1.0.0 • Published 11 years ago
ndsamples v1.0.0
ndsamples
ndsamples are ndarrays in a format for audio.
spec
each ndsamples frame should have the follow properties:
shape
should be an Array of the form:
[length, numberOfChannels]for example, a frame of 1024 samples per channel and 2 channels (stereo) has the shape [1024, 2].
data
should be a Float32Array of samples between -1.0 and +1.0.
if we .pick(time), we should see channel data in a form such as:
[center] // 1.0 mono
[front left, front right] // 2.0 stereo
[front left, front right, front center] // 3.0 stereo
[front left, front right, back center] // 3.0 surround
[front left, front right, back left, back right] // 4.0 quad
[front left, front right, front center, back center] // 4.0 surround
...TODO: support other common data types? (uint8, int16, float64, ...)
format
should be an Object with the following properties:
{
sampleRate: 44100
}TODO: should there be a format identifier to store channel configuration of a frame?
modules
some modules use ndsamples.
- TODO
feel free to add what's missing. :)
ndsamples factory
install
with npm, do
npm i --save ndsamplesusage
var ndsamples = require('ndsamples')
var samples = ndsamples({
data: [0, 0.5, -0.5, 0, 1, -1, -1, 1],
shape: [4, 2],
format: {
sampleRate: 44100
}
})the ndsamples factory returns an ndarray with:
- your data cast into a
Float32Array, if necessary - a getter for
length(shape[0]) - a getter for
numberOfChannels(shape[1]) - a getter for
formatas given
license
ISC
1.0.0
11 years ago