Created by Mike Hodnick [github.com/kindohm]
*hint: because it is freaking awesome
JavaScript -> Audio API -> Browser
JavaScript -> audiolib.js -> Audio API -> Browser
Sample #0 |
Sample #1 |
Sample #2 |
Sample #3 |
Sample #4 |
Sample #5 |
Sample #6 |
Sample #N |
Sample #0 L |
Sample #0 R |
Sample #1 L |
Sample #1 R |
Sample #2 L |
Sample #2 R |
Sample #N L |
Sample #N R |
* Not the same as the HTML5 <audio> object.
var osc, device, channels = 1;
var audioCallback = function(buffer, channelCount) {
osc.append(buffer, channelCount);
};
device = audioLib.AudioDevice(audioCallback, channels);
osc = audioLib.Oscillator(device.sampleRate, 400);
for (index = 0; index < buffer.length; index += 2){
osc1.generate();
osc2.generate();
leftSample = osc1.getMix();
rightSample = osc2.getMix();
buffer[index] = leftSample;
buffer[index + 1] = rightSample;
}
for (index = 0; index < buffer.length; index += channels) {
lfo.generate();
osc.fm = lfo.getMix();
osc.generate();
sample = osc.getMix();
// fill buffer...
}
for (i = 0; i < oscillators.length; i++) {
oscillators[i].generate();
sample += oscillators[i].getMix() * level;
}
Only so much headroom is available.
User-controlled mixing versus computed.
var sample = 0;
generator.generate();
sample = generator.getMix();
effect.pushSample(sample);
sample += effect.getMix();