decode-audio-data

audio data to pcm

Usage no npm install needed!

<script type="module">
  import decodeAudioData from 'https://cdn.skypack.dev/decode-audio-data';
</script>

README

decodeAudioData

License: MIT

Usage

const { decodeAudioData } = require("decode-audio-data");
decodeAudioData(
  fs.readFileSync("music.mp3")
);
// return: Promise<AudioBuffer>
const { decodeAudioDataStream } = require("decode-audio-data");
decodeAudioDataStream(
  fs.createReadStream("music.mp3")
);
// return: ReadableStream<Buffer>

decodeAudioData(input[, options])

Parameters

input <Buffer> | <Uint8Array> | <Readable>

A Buffer containing the audio data to be decoded

options (optional) <Object>

Options for decoding

options.numberOfChannels <number>

An integer representing the number of channels this buffer should have. The default value is 2

options.sampleRate <number>

The sample rate of the linear audio data in sample-frames per second. The default value is 48000

Return value

decodedData <Promise<AudioBuffer>>

A Promise object that fulfills with the decoded aduio data

decodeAudioDataStream(stream[, options])

Parameters

stream <Readable>

A Readable stream containing the audio data to be decoded

options (optional) <Object>

Options for decoding

options.numberOfChannels <number>

An integer representing the number of channels this buffer should have. The default value is 1

options.sampleRate <number>

The sample rate of the linear audio data in sample-frames per second. The default value is 48000

Return value

decodedData <Readable<Buffer>>

A Readable stream containing decoded audio data