observ-fs-audio-buffer
v1.0.0
Published
Observable AudioBuffer for use with fs.
Downloads
6
Maintainers
Readme
observ-fs-audio-buffer
Observable AudioBuffer for use with fs.
Example
var ObservAudioBuffer = require('observ-fs-audio-buffer')
var audioContext = new window.AudioContext()
var context = {
fs: require('fs'),
cwd: __dirname + '/audio-samples',
audio: audioContext
}
var buffer = ObservAudioBuffer(context)
buffer.resolved(function(data) {
if (data) {
// wait for buffer to load before triggering
trigger(audioContext.currentTime)
}
})
buffer.set({
src: './snare.ogg'
})
function trigger(at) {
var player = audioContext.createBufferSource()
player.buffer = buffer.resolved()
player.connect(audioContext.destination)
player.start(at)
}