Last active
December 30, 2015 14:29
-
-
Save yo-to/7842110 to your computer and use it in GitHub Desktop.
Mac用 Firefox 25.0.1 のスクラッチパッドで音を鳴らす
(矩形波、3つの音を連続で)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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