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 is a class to work with audio data. It provides a thin wrapper with a bunch of audio methods for any audio data source — AudioBuffer, Buffer, TypedArray, Array, NDarray or any Object with get/set methods. It stores data as an ndarray, so any ndarray packages can be used over audio buffers.
Usage
var AudioBuffer = require('audio-buffer');
//create audio buffer from any type of array
var buffer = new AudioBuffer([0,0,1,1], {channels: 2});API
//Create audio buffer from data source. Pass audio data format as a second argument.
//Format only affects the way to access raw data, it can be changed at any time.
var buffer = new AudioBuffer(data, format);
//Format of data
buffer.format;
//NDarray with the data
buffer.data;
//Raw data object - array, buffer, etc.
buffer.rawData;
//Duration of the underlying audio data, in seconds
buffer.duration;
//Number of samples per channel
buffer.length;
buffer.samplesPerFrame;
//Sample rate
buffer.sampleRate;
//Number of channels
buffer.channels;
buffer.numberOfChannels;
//Get sample value
buffer.get(channel, index);
//Set sample value
buffer.set(channel, index, value);
//Get array containing the data for the channel
buffer.getChannelData(channel);
//Fill buffer with the value or function
buffer.fill(function (channel, idx) { return 0; });
//Return array of arrays with the inner data
buffer.toArray();Related
pcm-util — utils for audio formats.
ndsamples — audio-wrapper for ndarrays.
ndarray — generic multidimensional arrays.
