Skip to content

Instantly share code, notes, and snippets.

@squarefeet
Created February 10, 2013 01:48
Show Gist options
  • Save squarefeet/4747962 to your computer and use it in GitHub Desktop.
Save squarefeet/4747962 to your computer and use it in GitHub Desktop.
WebAudio LFOs - Why you no worky!?
<body>
<script type="text/javascript">
var context = new webkitAudioContext();
destination = context.destination,
osc = context.createOscillator(),
lfo = context.createOscillator(),
lfoGain = context.createGainNode(),
filter = context.createBiquadFilter();
osc.type = osc.TRIANGLE;
filter.type = filter.HIGHPASS;
osc.connect(filter);
filter.connect(destination);
lfo.connect(lfoGain);
lfoGain.connect(filter.frequency);
lfoGain.gain.value = 0.5;
lfo.noteOn(2);
osc.noteOn(1);
</script>
</body>
@squarefeet
Copy link
Author

Fix:
lfoGain.gain.value = 2000;

Always remember to set gain values to match the parameter you're modulating. Derp.

@cwilso
Copy link

cwilso commented Feb 10, 2013

:) there you go. Also, "noteOn(2); noteOn(1);" is a bit suspect? Should either be zero or audioContext.currentTime+something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment