Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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