Created
December 22, 2011 17:58
-
-
Save kindohm/1511204 to your computer and use it in GitHub Desktop.
audiolib.js - two oscillators, two lfo's, one for each channel
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
function buildAudio() { | |
audioDevice = audioLib.AudioDevice(audioCallback, channelCount); | |
oscillator1 = audioLib.Oscillator(audioDevice.sampleRate, 440); | |
oscillator2 = audioLib.Oscillator(audioDevice.sampleRate, 441); | |
lfo1 = audioLib.Oscillator(audioDevice.sampleRate, 1); | |
lfo2 = audioLib.Oscillator(audioDevice.sampleRate, 2); | |
oscillator1.addAutomation('frequency', lfo1, .25, 'additiveModulation'); | |
oscillator2.addAutomation('frequency', lfo2, .55, 'additiveModulation'); | |
} | |
function audioCallback(buffer, channelCount) { | |
var l = buffer.length, current; | |
for (current = 0; current < l; current += channelCount) { | |
lfo1.generate(); | |
lfo2.generate(); | |
oscillator1.generate(); | |
oscillator2.generate(); | |
buffer[current] = oscillator1.getMix(); | |
buffer[current + 1] = oscillator2.getMix(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment