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

@silyze/async-audio-mixer

v1.0.0

Published

Simple audio mixer that uses @silyze/async-audio-stream

Readme

Async Audio Mixer

@silyze/async-audio-mixer is a lightweight, battery‑included audio mixer built on top of
@silyze/async-audio-stream.
It lets you combine any number of PCM/encoded streams, produce a single mixed
output, and even bridge two full‑duplex AudioStreams with automatic
transcoding when their formats differ.


Install

npm install @silyze/async-audio-mixer

Quick start

import AudioMixer from "@silyze/async-audio-mixer";
import { OpusFormat } from "@silyze/async-audio-format-webm";

// Imagine three incoming Opus/WebM streams (8 kHz mono):
const format = new OpusFormat(8000);
const speakers = [streamA, streamB, streamC].map((s) => format.decode(s));

// Mix to PCM and then re‑encode to Opus:
const mixedOpus = AudioMixer.mix(speakers, { format });

// Pipe to a WebSocket or file:
await mixedOpus.pipe(wsWritable);

API

AudioMixer.mix(streams, config?) ⇒ AsyncReadStream<Buffer>

| Parameter | Type & Default | Description | | --------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | | streams | Iterable<AudioOutputStream> | Any audio output streams to be mixed. All must share the same PCM sample‑rate. | | config.signal | AbortSignal (optional) | Cancel mixing early. | | config.buffer | number (ms) default 100 | Length of each mixing frame in milliseconds. | | config.live | boolean default false | If true, the mixer starts emitting only new audio frames (live broadcast). If false, the full buffer history is replayed once a consumer attaches. | | config.format | AudioFormat (optional) | If supplied, the PCM mix is encoded with format.encode() before being returned. |

The returned stream is PCM‑16‑LE unless you supply config.format.

AudioMixer.connect(a, b, pipeConfig?) ⇒ Promise<void>

Bidirectionally connects two AudioStreams (a ⇆ b).
If the streams already share the same format & sample‑rate, raw data is piped.
Otherwise each direction is transcoded on‑the‑fly using the respective
encode/decode methods.

pipeConfig is forwarded to AsyncTransform.pipe() for back‑pressure and error
handling options.


Example – Simple Voice Chat Room

// listenerStreams: Set<AudioOutputStream> coming from WebRTC peers
const mix = AudioMixer.mix(listenerStreams, {
  buffer: 20, // 20 ms frames → low latency
  live: true,
});

// Broadcast the mixed PCM to a speech‑to‑text service …
await mix.pipe(sttInputWritable);

Internals

  • Frame‑based mixing – samples are summed per frame, with hard clipping at
    ±32768 to avoid overflow.
  • Mono‑only – each input is treated as mono; stereo mixing is out of scope
    (PRs welcome!).
  • Sample‑rate safety – a runtime assertion prevents accidental mixing of
    streams that use different PCM sample‑rates.