brstm
v1.7.0
Published
BRSTM Decoder
Downloads
14
Readme
brstm.js
BRSTM decoder.
Part of Nikku.
Usage example
import { Brstm } from 'brstm';
// BRSTM file should be read and passed as ArrayBuffer type
const brstm = new Brstm(arrayBuffer);
// Here you get an Object containing all the metadata extracted from BRSTM's file HEAD chunk
const metadata = brstm.metadata;
// You get per-channel PCM samples
const samples = brstm.getAllSamples();
// If you don't want the full samples, you can decode them partially
// getSamples(offset, size) will return the per-channel `offset`-th sample until `(offset + size - 1)`-th sample
const samplesPartial = brstm.getSamples(0, 100);
Members
rawData
:{Uint8Array}
, representation of array buffer passed in at class constructor.metadata
:{Object}
, the metadata extracted from BRSTM's file HEAD chunkfileSize
:{number}
endianness
:{number}
, 0 - little endian, 1 - big endiancodec
:{number}
- 0 - 8-bit PCM
- 1 - 16-bit PCM
- 2 - 4-bit ADPCM
loopFlag
:{number}
numberChannels
:{number}
, channel count of the whole filesampleRate
:{number}
loopStartSample
:{number}
, loop start, in terms of sample #totalSamples
:{number}
totalBlocks
:{number}
, total number of blocks, per channel, including final blockblockSize
:{number}
samplesPerBlock
:{number}
finalBlockSize
:{number}
, Final block size, without padding, in bytesfinalBlockSizeWithPadding
:{number}
, Final block size, with padding, in bytestotalSamplesInFinalBlock
:{number}
, Total samples in final blockadpcTableSamplesPerEntry
:{number}
, Samples per entry in ADPC tableadpcTableBytesPerEntry
:{number}
, Bytes per entry in ADPC tablenumberTracks
:{number}
, Number of trackstrackDescriptionType
:{number}
, Track description type (0 or 1)trackDescriptions
:{Array<TrackDescription>}
, Basic description of each trackTrackDescription
:{Object}
,numberChannels
:{number}
, this particular track's channel counttype
:{number}
, this particular track's description type (0 or 1)
Methods
getAllSamples()
:{Array<Int16Array>}
, per-channel PCM samplesgetSamples(offset, size)
:{Array<Int16Array>}
, per-channel samples fromoffset
-th sample until(offset + size - 1)
-th sample