audiofile = data( './resources/audiofiles/dead-presidents.wav' ).then( ()=> {
  
damp1  = param( 'damp1', .25 )
damp2  = param( 'damp2', .25 )
maindamp = param( 'maindamp', .5 )
period1 = param( 'period1', 11025 )
period2 = param( 'period2', 5512 )
router  = param( 'router',  0)
 
in1 = peek( 
  audiofile, // data
  accum( 1,0,{ max:audiofile.buffer.length } ), // indexing
  { interp:'none', mode:'samples' } 			// attributes
)
 
fbL1 = ssd(); fbL2 = ssd(); fbR1 = ssd(); fbR2 = ssd()
 
gateL1 = gate( router, fbL1.out, { count:4 } )
gateL2 = gate( router, fbL2.out, { count:4 } )
gateR1 = gate( router, fbR1.out, { count:4 } )
gateR2 = gate( router, fbR2.out, { count:4 } )
 
delayL1In = add( in1, gateL1.outputs[0], gateL2.outputs[1], gateR1.outputs[2], gateR2.outputs[2] )
delayL2In = add( in1, gateL1.outputs[1], gateL2.outputs[0], gateR1.outputs[3], gateR2.outputs[3] )
delayR1In = add( in1, gateL1.outputs[2], gateL2.outputs[3], gateR1.outputs[0], gateR2.outputs[1] )
delayR2In = add( in1, gateL1.outputs[3], gateL2.outputs[2], gateR1.outputs[1], gateR2.outputs[0] )
 
delayL1 = delay( delayL1In, period1,  {size:44100, interp:'none'})
delayL2 = delay( delayL2In, period2,  {size:44100, interp:'none'})
delayR1 = delay( delayR1In, period1,  {size:44100, interp:'none'})
delayR2 = delay( delayR2In, period2,  {size:44100, interp:'none'})
 
delayL1F = fold( delayL1, -1,1 )
delayL2F = fold( delayL2, -1,1 )
delayR1F = fold( delayR1, -1,1 )
delayR2F = fold( delayR2, -1,1 )
 
mixL1 = memo( mix( delayL1F, fbL1.out, damp1 ) )
mixL2 = memo( mix( delayL2F, fbL2.out, damp2 ) )
mixR1 = memo( mix( delayR1F, fbR1.out, damp1 ) )
mixR2 = memo( mix( delayR2F, fbR2.out, damp2 ) )
 
fbL1.in( mixL1 ); fbL2.in( mixL2 ); fbR1.in( mixR1 ); fbR2.in( mixR2 )
 
fbL = ssd(); fbR = ssd() 
 
mainL = memo( mix( mul( add( mixL1, mixL2 ), .5 ), fbL.out, maindamp ) )
mainR = memo( mix( mul( add( mixR1, mixR2 ), .5 ), fbR.out, maindamp ) )
 
fbL.in( mainL ); fbR.in( mainR )
 
cb = play( [mainL, mainR] )
 
gui = new dat.GUI()
gui.add( cb, 'damp1', 0, 1 )
gui.add( cb, 'damp2', 0, 1 )
gui.add( cb, 'maindamp', 0, 1 )
gui.add( cb, 'period1', 64, 22050 ).step(1)
gui.add( cb, 'period2', 64, 22050 ).step(1)
gui.add( cb, 'router', 0,3 ).step(1)
})