JSPM

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

Audio data container

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

AudioBuffer optimal implementation for node. In browser provides just a useful constructor for web-audio’s AudioBuffer, in node is also useful instead of Buffer in audio streams.

Usage

npm install audio-buffer

var AudioBuffer = require('audio-buffer');

//Create audio buffer from a data source or of a length.
//Data is interpreted as a planar sequence of float32 samples.
//It can be Array, TypedArray, ArrayBuffer, Buffer, AudioBuffer, DataView, NDArray etc.
var buffer = new AudioBuffer(channels?, data|length, sampleRate?);

//Duration of the underlying audio data, in seconds
buffer.duration;

//Number of samples per channel
buffer.length;

//Default sample rate is 44100
buffer.sampleRate;

//Default number of channels is 2
buffer.numberOfChannels;

//Get array containing the data for the channel (not copied)
buffer.getChannelData(channel);

//Place data from channel to destination Float32Array
buffer.copyFromChannel(destination, channelNumber, startInChannel?);

//Place data from source Float32Array to the channel
buffer.copyToChannel(source, channelNumber, startInChannel?);


//Some special properties, it’s unlikely you will ever need them.

//Type of storage to use for data - replace to Float64Array, if needed.
//It will only affect node implementation.
AudioBuffer.FloatArray = Float32Array;

//In browser, you can set the audio context (online/offline).
//By default it is taken from audio-context module.
AudioBuffer.context;

//Whether WebAudioAPI Buffer should be created, if possible, instead of own instance
//In browser it is true, if WAA is available.
AudioBuffer.isWAA;

pcm-util — utils for audio format convertions.
ndsamples — audio-wrapper for ndarrays. A somewhat alternative approach to wrap audio data, based on ndarrays, used by some modules in livejs.