npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pcm-convert

v3.1.1

Published

Convert PCM audio data between formats

Readme

pcm-convert stable

Convert PCM audio data between formats. Zero dependencies, ESM.

npm install pcm-convert

import convert, { parse, detect, stringify, sampleRate } from 'pcm-convert'

// dtype conversion
convert(new Float32Array([1, -1, 0.5]), 'int16')

// interleaved → planar, dtype change
convert(new Uint8Array([127, 200, 127, 200]), 'uint8 stereo interleaved', 'float32 planar')

// endianness swap
convert(new Float32Array([1, .5, -.5, -1]), 'le', 'be')

// planar channel arrays → interleaved (replaces pcm-encode)
convert([new Float32Array([1, 0, -1]), new Float32Array([0, 0.5, -0.5])], 'int16 interleaved')

// AudioBuffer input (auto-detected)
convert(audioBuffer, 'int16 interleaved')

// any format → AudioBuffer (browser-native; Node.js auto-discovers audio-buffer package if installed)
convert(new Int16Array([...]), { dtype: 'int16', channels: 2, interleaved: true, sampleRate: 44100 }, 'audiobuffer')

// write into existing buffer
convert(new Uint8Array([0, 255]), new Uint16Array(2))

// object format
convert(data, { dtype: 'float32', channels: 2, interleaved: false }, { dtype: 'int16', interleaved: true })

// format utilities
parse('float32 stereo planar 44100')  // → { dtype: 'float32', channels: 2, interleaved: false, sampleRate: 44100 }
stringify({ dtype: 'float32', channels: 2, interleaved: false })  // → 'float32 stereo planar'
detect(new Int16Array(4))  // → { dtype: 'int16' }
detect([new Float32Array(4), new Float32Array(4)])  // → { dtype: 'float32', channels: 2, interleaved: false }

API

convert(src, from?, to?, dst?)

Converts src from format from to format to. If from is omitted, it is detected from src. If dst is provided, result is written into it.

Source types: Float32Array, Float64Array, Int8/16/32Array, Uint8/16/32Array, Array (float -1..1), Float32Array[] (planar channels), AudioBuffer (Web Audio API), ArrayBuffer, Buffer (Node.js).

Format

String ('float32 stereo planar 44100') or object ({ dtype, channels, interleaved, endianness, sampleRate, container }). Tokens in any order; commas, semicolons, underscores accepted as separators.

| Field | Tokens / values | |---|---| | dtype | float32, float64, float, int8, int16, int32, int, uint8, uint16, uint32, uint | | channels | mono, stereo, quad, 2.1, 5.1, N-channel — or any number in object format | | interleaved | interleaved, planar — or boolean in object format | | endianness | le, be | | sampleRate | 8000 11025 16000 22050 44100 48000 88200 96000 176400 192000 352800 384000 — or any number in object format | | container | array, arraybuffer, buffer (Node.js), audiobuffer |

In string format, bare numbers are matched against the sample rate whitelist. Use N-channel for arbitrary channel counts.

Object aliases: typedtype, numberOfChannelschannels, ratesampleRate.

parse(fmt) → descriptor • detect(data) → descriptor • stringify(descriptor, omit?) → string

sampleRate — standard sample rates array

Absorbs

License

MIT