~/bend-docscommunity

src/mp3_syn.bend checks

raw source on the hub · import emerging-ezaudio@0.7.0.0/src/mp3_syn.bend as Mp3_syn

MPEG-1 Layer III synthesis: antialias, IMDCT-36, sign flip, DCT-II, polyphase.

3 imports
import Base
import ./mp3_tab.bend as Tab
import ./mp3_enc.bend as Enc

Types

type D9 source · line 240 · raw

Data

even and odd 9-point DCT results, ready to interleave

type D9e source · line 246 · raw

Data

the even part of the 9-point DCT, from bins 0, 2, 4, 6 and 8

type D9o source · line 250 · raw

Data

the odd part of the 9-point DCT, from bins 1, 3, 5 and 7

type Wn source · line 284 · raw

Data

one windowed band: 18 time samples and 9 new overlap samples

type Ws source · line 288 · raw

Data

window product and the overlap it saves

type Dx source · line 339 · raw

Type

one F32 read from the IMDCT/DCT spectrum Array

type Il source · line 350 · raw

Type

spectrum Array beside the samples just read

type Im source · line 376 · raw

Type

576 lines in the spectrum Array, and 288 overlap samples

type Ia source · line 421 · raw

Type

spectrum Array beside the two aliasing samples

type Q4 source · line 513 · raw

Data

four DCT-II column results

type Dq source · line 541 · raw

Type

spectrum Array beside one finished column

type Dr source · line 577 · raw

Type

spectrum Array beside the 4 by 8 working rows

type E8 source · line 595 · raw

Data

eight floats carried through the DCT-II row butterfly

type Sv source · line 691 · raw

Type

seven samples of one scatter column, row-major

type Sc source · line 741 · raw

Type

spectrum Array beside the rows Array

type Sf source · line 782 · raw

Type

row 0, 1, 2 and 3 of column 7

type La source · line 857 · raw

Type

one F32 read from the polyphase delay Array

type Mac source · line 892 · raw

Data

four running polyphase sums, a and b

type Mk source · line 896 · raw

Type

MAC state plus the delay line handle mac.* only reads

type Sw source · line 1011 · raw

Type

one window coefficient handed back beside the table Array.get just read

type Mw source · line 1026 · raw

Type

MAC state plus the window table the next load still reads

type Ga source · line 1096 · raw

Type

one F32 read from the post-DCT granule Array

type Lg source · line 1107 · raw

Type

delay line handed back beside the granule Array a write just read

type Pp source · line 1504 · raw

Type

PCM and delay line while pairing synth samples

type Sb source · line 1530 · raw

Type

delay line and the PCM written so far

type Bg source · line 1543 · raw

Type

polyphase state, the granule Array the rows still read, and the window table

type Sr source · line 1561 · raw

Type

a finished row, with the window table the next row still reads

type Pc source · line 1662 · raw

Data

PCM, the overlap to carry, and the polyphase delay

Definitions

def f.add source · line 7 · raw

@+aa:F32 -> @+bb:F32 -> F32

add two binary32 values

def f.sub source · line 11 · raw

@+aa:F32 -> @+bb:F32 -> F32

subtract two binary32 values

def f.mul source · line 15 · raw

@+aa:F32 -> @+bb:F32 -> F32

multiply two binary32 values

def f.at source · line 19 · raw

@+xs:List<&2, F32> -> @+ii:U32 -> F32

sample at an index, or 0 past the end

def f.set source · line 23 · raw

@xs:List<&2, F32> -> @+ii:U32 -> @+vv:F32 -> List<&2, F32>

replace one sample

def u.add source · line 27 · raw

@+aa:U32 -> @+bb:U32 -> U32

unsigned add

def u.sub source · line 31 · raw

@+aa:U32 -> @+bb:U32 -> U32

unsigned subtract

def u.mul source · line 35 · raw

@+aa:U32 -> @+bb:U32 -> U32

unsigned multiply

def u.and source · line 39 · raw

@+kk:U32 -> U32

low bit

def c.half source · line 43 · raw

F32

0.5

def c.c939 source · line 47 · raw

F32

0.93969262

def c.c766 source · line 51 · raw

F32

0.76604444

def c.c173 source · line 55 · raw

F32

0.17364818

def c.c866 source · line 59 · raw

F32

0.86602540

def c.c984 source · line 63 · raw

F32

0.98480775

def c.c342 source · line 67 · raw

F32

0.34202014

def c.c642 source · line 71 · raw

F32

0.64278761

def c.c707 source · line 75 · raw

F32

0.70710677

def c.c198 source · line 79 · raw

F32

0.198912367

def c.c382 source · line 83 · raw

F32

0.382683432

def c.c509 source · line 87 · raw

F32

0.50979561

def c.c541 source · line 91 · raw

F32

0.54119611

def c.c601 source · line 95 · raw

F32

0.60134488

def c.c899 source · line 99 · raw

F32

0.89997619

def c.c130 source · line 103 · raw

F32

1.30656302

def c.c256 source · line 107 · raw

F32

2.56291556

def c.inv source · line 111 · raw

F32

1/32768, the polyphase scale

def ls.drop source · line 115 · raw

@hop:Nat -> @xs:List<&2, F32> -> List<&2, F32>

drop a prefix

def ls.take source · line 125 · raw

@hop:Nat -> @xs:List<&2, F32> -> @acc:List<&2, F32> -> List<&2, F32>

take a prefix, reversed into acc

def ls.slice source · line 135 · raw

@+xs:List<&2, F32> -> @+at:U32 -> @hop:Nat -> List<&2, F32>

a slice of length hop starting at an index

def ls.poke source · line 139 · raw

@hop:Nat -> @dst:List<&2, F32> -> @src:List<&2, F32> -> @+at:U32 -> List<&2, F32>

write a short list over a destination starting at an index

def cs.co source · line 149 · raw

@+gg:List<&2, F32> -> List<&2, F32>

cosine half of one IMDCT-36 band

def cs.si source · line 157 · raw

@+gg:List<&2, F32> -> List<&2, F32>

sine half of one IMDCT-36 band

def d9.t0 source · line 164 · raw

@+y0:F32 -> @+y6:F32 -> F32

even-part sum used by the 9-point DCT

def d9.s0 source · line 168 · raw

@+y0:F32 -> @+y6:F32 -> F32

even-part difference

def d9.t4 source · line 172 · raw

@+y4:F32 -> @+y2:F32 -> F32

twiddle on bins 4 and 2

def d9.t2 source · line 176 · raw

@+y8:F32 -> @+y2:F32 -> F32

twiddle on bins 8 and 2

def d9.s6 source · line 180 · raw

@+y4:F32 -> @+y8:F32 -> F32

twiddle on bins 4 and 8

def d9.s4 source · line 184 · raw

@+y4:F32 -> @+y8:F32 -> @+y2:F32 -> F32

even residual

def d9.s2 source · line 188 · raw

@+s0:F32 -> @+s4:F32 -> F32

scaled residual

def d9.y4 source · line 192 · raw

@+s4:F32 -> @+s0:F32 -> F32

centre bin of the even DCT

def d9.s8c source · line 196 · raw

@+t0:F32 -> @+t2:F32 -> @+s6:F32 -> F32

high even output

def d9.s0c source · line 200 · raw

@+t0:F32 -> @+t4:F32 -> @+t2:F32 -> F32

low even output

def d9.s4c source · line 204 · raw

@+t0:F32 -> @+t4:F32 -> @+s6:F32 -> F32

mid even output

def d9.s3 source · line 208 · raw

@+y3:F32 -> F32

odd centre

def d9.tb0 source · line 212 · raw

@+y5:F32 -> @+y1:F32 -> F32

odd low twiddle

def d9.tb4 source · line 216 · raw

@+y5:F32 -> @+y7:F32 -> F32

odd high twiddle

def d9.tb2 source · line 220 · raw

@+y1:F32 -> @+y7:F32 -> F32

odd mid twiddle

def d9.s1 source · line 224 · raw

@+y1:F32 -> @+y5:F32 -> @+y7:F32 -> F32

odd residual

def d9.s5c source · line 228 · raw

@+t0:F32 -> @+s3:F32 -> @+t2:F32 -> F32

odd combination

def d9.s7c source · line 232 · raw

@+t4:F32 -> @+s3:F32 -> @+t0:F32 -> F32

odd combination

def d9.s3c source · line 236 · raw

@+t4:F32 -> @+s3:F32 -> @+t2:F32 -> F32

odd combination

def d9.even source · line 253 · raw

@+y0:F32 -> @+y2:F32 -> @+y4:F32 -> @+y6:F32 -> @+y8:F32 -> D9e

def d9.odd source · line 256 · raw

@+y1:F32 -> @+y3:F32 -> @+y5:F32 -> @+y7:F32 -> D9o

def d9.from source · line 260 · raw

@ev:D9e -> @od:D9o -> D9

assemble the nine DCT outputs from the even and odd parts

def d9.list source · line 267 · raw

@dd:D9 -> List<&2, F32>

nine DCT outputs in bin order

def d9.run source · line 274 · raw

@+ys:List<&2, F32> -> List<&2, F32>

9-point DCT

def d9.neg source · line 279 · raw

@+ys:List<&2, F32> -> List<&2, F32>

negate the odd bins of a sine DCT

def wn.pair source · line 292 · raw

@+co:List<&2, F32> -> @+si:List<&2, F32> -> @+tw:List<&2, F32> -> @+ii:U32 -> Ws

aliasing pair for one window index

def wn.put source · line 297 · raw

@st:Wn -> @+ov:List<&2, F32> -> @+win:List<&2, F32> -> @+ii:U32 -> @ws:Ws -> Wn

write one window index into the band

def wn.one source · line 305 · raw

@st:Wn -> @+co:List<&2, F32> -> @+si:List<&2, F32> -> @+ov:List<&2, F32> -> @+tw:List<&2, F32> -> @+win:List<&2, F32> -> @+ii:U32 -> Wn

one of the nine window steps

def wn.go source · line 317 · raw

@hop:Nat -> @st:Wn -> @+co:List<&2, F32> -> @+si:List<&2, F32> -> @+ov:List<&2, F32> -> @+tw:List<&2, F32> -> @+win:List<&2, F32> -> @+ii:U32 -> Wn

window all nine indices

def im.band source · line 334 · raw

@+gg:List<&2, F32> -> @+ov:List<&2, F32> -> @+tw:List<&2, F32> -> @+win:List<&2, F32> -> Wn

IMDCT-36 of one 18-point band

def dx.of source · line 342 · raw

@got:Pair(Array<F32>, F32) -> Dx

def dx.at source · line 346 · raw

@acc:Array<F32> -> @+ii:U32 -> Dx

def ix.pull source · line 354 · raw

@hop:Nat -> @got:Dx -> @+ii:U32 -> @ys:List<&2, F32> -> Il

pull one sample; hop is remaining after this read

def ix.take source · line 362 · raw

@acc:Array<F32> -> @+at:U32 -> @hop:Nat -> Il

hop+1 samples starting at at. The spectrum Array is handed back.

def ix.poke source · line 366 · raw

@hop:Nat -> @acc:Array<F32> -> @src:List<&2, F32> -> @+at:U32 -> Array<F32>

write a short list into the spectrum Array

def im.store source · line 380 · raw

@buf:Array<F32> -> @+ov:List<&2, F32> -> @ww:Wn -> @+jj:U32 -> @+base:U32 -> Im

write one band back into the spectrum Array and the overlap

def im.got source · line 386 · raw

@got:Il -> @+ov:List<&2, F32> -> @+tw:List<&2, F32> -> @+win:List<&2, F32> -> @+jj:U32 -> @+base:U32 -> Im

band samples in hand; window them and store

def im.one source · line 399 · raw

@st:Im -> @+tw:List<&2, F32> -> @+win:List<&2, F32> -> @+jj:U32 -> @+base:U32 -> Im

IMDCT-36 of band jj. Each of the 18 samples is an Array.get.

def im.go source · line 405 · raw

@hop:Nat -> @st:Im -> @+tw:List<&2, F32> -> @+win:List<&2, F32> -> @+jj:U32 -> @+base:U32 -> Im

IMDCT-36 over 32 bands. base is the channel offset in the spectrum Array.

def aa.ixh source · line 413 · raw

@+base:U32 -> @+bb:U32 -> @+ii:U32 -> U32

high index of one aliasing pair

def aa.ixl source · line 417 · raw

@+base:U32 -> @+bb:U32 -> @+ii:U32 -> U32

low index of one aliasing pair

def aa.lo source · line 425 · raw

@got:Dx -> @+up:F32 -> Ia

low sample, then both indices are in hand

def aa.rd1 source · line 431 · raw

@got:Dx -> @+lo:U32 -> Ia

high sample in hand; read the low sample next

def aa.rd source · line 437 · raw

@acc:Array<F32> -> @+hi:U32 -> @+lo:U32 -> Ia

read both samples of one aliasing pair. Each read is an Array.get.

def aa.wr source · line 441 · raw

@acc:Array<F32> -> @+up:F32 -> @+dp:F32 -> @+c0:F32 -> @+c1:F32 -> @+hi:U32 -> @+lo:U32 -> Array<F32>

butterfly of one aliasing pair. c0 and c1 are the two cosine rows.

def aa.use source · line 454 · raw

@got:Ia -> @+c0:F32 -> @+c1:F32 -> @+hi:U32 -> @+lo:U32 -> Array<F32>

write the pair once both samples have been read

def aa.one source · line 460 · raw

@acc:Array<F32> -> @+aa:List<&2, F32> -> @+bb:U32 -> @+ii:U32 -> @+base:U32 -> Array<F32>

one butterfly at index ii of band bb

def aa.i source · line 465 · raw

@hop:Nat -> @acc:Array<F32> -> @+aa:List<&2, F32> -> @+bb:U32 -> @+ii:U32 -> @+base:U32 -> Array<F32>

eight butterflies between band bb and the next

def aa.b source · line 473 · raw

@hop:Nat -> @acc:Array<F32> -> @+aa:List<&2, F32> -> @+bb:U32 -> @+base:U32 -> Array<F32>

antialias from low bands toward high bands

def aa.run source · line 481 · raw

@acc:Array<F32> -> @+aa:List<&2, F32> -> @+base:U32 -> Array<F32>

31 long-block aliasing pairs. base is the channel offset in the spectrum Array.

def sg.neg source · line 485 · raw

@got:Dx -> @+at:U32 -> Array<F32>

negate the sample just read

def sg.i source · line 491 · raw

@hop:Nat -> @acc:Array<F32> -> @+base:U32 -> @+ii:U32 -> Array<F32>

negate one odd sample of an odd band

def sg.b source · line 499 · raw

@hop:Nat -> @acc:Array<F32> -> @+base:U32 -> Array<F32>

odd samples of 16 odd bands, starting at sample 18

def im.sign source · line 507 · raw

@st:Im -> @+base:U32 -> Im

frequency inversion after the IMDCT. base is the channel offset.

def dc.x0 source · line 517 · raw

@acc:Array<F32> -> @+kk:U32 -> @+ii:U32 -> Dx

column sample i of the 32-band vector

def dc.x1 source · line 521 · raw

@acc:Array<F32> -> @+kk:U32 -> @+ii:U32 -> Dx

mirrored column

def dc.x2 source · line 525 · raw

@acc:Array<F32> -> @+kk:U32 -> @+ii:U32 -> Dx

upper column

def dc.x3 source · line 529 · raw

@acc:Array<F32> -> @+kk:U32 -> @+ii:U32 -> Dx

upper mirror

def dc.q2 source · line 533 · raw

@+t0:F32 -> @+t1:F32 -> @+t2:F32 -> @+t3:F32 -> @+s2:F32 -> Q4

finish the column butterfly

def dc.q source · line 537 · raw

@+x0:F32 -> @+x1:F32 -> @+x2:F32 -> @+x3:F32 -> @+s0:F32 -> @+s1:F32 -> @+s2:F32 -> Q4

one DCT-II column from four samples and three secants

def dc.rd3 source · line 545 · raw

@got:Dx -> @+x0:F32 -> @+x1:F32 -> @+x2:F32 -> @+s0:F32 -> @+s1:F32 -> @+s2:F32 -> Dq

fourth sample, then the column butterfly

def dc.rd2 source · line 551 · raw

@got:Dx -> @+sec:List<&2, F32> -> @+kk:U32 -> @+ii:U32 -> @+x0:F32 -> @+x1:F32 -> Dq

third sample and the three secants

def dc.rd1 source · line 558 · raw

@got:Dx -> @+sec:List<&2, F32> -> @+kk:U32 -> @+ii:U32 -> @+x0:F32 -> Dq

second sample

def dc.cell source · line 564 · raw

@got:Dx -> @+sec:List<&2, F32> -> @+kk:U32 -> @+ii:U32 -> Dq

read column ii. Each of the four samples is an Array.get.

def dc.store source · line 570 · raw

@xs:Array<F32> -> @qq:Q4 -> @+ii:U32 -> Array<F32>

store one column into the 4 by 8 working Array

def dc.stored source · line 581 · raw

@got:Dq -> @xs:Array<F32> -> @+ii:U32 -> Dr

write one gathered column and keep both Arrays

def dc.cols source · line 587 · raw

@hop:Nat -> @got:Dr -> @+sec:List<&2, F32> -> @+kk:U32 -> @+ii:U32 -> Dr

gather all eight columns before any write-back

def but.sum2 source · line 599 · raw

@+xt:F32 -> @+y0:F32 -> @+y7:F32 -> @+y1:F32 -> @+y6:F32 -> @+y2:F32 -> @+y5:F32 -> @+y3:F32 -> E8

finish the first stage

def but.sum source · line 612 · raw

@+x0:F32 -> @+x1:F32 -> @+x2:F32 -> @+x3:F32 -> @+x4:F32 -> @+x5:F32 -> @+x6:F32 -> @+x7:F32 -> E8

first add/sub stage of a DCT-II row

def but.mid source · line 617 · raw

@ee:E8 -> E8

second stage: the 45-degree rotations

def but.rot3 source · line 624 · raw

@+o0:F32 -> @+w3:F32 -> @+w6:F32 -> @+y4:F32 -> @+o4:F32 -> @+p5:F32 -> @+p7:F32 -> @+xt:F32 -> E8

last rotation update

def but.rot2 source · line 637 · raw

@+o0:F32 -> @+w3:F32 -> @+w6:F32 -> @+y4:F32 -> @+o4:F32 -> @+p5:F32 -> @+w7:F32 -> @+xt:F32 -> E8

complete the rotation

def but.rot source · line 650 · raw

@ee:E8 -> E8

third stage: the small-angle rotation, using the updated values

def but.end source · line 656 · raw

@ee:E8 -> List<&2, F32>

eight row outputs

def but.out source · line 664 · raw

@ee:E8 -> List<&2, F32>

the eight row outputs, in order

def but.sum8 source · line 668 · raw

@acc:Array<F32> -> @+ys:List<&2, F32> -> @+base:U32 -> Array<F32>

butterfly the eight samples and write the row back

def but.use source · line 673 · raw

@got:Il -> @+base:U32 -> Array<F32>

butterfly one row. The eight inputs are one slice of the working Array.

def but.row source · line 679 · raw

@xs:Array<F32> -> @+base:U32 -> Array<F32>

butterfly one row of eight and write it back

def dc.fly source · line 683 · raw

@hop:Nat -> @xs:Array<F32> -> @+base:U32 -> Array<F32>

butterfly all four rows

def sc.v6 source · line 695 · raw

@got:Dx -> @+r0:F32 -> @+r1:F32 -> @+r1n:F32 -> @+r2:F32 -> @+r2n:F32 -> @+r3:F32 -> Sv

row 3, column ii+1

def sc.v5 source · line 701 · raw

@got:Dx -> @+ii:U32 -> @+r0:F32 -> @+r1:F32 -> @+r1n:F32 -> @+r2:F32 -> @+r2n:F32 -> Sv

row 3, column ii

def sc.v4 source · line 707 · raw

@got:Dx -> @+ii:U32 -> @+r0:F32 -> @+r1:F32 -> @+r1n:F32 -> @+r2:F32 -> Sv

row 2, column ii+1

def sc.v3 source · line 713 · raw

@got:Dx -> @+ii:U32 -> @+r0:F32 -> @+r1:F32 -> @+r1n:F32 -> Sv

row 2, column ii

def sc.v2 source · line 719 · raw

@got:Dx -> @+ii:U32 -> @+r0:F32 -> @+r1:F32 -> Sv

row 1, column ii+1

def sc.v1 source · line 725 · raw

@got:Dx -> @+ii:U32 -> @+r0:F32 -> Sv

row 1, column ii

def sc.v0 source · line 731 · raw

@got:Dx -> @+ii:U32 -> Sv

row 0, column ii, then the six neighbour slots

def sc.vals source · line 737 · raw

@xs:Array<F32> -> @+ii:U32 -> Sv

the seven samples of column ii, each an Array.get

def sc.bands source · line 745 · raw

@+p0:F32 -> @+p1:F32 -> @+p2:F32 -> @+p3:F32 -> @+p4:F32 -> @+p5:F32 -> @+p6:F32 -> Q4

four band values from the seven column samples

def sc.put4 source · line 757 · raw

@xs:Array<F32> -> @acc:Array<F32> -> @qq:Q4 -> @+yy:U32 -> Sc

store the four bands and hand both Arrays back

def sc.put source · line 764 · raw

@got:Sv -> @acc:Array<F32> -> @+yy:U32 -> Sc

write one scatter group from the seven samples

def sc.one source · line 770 · raw

@acc:Array<F32> -> @xs:Array<F32> -> @+yy:U32 -> @+ii:U32 -> Sc

scatter one group of four bands into the spectrum Array

def sc.go source · line 774 · raw

@hop:Nat -> @got:Sc -> @+yy:U32 -> @+ii:U32 -> Sc

seven scatter steps; the eighth is the tail

def sc.e3 source · line 786 · raw

@got:Dx -> @+r0:F32 -> @+r1:F32 -> @+r2:F32 -> Sf

fourth tail sample, index 31

def sc.e2 source · line 792 · raw

@got:Dx -> @+r0:F32 -> @+r1:F32 -> Sf

third tail sample, index 23

def sc.e1 source · line 798 · raw

@got:Dx -> @+r0:F32 -> Sf

second tail sample, index 15

def sc.e0 source · line 804 · raw

@got:Dx -> Sf

first tail sample, index 7, then the other three rows

def sc.tset source · line 810 · raw

@acc:Array<F32> -> @+r0:F32 -> @+r1:F32 -> @+r2:F32 -> @+r3:F32 -> @+yy:U32 -> Array<F32>

four tail bands. r3 is both the high sum and the last band.

def sc.tend source · line 815 · raw

@got:Sf -> @acc:Array<F32> -> @+yy:U32 -> Array<F32>

drop the rows Array once the four tail samples have been read

def sc.tail source · line 823 · raw

@got:Sc -> @+yy:U32 -> Array<F32>

last scatter group, which has no i+1 neighbour. The rows Array ends here.

def sc.run source · line 829 · raw

@acc:Array<F32> -> @xs:Array<F32> -> @+kk:U32 -> Array<F32>

scatter every band of frequency bin kk

def dc.rows source · line 833 · raw

@got:Dr -> Dr

butterfly the gathered rows, then scatter them back into the spectrum

def dc.scat source · line 839 · raw

@got:Dr -> @+kk:U32 -> Array<F32>

scatter one frequency bin. The working rows are consumed here.

def dc.one source · line 845 · raw

@acc:Array<F32> -> @+sec:List<&2, F32> -> @+kk:U32 -> Array<F32>

one frequency bin of the 32-point DCT-II. The working rows stay an Array.

def dc.run source · line 849 · raw

@hop:Nat -> @acc:Array<F32> -> @+sec:List<&2, F32> -> @+kk:U32 -> Array<F32>

DCT-II of 18 frequency bins. kk is the first bin's index in the spectrum Array.

def la.of source · line 860 · raw

@got:Pair(Array<F32>, F32) -> La

def ln.at source · line 864 · raw

@lin:Array<F32> -> @+ii:U32 -> La

def ln.set source · line 867 · raw

@lin:Array<F32> -> @+ii:U32 -> @+vv:F32 -> Array<F32>

def ln.fill source · line 870 · raw

@xs:List<&2, F32> -> @a:Array<F32> -> @+ii:U32 -> Array<F32>

def ln.pull source · line 878 · raw

@hop:Nat -> @got:La -> @+ii:U32 -> @acc:List<&2, F32> -> List<&2, F32>

pull one sample into an accumulator; hop is remaining after this read

def ln.list source · line 888 · raw

@a:Array<F32> -> @hop:Nat -> List<&2, F32>

first hop+1 slots of an Array as a list

def mac.av source · line 900 · raw

@+mode:U32 -> @+zv:F32 -> @+yv:F32 -> @+w0:F32 -> @+w1:F32 -> F32

mode 0 replaces, mode 2 flips the a product, otherwise both add

def mac.wr source · line 908 · raw

@+aa:List<&2, F32> -> @+bb:List<&2, F32> -> @+mode:U32 -> @+jj:U32 -> @+bv:F32 -> @+av:F32 -> Mac

apply one lane of a window load

def mac.jy source · line 923 · raw

@st:Mac -> @got:La -> @+w0:F32 -> @+w1:F32 -> @+mode:U32 -> @+jj:U32 -> @+zv:F32 -> Mk

one of the four lanes, y slot

def mac.jz source · line 937 · raw

@st:Mac -> @got:La -> @+w0:F32 -> @+w1:F32 -> @+vy:U32 -> @+mode:U32 -> @+jj:U32 -> Mk

one of the four lanes, z slot

def mac.j source · line 951 · raw

@st:Mac -> @lin:Array<F32> -> @+w0:F32 -> @+w1:F32 -> @+vz:U32 -> @+vy:U32 -> @+mode:U32 -> @+jj:U32 -> Mk

one of the four lanes

def mac.js_next source · line 964 · raw

@mk:Mk -> @+w0:F32 -> @+w1:F32 -> @+vz:U32 -> @+vy:U32 -> @+mode:U32 -> @+jj:U32 -> Mk

four lanes of one load, advance one lane

def mac.js source · line 970 · raw

@hop:Nat -> @mk:Mk -> @+w0:F32 -> @+w1:F32 -> @+vz:U32 -> @+vy:U32 -> @+mode:U32 -> @+jj:U32 -> Mk

four lanes of one load

def mac.mode3 source · line 987 · raw

@odd:Bool -> U32

odd or even load

def mac.mode2 source · line 995 · raw

@zero:Bool -> @odd:Bool -> U32

pick the load mode

def mac.mode source · line 1003 · raw

@+kk:U32 -> U32

k = 0 replaces, odd k uses mode 2, other even k uses mode 1

def mac.pos source · line 1007 · raw

@+ii:U32 -> @+kk:U32 -> U32

window-coefficient index for block row ii and load kk

def sw.of source · line 1014 · raw

@got:Pair(Array<F32>, F32) -> Sw

def sw.at source · line 1018 · raw

@syn:Array<F32> -> @+ii:U32 -> Sw

def sw.tab source · line 1022 · raw

Array<F32>

242 synthesis-window coefficients. 256 slots cover every mac.pos index.

def mac.step2 source · line 1030 · raw

@mk:Mk -> @got:Sw -> @+w0:F32 -> @+zlin:U32 -> @+ii:U32 -> @+kk:U32 -> Mw

second coefficient, then the eight-lane load

def mac.step1 source · line 1037 · raw

@mk:Mk -> @got:Sw -> @+pos:U32 -> @+zlin:U32 -> @+ii:U32 -> @+kk:U32 -> Mw

first coefficient, then its neighbour

def mac.step source · line 1043 · raw

@mk:Mk -> @syn:Array<F32> -> @+zlin:U32 -> @+ii:U32 -> @+kk:U32 -> Mw

one of the eight loads. Each tap reads the window Array.

def mac.k source · line 1047 · raw

@hop:Nat -> @got:Mw -> @+zlin:U32 -> @+ii:U32 -> @+kk:U32 -> Mw

eight loads

def mac.sc source · line 1055 · raw

@+vv:F32 -> F32

scale a polyphase sum into a sample

def mac.p8 source · line 1059 · raw

@pcm:Array<F32> -> @+aa:List<&2, F32> -> @+bb:List<&2, F32> -> @+nch:U32 -> @+pcmi:U32 -> @+ii:U32 -> Array<F32>

write the eight samples this row produces

def mac.put source · line 1078 · raw

@pcm:Array<F32> -> @st:Mac -> @+nch:U32 -> @+pcmi:U32 -> @+ii:U32 -> Array<F32>

store the row

def mac.z source · line 1084 · raw

Mac

fresh accumulators

def blk.off source · line 1088 · raw

@+nch:U32 -> @right:Bool -> U32

channel offset: the right channel starts at 576 when there are two

def ga.of source · line 1099 · raw

@got:Pair(Array<F32>, F32) -> Ga

def ga.at source · line 1103 · raw

@gr:Array<F32> -> @+ii:U32 -> Ga

def blk.ix source · line 1111 · raw

@+nch:U32 -> @+band:U32 -> @+tm:U32 -> @right:Bool -> U32

subband index. right selects the second channel, which starts at 576.

def blk.rd source · line 1114 · raw

@gr:Array<F32> -> @+nch:U32 -> @+band:U32 -> @+tm:U32 -> @right:Bool -> Ga

def blk.w4d source · line 1118 · raw

@g:Ga -> @lin:Array<F32> -> @+at:U32 -> @+v0:F32 -> @+v1:F32 -> @+v2:F32 -> Lg

fourth sample of a four-lane write

def blk.w4c source · line 1125 · raw

@g:Ga -> @lin:Array<F32> -> @+nch:U32 -> @+at:U32 -> @+tm:U32 -> @+v0:F32 -> @+v1:F32 -> Lg

third sample: band 0, this channel's left slot

def blk.w4b source · line 1131 · raw

@g:Ga -> @lin:Array<F32> -> @+nch:U32 -> @+at:U32 -> @+tm:U32 -> @+v0:F32 -> Lg

second sample: the right channel of this band

def blk.w4a source · line 1137 · raw

@g:Ga -> @lin:Array<F32> -> @+nch:U32 -> @+at:U32 -> @+band:U32 -> @+tm:U32 -> Lg

first sample: the left channel of this band

def blk.w4 source · line 1143 · raw

@lin:Array<F32> -> @gr:Array<F32> -> @+nch:U32 -> @+at:U32 -> @+band:U32 -> @+tm:U32 -> Lg

write the four samples at zlin + 4*slot

def blk.w2b source · line 1154 · raw

@g:Ga -> @lin:Array<F32> -> @+at:U32 -> @+v0:F32 -> Lg

right channel of a two-lane write

def blk.w2a source · line 1160 · raw

@g:Ga -> @lin:Array<F32> -> @+nch:U32 -> @+at:U32 -> @+band:U32 -> @+tm:U32 -> Lg

left channel of a two-lane write

def blk.w2 source · line 1166 · raw

@lin:Array<F32> -> @gr:Array<F32> -> @+nch:U32 -> @+at:U32 -> @+band:U32 -> @+tm:U32 -> Lg

the second write of a row uses band (1+ii), not band 0

def blk.pre2 source · line 1177 · raw

@got:Lg -> @+nch:U32 -> @+zlin:U32 -> @+tm:U32 -> Lg

second preamble write: band 16 at the next time

def blk.pre source · line 1183 · raw

@lin:Array<F32> -> @gr:Array<F32> -> @+nch:U32 -> @+zlin:U32 -> @+tm:U32 -> Lg

preamble: bands 16 and 0 at the current and next time

def blk.hist source · line 1193 · raw

@+zlin:U32 -> @+ii:U32 -> U32

index of the history write, which steps back 16 slots

def blk.wsd source · line 1197 · raw

@g:Ga -> @lin:Array<F32> -> @+at:U32 -> @+v0:F32 -> @+v1:F32 -> @+v2:F32 -> Lg

fourth lane: this band at the next time, right channel

def blk.wsc source · line 1204 · raw

@g:Ga -> @lin:Array<F32> -> @+nch:U32 -> @+at:U32 -> @+band:U32 -> @+tm:U32 -> @+v0:F32 -> @+v1:F32 -> Lg

third lane: this band at the next time, left channel

def blk.wsb source · line 1219 · raw

@g:Ga -> @lin:Array<F32> -> @+nch:U32 -> @+at:U32 -> @+band:U32 -> @+tm:U32 -> @+v0:F32 -> Lg

second lane: this band at this time, right channel

def blk.wsa source · line 1225 · raw

@g:Ga -> @lin:Array<F32> -> @+nch:U32 -> @+at:U32 -> @+band:U32 -> @+tm:U32 -> Lg

first lane: this band at this time, left channel

def blk.ws source · line 1231 · raw

@lin:Array<F32> -> @gr:Array<F32> -> @+nch:U32 -> @+at:U32 -> @+band:U32 -> @+tm:U32 -> Lg

same band at this time and the next, four lanes

def blk.i1 source · line 1242 · raw

@lin:Array<F32> -> @gr:Array<F32> -> @+nch:U32 -> @+zlin:U32 -> @+tm:U32 -> @+ii:U32 -> Lg

current-slot writes for row ii

def blk.i2b source · line 1253 · raw

@got:Lg -> @+nch:U32 -> @+zlin:U32 -> @+tm:U32 -> @+ii:U32 -> Lg

history write, after the next-slot write has returned the granule

def blk.i2 source · line 1259 · raw

@lin:Array<F32> -> @gr:Array<F32> -> @+nch:U32 -> @+zlin:U32 -> @+tm:U32 -> @+ii:U32 -> Lg

next-slot and history writes for row ii

def blk.ib source · line 1271 · raw

@got:Lg -> @+nch:U32 -> @+zlin:U32 -> @+tm:U32 -> @+ii:U32 -> Lg

history writes, after the current-slot write has returned the granule

def blk.i source · line 1277 · raw

@lin:Array<F32> -> @gr:Array<F32> -> @+nch:U32 -> @+zlin:U32 -> @+tm:U32 -> @+ii:U32 -> Lg

both writes for row ii

def sp.a1a3 source · line 1288 · raw

@g1:La -> @+v896:F32 -> La

(z+896) - z, times 29

def sp.a1a2 source · line 1293 · raw

@g0:La -> @+zz:U32 -> La

def sp.a1a source · line 1298 · raw

@lin:Array<F32> -> @+zz:U32 -> La

def sp.a1b2 source · line 1302 · raw

@g1:La -> @+acc:F32 -> @+v64:F32 -> La

slots 1 and 13, times 213

def sp.a1b1 source · line 1307 · raw

@g0:La -> @+acc:F32 -> @+zz:U32 -> La

def sp.a1b source · line 1312 · raw

@+acc:F32 -> @lin:Array<F32> -> @+zz:U32 -> La

def sp.a1c2 source · line 1316 · raw

@g1:La -> @+acc:F32 -> @+v768:F32 -> La

slots 12 and 2, times 459

def sp.a1c1 source · line 1321 · raw

@g0:La -> @+acc:F32 -> @+zz:U32 -> La

def sp.a1c source · line 1326 · raw

@+acc:F32 -> @lin:Array<F32> -> @+zz:U32 -> La

def sp.a1d2 source · line 1330 · raw

@g1:La -> @+acc:F32 -> @+v192:F32 -> La

slots 3 and 11, times 2037

def sp.a1d1 source · line 1335 · raw

@g0:La -> @+acc:F32 -> @+zz:U32 -> La

def sp.a1d source · line 1340 · raw

@+acc:F32 -> @lin:Array<F32> -> @+zz:U32 -> La

def sp.a1e2 source · line 1344 · raw

@g1:La -> @+acc:F32 -> @+v640:F32 -> La

slots 10 and 4, times 5153

def sp.a1e1 source · line 1349 · raw

@g0:La -> @+acc:F32 -> @+zz:U32 -> La

def sp.a1e source · line 1354 · raw

@+acc:F32 -> @lin:Array<F32> -> @+zz:U32 -> La

def sp.a1f2 source · line 1358 · raw

@g1:La -> @+acc:F32 -> @+v320:F32 -> La

slots 5 and 9, times 6574

def sp.a1f1 source · line 1363 · raw

@g0:La -> @+acc:F32 -> @+zz:U32 -> La

def sp.a1f source · line 1368 · raw

@+acc:F32 -> @lin:Array<F32> -> @+zz:U32 -> La

def sp.a1g4 source · line 1372 · raw

@g2:La -> @+acc:F32 -> @+v512:F32 -> @+v384:F32 -> La

slots 8 and 6, times 37489, then slot 7 times 75038

def sp.a1g3 source · line 1379 · raw

@g1:La -> @+acc:F32 -> @+v512:F32 -> @+zz:U32 -> La

def sp.a1g2 source · line 1384 · raw

@g0:La -> @+acc:F32 -> @+zz:U32 -> La

def sp.a1g source · line 1389 · raw

@+acc:F32 -> @lin:Array<F32> -> @+zz:U32 -> La

def sp.a1go6 source · line 1392 · raw

@g:La -> @+zz:U32 -> La

def sp.a1go5 source · line 1397 · raw

@g:La -> @+zz:U32 -> La

def sp.a1go4 source · line 1402 · raw

@g:La -> @+zz:U32 -> La

def sp.a1go3 source · line 1407 · raw

@g:La -> @+zz:U32 -> La

def sp.a1go2 source · line 1412 · raw

@g:La -> @+zz:U32 -> La

def sp.a1go1 source · line 1417 · raw

@g:La -> @+zz:U32 -> La

def sp.a1 source · line 1423 · raw

@lin:Array<F32> -> @+zz:U32 -> La

first grouped window sum

def sp.a2a4 source · line 1427 · raw

@g3:La -> @+v898:F32 -> @+v770:F32 -> @+v642:F32 -> La

taps 898, 770, 642, 514

def sp.a2a3 source · line 1434 · raw

@g2:La -> @+v898:F32 -> @+v770:F32 -> @+zz:U32 -> La

def sp.a2a2 source · line 1439 · raw

@g1:La -> @+v898:F32 -> @+zz:U32 -> La

def sp.a2a1 source · line 1444 · raw

@g0:La -> @+zz:U32 -> La

def sp.a2a source · line 1449 · raw

@lin:Array<F32> -> @+zz:U32 -> La

def sp.a2b2 source · line 1453 · raw

@g1:La -> @+acc:F32 -> @+v386:F32 -> La

taps 386 and 258

def sp.a2b1 source · line 1458 · raw

@g0:La -> @+acc:F32 -> @+zz:U32 -> La

def sp.a2b source · line 1463 · raw

@+acc:F32 -> @lin:Array<F32> -> @+zz:U32 -> La

def sp.a2c1 source · line 1467 · raw

@g:La -> @+acc:F32 -> La

tap 130

def sp.a2c source · line 1472 · raw

@+acc:F32 -> @lin:Array<F32> -> @+zz:U32 -> La

def sp.a2d1 source · line 1476 · raw

@g:La -> @+acc:F32 -> La

tap 2

def sp.a2d source · line 1481 · raw

@+acc:F32 -> @lin:Array<F32> -> @+zz:U32 -> La

def sp.a2go3 source · line 1484 · raw

@g:La -> @+zz:U32 -> La

def sp.a2go2 source · line 1489 · raw

@g:La -> @+zz:U32 -> La

def sp.a2go1 source · line 1494 · raw

@g:La -> @+zz:U32 -> La

def sp.a2 source · line 1500 · raw

@lin:Array<F32> -> @+zz:U32 -> La

second window sum, eight weighted taps

def sp.pair2 source · line 1508 · raw

@g2:La -> @pcm:Array<F32> -> @+pcmi:U32 -> @+nch:U32 -> Pp

one synth pair: two scaled samples

def sp.pair1 source · line 1513 · raw

@g1:La -> @pcm:Array<F32> -> @+pcmi:U32 -> @+nch:U32 -> @+zz:U32 -> Pp

def sp.pair source · line 1518 · raw

@st:Pp -> @+pcmi:U32 -> @+nch:U32 -> @+zz:U32 -> Pp

def blk.pairs source · line 1524 · raw

@st:Pp -> @+nch:U32 -> @+pcmi:U32 -> @+z0:U32 -> Pp

four synth pairs that open a block

def blk.armed1 source · line 1533 · raw

@got:Pp -> Sb

def blk.armed source · line 1539 · raw

@lin:Array<F32> -> @pcm:Array<F32> -> @+nch:U32 -> @+tm:U32 -> Sb

pairs read the delay line the preamble just wrote

def blk.arm2 source · line 1547 · raw

@got:Lg -> @pcm:Array<F32> -> @syn:Array<F32> -> @+nch:U32 -> @+tm:U32 -> Bg

preamble done: the pairs read the delay line, the granule and window stay put

def blk.arm source · line 1553 · raw

@got:Bg -> @+nch:U32 -> @+tm:U32 -> Bg

open a block: preamble, then the four pairs

def blk.row1 source · line 1564 · raw

@got:Mw -> @pcm:Array<F32> -> @+nch:U32 -> @+tm:U32 -> @+ii:U32 -> Sr

def blk.row3 source · line 1571 · raw

@got:Sr -> @gr:Array<F32> -> Bg

def blk.row source · line 1577 · raw

@lin:Array<F32> -> @pcm:Array<F32> -> @syn:Array<F32> -> @+nch:U32 -> @+tm:U32 -> @+ii:U32 -> Sr

window the row just written

def blk.step2 source · line 1588 · raw

@got:Lg -> @pcm:Array<F32> -> @syn:Array<F32> -> @+nch:U32 -> @+tm:U32 -> @+ii:U32 -> Bg

window the row, keeping the granule for the rows still to come

def blk.step source · line 1601 · raw

@got:Bg -> @+nch:U32 -> @+tm:U32 -> @+ii:U32 -> Bg

one row of the block, from i = 14 down to 0

def blk.i.go source · line 1609 · raw

@hop:Nat -> @got:Bg -> @+nch:U32 -> @+tm:U32 -> @+ii:U32 -> Bg

fifteen rows

def blk.one source · line 1617 · raw

@got:Bg -> @+nch:U32 -> @+tm:U32 -> Bg

one time block

def blk.go source · line 1621 · raw

@hop:Nat -> @got:Bg -> @+nch:U32 -> @+tm:U32 -> Bg

nine time blocks, time = 0, 2, ..., 16

def qmf.ev source · line 1630 · raw

@hop:Nat -> @old:List<&2, F32> -> @got:La -> @+ii:U32 -> @acc:List<&2, F32> -> List<&2, F32>

one even delay sample and the odd slot kept from the carried tail. hop is the pairs still to come after this one. The sample was read at ii.

def qmf.st source · line 1644 · raw

@+old:List<&2, F32> -> @lin:Array<F32> -> List<&2, F32>

stereo tail: 960 delay-Array samples in one pull. The old list is dropped.

def qmf.pick source · line 1650 · raw

@mono:Bool -> @+qmf:List<&2, F32> -> @lin:Array<F32> -> List<&2, F32>

mono keeps odd slots; stereo replaces the whole tail from the delay Array

def qmf.save source · line 1658 · raw

@lin:Array<F32> -> @+qmf:List<&2, F32> -> @+nch:U32 -> List<&2, F32>

save the 15-block tail off the delay Array, one pass, no List.set

def syn.zov source · line 1666 · raw

List<&2, F32>

zero overlap, 288 samples, one channel

def syn.zqmf source · line 1670 · raw

List<&2, F32>

zero polyphase delay

def ch.prep source · line 1674 · raw

@acc:Array<F32> -> @+ov:List<&2, F32> -> @+aa:List<&2, F32> -> @+tw:List<&2, F32> -> @+win:List<&2, F32> -> @+base:U32 -> Im

antialias, IMDCT, and the sign flip for one channel

def syn.st2 source · line 1685 · raw

@+ova:List<&2, F32> -> @bb:Im -> Im

append the second channel's overlap. The spectrum Array already holds both.

def syn.st source · line 1691 · raw

@aa:Im -> @+ovb:List<&2, F32> -> @+cs:List<&2, F32> -> @+tw:List<&2, F32> -> @+win:List<&2, F32> -> Im

join two channel states. The right channel starts at bin 576.

def syn.ch source · line 1703 · raw

@mono:Bool -> @acc:Array<F32> -> @+ov:List<&2, F32> -> @+aa:List<&2, F32> -> @+tw:List<&2, F32> -> @+win:List<&2, F32> -> Im

prepare one or two channels

def syn.ready source · line 1718 · raw

@+spec:List<&2, F32> -> @+ov:List<&2, F32> -> @+nch:U32 -> Im

tables shared by a granule. 2048 slots cover mono 576 and stereo 1152.

def sy.dct2 source · line 1723 · raw

@mono:Bool -> @acc:Array<F32> -> @+sec:List<&2, F32> -> Array<F32>

second channel starts at bin 576

def sy.dct source · line 1731 · raw

@mono:Bool -> @acc:Array<F32> -> @+sec:List<&2, F32> -> Array<F32>

DCT-II of each channel. The spectrum Array is the one IMDCT just wrote.

def sy.lin source · line 1735 · raw

@+qmf:List<&2, F32> -> Array<F32>

delay line: the carried tail, then zeros (4096-slot Array starts at 0.0)

def sy.pcm source · line 1739 · raw

Array<F32>

empty PCM for one granule (2048-slot Array covers mono 576 and stereo 1152)

def sy.pcm.list source · line 1743 · raw

@+nch:U32 -> @pcm:Array<F32> -> List<&2, F32>

PCM Array back to a list of length 576*nch

def syn.drop source · line 1747 · raw

@gr:Array<F32> -> @st:Sb -> @+ov:List<&2, F32> -> @+qmf:List<&2, F32> -> @+nch:U32 -> Pc

the granule Array is finished once the nine blocks have read it

def syn.out source · line 1755 · raw

@got:Bg -> @+ov:List<&2, F32> -> @+qmf:List<&2, F32> -> @+nch:U32 -> Pc

run the polyphase and keep the overlap from the IMDCT

def syn.pcm source · line 1763 · raw

@buf:Array<F32> -> @+ov:List<&2, F32> -> @+qmf:List<&2, F32> -> @+nch:U32 -> Pc

DCT-II then nine polyphase blocks. The spectrum Array is what the polyphase reads.

def syn.finish source · line 1768 · raw

@st:Im -> @+qmf:List<&2, F32> -> @+nch:U32 -> Pc

synthesis of a prepared granule

def syn.gran source · line 1774 · raw

@+spec:List<&2, F32> -> @+ov:List<&2, F32> -> @+qmf:List<&2, F32> -> @+nch:U32 -> Pc

one granule to PCM. spec is 576 samples per channel. ov is 288 per channel.

def syn.im source · line 1778 · raw

@+buf:List<&2, F32> -> @+ov:List<&2, F32> -> Im

IMDCT only, 32 bands, no antialias. Used to check the unit impulse.

def syn.nth source · line 1783 · raw

@st:Pc -> @+ii:U32 -> U32

one PCM sample of a granule, as a binary32 word

def syn.word1 source · line 1789 · raw

@got:Dx -> U32

drop the spectrum Array once sample 0 has been read

def syn.word source · line 1797 · raw

@st:Im -> U32

first sample of an IMDCT buffer, as a binary32 word

def syn.probe source · line 1803 · raw

@+ii:U32 -> U32

PCM word ii of one granule whose spectrum is a unit impulse at bin 0.

def syn.impulse source · line 1808 · raw

U32

unit impulse at bin 0. The first sample is the float32 word 1022453915.