https://github.com/audiojs/audio-decode
Minimal audio decoders layer
https://github.com/audiojs/audio-decode
audio codec decoder wav webassembly
Last synced: 3 months ago
JSON representation
Minimal audio decoders layer
- Host: GitHub
- URL: https://github.com/audiojs/audio-decode
- Owner: audiojs
- License: mit
- Created: 2016-08-27T22:06:19.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2025-05-21T12:30:06.000Z (8 months ago)
- Last Synced: 2025-09-30T01:51:27.522Z (3 months ago)
- Topics: audio, codec, decoder, wav, webassembly
- Language: JavaScript
- Homepage:
- Size: 202 KB
- Stars: 184
- Watchers: 4
- Forks: 16
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# audio-decode [](https://github.com/audiojs/audio-decode/actions/workflows/test.js.yml) [](http://github.com/badges/stability-badges)
Decode audio data from supported format to [AudioBuffer](https://github.com/audiojs/audio-buffer).
Supported formats:
* [x] `wav`
* [x] `mp3`
* [x] `ogg vorbis`
* [x] `flac`
* [x] `opus`
* [ ] `alac`
* [ ] `aac`
* [ ] `m4a`
* [x] [`qoa`](https://github.com/phoboslab/qoa)
[](https://npmjs.org/package/audio-decode/)
```js
import decodeAudio from 'audio-decode';
import buffer from 'audio-lena/mp3';
let audioBuffer = await decode(buffer);
```
`buffer` type can be: _ArrayBuffer_, _Uint8Array_ or _Buffer_.
`decode` is lazy: first call prepares decoder.
To get more granular control over individual decoders, use `decoders`:
```js
import decode, {decoders} from 'audio-decode';
await decoders.mp3(); // load & compile decoder
const audioBuffer = await decoders.mp3(mp3buf); // decode
```
## See also
* [wasm-audio-decoders](https://github.com/eshaz/wasm-audio-decoders) – best in class compact & fast WASM audio decoders.
* [Web Audio Decoders](https://developer.mozilla.org/en-US/docs/Web/API/AudioDecoder) – native decoders API, hope one day will be fixed or alternatively polyfilled.
* [decodeAudioData](https://github.com/eshaz/wasm-audio-decoders) – default in-browser decoding method.
* [ffmpeg.wasm](https://github.com/ffmpegwasm/ffmpeg.wasm) – ultimate encoding/decoding library (8.5Mb of code).
## License
[MIT](LICENSE) • 🕉