Skip to content

Instantly share code, notes, and snippets.

@kylebragger
Created October 16, 2012 20:47
Show Gist options
  • Save kylebragger/3901888 to your computer and use it in GitHub Desktop.
Save kylebragger/3901888 to your computer and use it in GitHub Desktop.
var playSingleChime = function()
{
var context = new webkitAudioContext(),
gain = context.createGainNode(),
osc = context.createOscillator();
osc.connect(gain);
gain.connect(context.destination);
osc.frequency.value = 1000.0;
osc.type = osc.SQUARE;
gain.gain.setValueAtTime(gain.gain.value, context.currentTime);
gain.gain.linearRampToValueAtTime(0.0, 0.5);
osc.noteOn(0);
osc.noteOff(0.5);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment