Last active
May 26, 2018 19:44
-
-
Save miselaytes-anton/3093ee3dcf022e88af8f43943ad64846 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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