JSPM

  • Created
  • Published
  • Downloads 113524
  • Score
    100M100P100Q153073F
  • License MIT

AudioBuffer class for node/browser

Package Exports

  • audio-buffer

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (audio-buffer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

audio-buffer Build Status stable Greenkeeper badge

Basic audio data container. Provides lightweight Web Audio API AudioBuffer implementation. Useful instead of Buffer in audio streams, @audiojs components and other audio applications. Can be used as a ponyfill.

Usage

npm install audio-buffer

new AudioBuffer(context?, options)

Create audio buffer for audio context based on options.

Default context is audio-context singleton. null context can be used to indicate context-free buffer instance, eg. in nodejs.

Available options:

  • length — number of samples, minimum is 1.
  • sampleRate — default sample rate is 44100.
  • numberOfChannels — default number of channels is 1.

buffer.duration

Duration of the underlying audio data, in seconds.

buffer.length

Number of samples per channel.

buffer.sampleRate

Default sample rate is 44100.

buffer.numberOfChannels

Default number of channels is 1.

buffer.getChannelData(channel)

Get array containing the data for the channel (not copied).

buffer.copyFromChannel(destination, channelNumber, startInChannel=0)

Place data from channel to destination Float32Array.

buffer.copyToChannel(source, channelNumber, startInChannel=0)

Place data from source Float32Array to the channel.

See also

Similar

  • ndsamples — audio-wrapper for ndarrays. A somewhat alternative approach to wrap audio data, based on ndarrays, used by some modules in livejs.
  • 1, 2, 3, 4 — other AudioBuffer implementations.
  • audiodata alternative data holder from @mohayonao.