@audio/wav-encode
v1.0.0
Published
Encode PCM audio samples to WAV format
Readme
@audio/wav-encode
Encode PCM audio samples to WAV format. Pure JS — no WASM, no native bindings, works in both node and browser.
import wav from '@audio/wav-encode';
const encoder = await wav({ sampleRate: 44100 });
encoder.encode(channelData); // buffer PCM
const buffer = encoder.flush(); // → complete WAV file as Uint8ArrayOptions
| Option | Default | Description |
|--------|---------|-------------|
| sampleRate | — | Sample rate (required) |
| bitDepth | 16 | 16 (PCM int) or 32 (IEEE float) |
Streaming
const encoder = await wav({ sampleRate: 44100, bitDepth: 16 });
encoder.encode(chunk1); // buffer chunk
encoder.encode(chunk2); // buffer chunk
const file = encoder.flush(); // → Uint8Array (complete WAV)
encoder.free();Input is Float32Array[] — one array per channel. Channels are interleaved automatically.
License
ॐ

