ima-adpcm-decoder
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

ima-adpcm-decoder

AudioContext Decoder for ADPCM-Wavefiles

Installation

npm install ima-adpcm-decoder
yarn add ima-adpcm-decoder

Usage

import { decodeImaAdpcm } from 'ima-adpcm-decoder';
 
const playAdpcm = async () => {
    const ctx = new AudioContext();
 
    const response = await fetch('./test.wav');
    const buffer = await response.arrayBuffer();
    const audioBuffer = decodeImaAdpcm(ctx, buffer);
 
    const src = ctx.createBufferSource();
    src.buffer = audioBuffer;
    src.connect(ctx.destination);
    src.start(0);
};

For streaming, the package also exposes the decodeImaAdpcmBlock function, which decodes a single block of ADPCM samples.

Notes

As this uses the AudioContext directly, this currently only works in Browsers. A future implementation may use webasm to provide async decoding of ADPCM Buffers.

This code runs synchronously in the Browser, meaning it will block the event-loop until the decoding is finished. That may take some time depending on the size of your Wavefiles.

This package correctly handles multi-channel wavefiles.

Do not use if...

  • You need decoding of ADPCM files in nodejs
  • You need async decoding
  • You are not okay with the hefty dependency that is wavefile

Dependencies (1)

Thanks

The code for decoding ADPCM-blocks is ported from ADPCM-XQ

This code draws inspiration from imaadpcm

So thanks go to David Bryant and Rafael da Silva Rocha.

Package Sidebar

Install

npm i ima-adpcm-decoder

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

24.9 kB

Total Files

12

Last publish

Collaborators

  • screeny05