ALAC Encoder
An encoder that produces raw ALAC data from PCM data.
Installation
npm install --save @alac/encoder
Usage
const pcmData = new Uint8Array()
const encoder = new ALACEncoder()
const outputBuffer = new Uint8Array(encoder.bytesPerPacket + ALACEncoder.maxEscapeHeaderBytes)
for (let pos = 0; pos < pcmData.byteLength; pos += encoder.bytesPerPacket) {
const chunk = pcmData.subarray(pos, pos + encoder.bytesPerPacket)
const bytesWritten = encoder.encodeChunk(chunk, outputBuffer)
const packet = outputBuffer.slice(0, bytesWritten)
}