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

g722-spandsp

v1.0.1

Published

Node-API bindings for SpanDSP G.722 (encode/decode) with ESM+CJS loaders.

Downloads

41

Readme

g722-spandsp

Node-API bindings for SpanDSP G.722 (encode/decode).
Minimal, fast, production-friendly. Works with ESM and CommonJS.

⚠️ This package links dynamically against system libspandsp (LGPL-2.1).
Your app remains MIT/closed as long as you dynamically link and ship the LGPL notice.

Install

macOS (Apple Silicon / Intel)

brew install spandsp pkg-config
npm i g722-spandsp
# or from source in this repo:
npm install
npm run build

Debian/Ubuntu

sudo apt-get update
sudo apt-get install -y build-essential python3 pkg-config libspandsp-dev
npm i g722-spandsp

Windows is not supported.

Usage

ESM

import { G722Encoder, G722Decoder } from 'g722-spandsp';

// 20 ms of 1 kHz @ 16 kHz PCM16LE
const sr = 16000, ms = 20, n = sr*ms/1000;
const pcm = Buffer.alloc(n*2);
let ph=0, w=2*Math.PI*1000/sr;
for (let i=0;i<n;i++){ pcm.writeInt16LE(Math.round(Math.sin(ph)*12000), i*2); ph+=w; }

const enc = new G722Encoder();
const g = enc.encode(pcm);      // ~160 bytes (64 kbps)

const dec = new G722Decoder();
const back = dec.decode(g);     // ~320 samples PCM16

CommonJS

const { G722Encoder, G722Decoder } = require('g722-spandsp');

API

  • new G722Encoder()
    • encode(pcm16le: Buffer|Uint8Array): Buffer — encodes to G.722 octet-aligned (64 kbps).
    • reset(): void
  • new G722Decoder()
    • decode(g722: Buffer|Uint8Array): Buffer — decodes to PCM16LE @ 16 kHz.
    • reset(): void

Notes

  • G.722 audio sample rate is 16 kHz.
    RTP timestamps tick at 8 kHz (RFC quirk).
  • The addon uses G722_PACKED (octet-aligned) payloads.

Build from source (in this repo)

npm install
npm run build
node test/test.js

License

  • Code here: MIT (see LICENSE)
  • Runtime dependency: SpanDSP (LGPL-2.1) — dynamically linked.