@neoxr/audio-decode
v2.2.1
Published
Decode audio data in node or browser
Downloads
1,109
Maintainers
Readme
audio-decode
Decode audio data from supported format to AudioBuffer.
Supported formats:
- [x]
wav
- [x]
mp3
- [x]
ogg vorbis
- [x]
flac
- [x]
opus
- [ ]
alac
- [ ]
aac
- [ ]
m4a
- [x]
qoa
import decodeAudio from 'audio-decode';
import buffer from 'audio-lena/mp3';
let audioBuffer = await decode(buffer);
buffer
type can be: ArrayBuffer, Uint8Array or Buffer.
Decoder's code is lazy: first run loads decoder's sources and compiles module before decoding.
To get more granular control over individual decoders, use decoders
:
import decode, {decoders} from 'audio-decode';
await decoders.mp3(); // load & compile decoder
const audioBuffer = await decoders.mp3(mp3buf); // decode
See also
- wasm-audio-decoders – best in class compact & fast WASM audio decoders.
- Web Audio Decoders – native decoders API, hope one day will be fixed or alternatively polyfilled.
- decodeAudioData – default in-browser decoding method.
- ffmpeg.wasm – ultimate encoding/decoding library (8.5Mb of code).
License
MIT • 🕉