jussi-kalliokoski/audiolib.js — Issue #39: Problem automating two oscillators, one for each channel
Author: kindohm
Created: 2011-12-28 16:15:41+00:00
State: open

I'm having trouble getting an LFO to work on two oscillators. I'm automating the frequency of the oscillators. I'm writing the samples of one oscillator to the left channel and the samples of the other oscillator to the right channel.

The code below results in two oscillators generating normally with no apparent LFO automation. Any ideas?

```js
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();
}
}
```