Skip to content

Instantly share code, notes, and snippets.

@miselaytes-anton
Last active May 26, 2018 19:44
Show Gist options
  • Save miselaytes-anton/3093ee3dcf022e88af8f43943ad64846 to your computer and use it in GitHub Desktop.
Save miselaytes-anton/3093ee3dcf022e88af8f43943ad64846 to your computer and use it in GitHub Desktop.
// static Low Pass Feedback Comb Filter
const audioCtx = new AudioContext()
const input = getOsc(audioCtx)
const combFilter = getCombFilter(audioCtx)
const output = audioCtx.destination
input
.connect(combFilter)
.connect(output)
function getCombFilter(audioCtx){
const node = audioCtx.createGain()
const lowPass = new BiquadFilterNode(audioCtx, {type: 'lowpass', frequency: 440})
const delay = new DelayNode(audioCtx, {delayTime: 0.7})
const gain = audioCtx.createGain()
gain.gain.setValueAtTime(0.5, audioCtx.currentTime)
node
.connect(delay)
.connect(lowPass)
.connect(gain)
.connect(node)
return node
}
function getOsc(audioCtx){
const osc = audioCtx.createOscillator()
osc.type = 'square'
osc.frequency.setValueAtTime(440, audioCtx.currentTime) // value in hertz
osc.start()
return osc
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment