UNPKG

gibberish-dsp

Version:

Gibberish is designed to be an optimized API for audio synthesis using per-sample techniques.

18 lines (12 loc) 613 B
let g = require( 'genish.js' ) let combFilter = function( _input, combLength, damping=.5*.4, feedbackCoeff=.84 ) { let lastSample = g.history(), readWriteIdx = g.counter( 1,0,combLength ), combBuffer = g.data( combLength ), out = g.peek( combBuffer, readWriteIdx, { interp:'none', mode:'samples' }), storeInput = g.memo( g.add( g.mul( out, g.sub( 1, damping)), g.mul( lastSample.out, damping ) ) ) lastSample.in( storeInput ) g.poke( combBuffer, g.add( _input, g.mul( storeInput, feedbackCoeff ) ), readWriteIdx ) return out } module.exports = combFilter