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

@bjesuiter/audio-limiter

v2.0.0

Published

Modern AudioWorklet limiter with explicit factory API

Readme

audio-limiter

Modern AudioWorklet limiter for the Web Audio API.

This package exposes an explicit async factory. It does not patch AudioContext.prototype.

Installation

npm install audio-limiter

Usage

import { createLimiter } from "audio-limiter";

const context = new AudioContext();
const limiter = await createLimiter(context, {
  threshold: -6,
  lookahead: 0.005,
  attack: 0.003,
  release: 0.05,
});

const source = context.createBufferSource();
source.buffer = audioBuffer;
source.connect(limiter).connect(context.destination);
source.start();

createLimiter() works with both AudioContext and OfflineAudioContext:

const context = new OfflineAudioContext({
  numberOfChannels: 2,
  length: 44_100,
  sampleRate: 44_100,
});

const limiter = await createLimiter(context, { threshold: -2 });

API

createLimiter(context, options?)

Creates and returns a ready LimiterAudioWorkletNode.

const limiter = await createLimiter(context, options);

By default, the AudioWorklet processor is loaded from an embedded Blob URL. If your app needs to manage the worklet asset itself, pass workletUrl:

const limiter = await createLimiter(context, {
  workletUrl: "/assets/limiter-worklet.js",
});

Advanced preload API

For most apps, use createLimiter(). If you want to preload the worklet during app setup and construct nodes synchronously later, use the advanced helpers:

import { createLimiterNode, loadLimiterWorklet } from "audio-limiter";

await loadLimiterWorklet(context);

const limiter = createLimiterNode(context, {
  threshold: -6,
  lookahead: 0.005,
});

createLimiterNode() assumes the processor was already registered with loadLimiterWorklet(). If it is called first, the browser will throw because the worklet processor name is not known yet.

loadLimiterWorklet() accepts only loader options:

await loadLimiterWorklet(context, {
  workletUrl: "/assets/limiter-worklet.js",
});

Worklet registration is cached per audio context. If workletUrl is provided for the first load, that URL is used; later loads for the same context reuse the existing registration.

Options

| Option | Type | Default | Description | | -------------- | --------------- | ------------: | -------------------------------------------------------------------------- | | threshold | number | -2 | Limiting threshold in dB. | | attack | number | 0 | Envelope attack time in seconds. | | release | number | 0.1 | Envelope release time in seconds. | | preGain | number | 0 | Input gain in dB before limiting. | | postGain | number | 0 | Output gain in dB after limiting. | | bypass | boolean | false | Pass input through without limiting. | | lookahead | number | 0.005 | Delay in seconds used for limiter lookahead. Must be between 0 and 10. | | workletUrl | string \| URL | embedded Blob | Optional caller-managed worklet module URL. | | channelCount | number | 2 | Number of channels. |

The limiter uses one input and one output, with channelCountMode: 'explicit'.

Parameters

The returned node is an AudioWorkletNode, so all limiter controls are native AudioParams:

limiter.parameters.get("threshold")?.setValueAtTime(-8, context.currentTime);

For convenience, the same params are also available as typed getters:

limiter.threshold.setValueAtTime(-8, context.currentTime);
limiter.attack.setValueAtTime(0.005, context.currentTime);
limiter.release.setValueAtTime(0.1, context.currentTime);
limiter.preGain.setValueAtTime(3, context.currentTime);
limiter.postGain.setValueAtTime(0, context.currentTime);
limiter.bypass.setValueAtTime(1, context.currentTime);

Development

bun install
bun run format:check
bun run lint
bun run type-check
bun run test:browser
bun run build

The browser tests use Vitest Browser with Playwright and render through OfflineAudioContext, so they exercise the real AudioWorklet path.

Acknowledgements

Thanks to Robert Kamiński and the original robert8888/audio-limiter package. This version was rebuilt with a modern TypeScript/tsdown setup and an explicit factory API, using the original package as inspiration for the limiter design and parameter model.

License

MIT