ndsamples are ndarrays in a format for audio.
each ndsamples frame should have the follow properties:
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].
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, ...)
should be an Object with the following properties:
{
sampleRate: 44100
}
TODO: should there be a format identifier to store channel configuration of a frame?
some modules use ndsamples.
feel free to add what's missing. :)
with npm, do
npm i --save ndsamples
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
ISC