amenData = data( './resources/audiofiles/amen.wav' ).then( ()=> {

  combLength = 1200, feedback = .84, damping = .2

  amenSignal = peek( amenData, accum( 1,0,{max:amenData.buffer.length} ), { interp:'none', mode:'samples' } )

  readWriteIdx = counter( 1,0,combLength )

  combBuffer = data( combLength )

  lastSample = ssd()

  out = peek( combBuffer, readWriteIdx, { interp:'none', mode:'samples' })

  storeInput = add( mul( out, sub( 1, damping)), mul( lastSample.out, damping ) )
  lastSample.in( storeInput )
 
  poke( combBuffer, add( amenSignal, mul( storeInput, feedback ) ), readWriteIdx )

  cb = play( out )
                      
})

amen = data( './resources/audiofiles/amen.wav' ).then( ()=> {

/*
callback: function(input, feedback, damping) {
var currentPos = ++index % bufferLength;
var out = buffer[currentPos];

store = (out * (1 - damping)) + (store * damping);

buffer[currentPos] = input + (store * feedback);

return out;
}
*/

let feedback = .94, damping = .05
let store = ssd(), out1 = ssd()
let storeInput = add( mul( out1.out, sub( 1, damping)), mul( store.out, damping ) )
store.in( storeInput )
let x = peek( amen, accum( 1,0,{max:amen.buffer.length} ), { interp:'none', mode:'samples' } )
let delayIn = add( x, mul( storeInput, feedback ) )
let out = delay( delayIn, 0, { interp:'none', size:1200 })
out1.in( out )
/*
let c = counter(1,0,1200)
let d = data( 1200 )
let out = peek( d, c, { interp:'none', mode:'samples' })
let p = poke( d, , c )
*/

cb = play( out )
                      
})