Skip to content

Instantly share code, notes, and snippets.

@rumblesan
Created June 25, 2019 09:08
Show Gist options
  • Save rumblesan/8098306a0c71d2e7d9e78ff2fb094f90 to your computer and use it in GitHub Desktop.
Save rumblesan/8098306a0c71d2e7d9e78ff2fb094f90 to your computer and use it in GitHub Desktop.
var ctx = new AudioContext();
var osc1 = audioCtx.createOscillator();
osc1.type = 'square';
osc1.frequency.setValueAtTime(440, ctx.currentTime);
osc1.start();
var osc2 = audioCtx.createOscillator();
osc2.type = 'square';
osc2.frequency.setValueAtTime(441, ctx.currentTime);
osc2.start();
var gainNode = audioCtx.createGain();
gainNode.gain.setValueAtTime(0.3, ctx.currentTime);
gainNode.connect(ctx.destination);
osc1.connect(gainNode);
osc2.connect(gainNode);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment