Miss any of our Open RFC calls?Watch the recordings here! »

observ-fs-audio-buffer

1.0.0 • Public • Published

observ-fs-audio-buffer

Observable AudioBuffer for use with fs.

NPM

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)
}

Install

npm i observ-fs-audio-buffer

DownloadsWeekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • avatar