Skip to content

Instantly share code, notes, and snippets.

@yo-to
Last active December 30, 2015 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yo-to/7842110 to your computer and use it in GitHub Desktop.
Save yo-to/7842110 to your computer and use it in GitHub Desktop.
Mac用 Firefox 25.0.1 のスクラッチパッドで音を鳴らす (矩形波、3つの音を連続で)
var ctx = new AudioContext();
var vol = ctx.createGain();
vol.gain.value = 0.2; // 0.0 - 1.0
vol.connect(ctx.destination);
osc = new Array(3);
osc_freq = new Array(262, 277, 330);
for(i=0; i<3; i++) {
osc[i] = ctx.createOscillator();
osc[i].type = 'square';
osc[i].frequency.value = osc_freq[i];
osc[i].connect(vol);
}
osc[0].start(0);
osc[0].stop(1.0);
osc[1].start(1.0);
osc[1].stop(2.0);
osc[2].start(2.0);
osc[2].stop(3.0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment