Created
March 11, 2013 21:30
-
-
Save usefulthink/5137953 to your computer and use it in GitHub Desktop.
simplistic demo for using the audioContext of the webaudio-api
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 audioContext = new webkitAudioContext(), | |
osc1 = audioContext.createOscillator(), | |
osc2 = audioContext.createOscillator(); | |
osc1.frequency.value = 440; // Hz | |
osc2.frequency.value = 220; // one octave down | |
osc1.connect(audioContext.destination); | |
osc2.connect(audioContext.destination); | |
osc1.noteOn(0); // zeit in sek. nach start der internen clock des AudioContext (currentTime) | |
osc1.noteOff(1); | |
osc2.noteOn(.5); | |
osc2.noteOff(2); | |
// noch ein Beispiel für programmierte Verläufe von AudioParams | |
osc2.frequency.setValueAtTime(220, 1); | |
osc2.frequency.exponentialRampToValueAtTime(440, 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment