signalData = data( './resources/audiofiles/dead-presidents.wav' ).then( ()=> {
  // parameters for external manipulation (via gui)
  let wet 		= param( 'wet',		  .55 ), 
      dry 		= param( 'dry',		  .5  ), 
      roomSize  = param( 'roomSize',  75  ), 
      bandwidth = param( 'bandwidth', .5  ),
      early 	= param( 'early', 	  .25 ), 
      revtime 	= param( 'revtime',   11  ),
      damping 	= param( 'damping',   .7  ), 
      tail 		= param( 'tail', 	  .25 )
  
  in1 = peek( signalData, accum( 1,0, { max:signalData.buffer.length } ), { interp:'none', mode:'samples' } )
 
  attenuatedSignal = memo( mul( in1, .707 ) )
  
  // in1 * samplerate / 340
  roomSizeCoeff = memo( div( mul( roomSize, gen.samplerate ), 340 ) )
  
  // input damper
  damperHistory = ssd()
  damper = mix( attenuatedSignal, damperHistory.out, sub( 1, bandwidth ) )
  damperHistory.in( damper )
  
  prediffuseHistory = ssd()
  prediffuseTime  = mul( roomSizeCoeff, .110732 )
  prediffuseDelay = delay( prediffuseHistory.out, prediffuseTime, { size: 6000 })
  
  dampMinusDiffuse = sub( damper, mul( prediffuseDelay, .75 ) )
  prediffuseHistory.in( dampMinusDiffuse )
  
  prediffusePlusDamping = add( prediffuseDelay, mul( dampMinusDiffuse, .75 ) )
  
  tap1Time = memo( add( mul( roomSizeCoeff, .41 ), 5 ) )
  tap2Time = memo( add( mul( roomSizeCoeff, .3 ), 5 ) )
  tap3Time = memo( add( mul( roomSizeCoeff, .155 ), 5 ) )
  tap4Time = add( roomSizeCoeff, 5 )
  multitap = delay( 
    prediffusePlusDamping, 
   	tap1Time, tap2Time, tap3Time, tap4Time,
    { size: 48000, interp:'linear' }
  )
  
//play( add( ...multitap.outputs ) ) })

  // pow( pow( 10,-60/20 ), 1. / ( in1*samplerate ) )
  revtimeCoeff = memo( pow( pow( 10,-60/20 ), div(1., mul( revtime, gen.samplerate) ) ) )
  
  
  taps = [
    memo( mul( early, mul( multitap.outputs[0], pow( revtimeCoeff, tap1Time ) ) ) ),
    memo( mul( early, mul( multitap.outputs[1], pow( revtimeCoeff, tap2Time ) ) ) ),
    memo( mul( early, mul( multitap.outputs[2], pow( revtimeCoeff, tap3Time ) ) ) ),
    memo( mul( early, mul( multitap.outputs[3], pow( revtimeCoeff, tap4Time ) ) ) )
  ]
  
  tapsL = add( taps[0], taps[2] )
  tapsR = add( taps[1], taps[3] )
  tapOutput = sub( tapsL, tapsR )
play( tapOutput )  })
  // ************* Feedback Delay Network *************
  fdnCoeffs = [ 1, .81649, .7071, .63245 ]
  delayLines = []
  
  for( let i = 0; i < 4; i++ ) {
    let dlHistory, delayTimeCoeff, dl, feedbackInput, feedbackHistory, feedbackMix,
        terminal, output
    
    dlHistory = ssd()
    delayTimeCoeff = memo( mul( roomSizeCoeff, fdnCoeffs[i] ) )
    dl = delay( dlHistory.out, delayTimeCoeff, { size:48000 } )
    
    feedbackInput = mul( dl, mul( -1, pow( revtimeCoeff, delayTimeCoeff) ) )
    feedbackHistory = ssd(),
    feedbackMix = mix( feedbackInput, feedbackHistory.out, damping )
    feedbackHistory.in( feedbackMix )
    
	terminal = i < 2 ? sub() : add()
    
    output = i !== 2 ? mul( terminal, .5 ) : mul( sub( 0, terminal ), .5 )
      
  	dlHistory.in( add( output, taps[i] ) )
    
	delayLines.push({ terminal, output, feedbackMix })
  }
  
  // *************** hook the network up *****************
  delayLines[0].positive = add( delayLines[0].feedbackMix, delayLines[1].feedbackMix )
  delayLines[0].negative = sub( delayLines[0].feedbackMix, delayLines[1].feedbackMix )  
  // must wait for delay line 2 to connect terminal
  
  delayLines[1].terminal.inputs[0] = delayLines[0].negative
  // STILL MUST DO OTHER INPUT TO DL[2].NEGATIVE
  
  delayLines[2].positive = add( delayLines[2].feedbackMix, delayLines[3].feedbackMix )
  delayLines[2].negative = sub( delayLines[2].feedbackMix, delayLines[3].feedbackMix )  
  delayLines[2].terminal.inputs = [ delayLines[0].negative, delayLines[2].negative ]

  delayLines[0].terminal.inputs = [ delayLines[0].positive, delayLines[2].positive ]

  // now that delayLine[2] has been made, connect delayLine[1] to it
  delayLines[1].terminal.inputs[1] = delayLines[2].negative
  
  delayLines[3].terminal.inputs = [ delayLines[2].positive, delayLines[0].positive ]

  fdnL = add( mul( delayLines[0].output, tail ), mul( delayLines[2].output, tail ) )
  fdnR = add( mul( delayLines[1].output, tail ), mul( delayLines[3].output, tail ) )  
  fdnOut = sub( fdnL, fdnR )
  
  fdnPlusDiffuse = add( fdnOut, tapOutput )
  
  cb = play( fdnPlusDiffuse, true )
})  