-
-
Save kalibora/cd9314833f9574b78353 to your computer and use it in GitHub Desktop.
audio-test-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 osc = ctx.createOscillator(); | |
var freqs = [261.63, 293.67, 329.63, 349.23, 392.00, 440.00, 493.88, 523.23]; | |
var freqIdx = 0; | |
var timerId = setInterval(function () { | |
if (freqIdx >= freqs.length) { | |
clearInterval(timerId); | |
return; | |
} | |
console.log(freqs[freqIdx]); | |
osc.frequency.value = freqs[freqIdx]; // set frequency | |
if (freqIdx === 0) { | |
osc.start(0); | |
osc.stop(ctx.currentTime + freqs.length * 1); | |
} | |
freqIdx++; | |
}, 1000); | |
osc.connect(ctx.destination); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment