Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including pcm-util with all npm packages installed. Try it out:

var pcmUtil = require("pcm-util")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

pcm-util v3.0.0

Convert audiobuffer to arraybuffer and back with defined pcm format

pcm-util unstable Build Status Greenkeeper badge

Utils to tamper with PCM formats/buffers. In particular, converting Buffer to AudioBuffer, ArrayBuffer to AudioBuffer, AudioBuffer to ArrayBuffer or AudioBuffer to Buffer.

npm install pcm-util

var pcm = require('pcm-util')


Default PCM format to use for any operations

pcm.defaults === {
    channels: 2,
    sampleRate: 44100,
    interleaved: true,
    float: false,
    signed: true,
    bitDepth: 16,
    byteOrder: 'LE',
    max: 32767,
    min: -32768,
    samplesPerFrame: 1024,
    id: 'S_16_LE_2_44100_I'


Normalize passed format: ensure all the properties are present and do not contradict.


Retrieve format-related properties from audio buffer, return not normalized format.

pcm.equal(a, b)

Compare whether two formats are equal to each other.

pcm.toAudioBuffer(buffer, format)

Convert buffer/arrayBuffer with the format to audio buffer.

pcm.toArrayBuffer(audioBuffer, format)

Convert audio buffer to array buffer with the format.

pcm.convert(buffer, fromFormat, toFormat)

Convert array buffer from one format to another.


audio-buffer — audio buffer polyfill.
audio-buffer-utils — utils for audio buffers.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free