Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Mac用 Firefox 25.0.1 のスクラッチパッドで音を鳴らす (矩形波、周波数 330Hz)
var ctx = new AudioContext();
var osc = ctx.createOscillator();
osc.type = 'square';
osc.frequency.value = 330;
var vol = ctx.createGain();
vol.gain.value = 0.2; // 0.0 - 1.0
osc.connect(vol);
vol.connect(ctx.destination);
osc.start(0);
osc.stop(1.5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment