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

start-audio-worklet

v0.1.2

Published

A dead simple, single function API for creating and starting a web audio worklet.

Readme

What is this?

start-audio-worklet provides a dead simple, single function API for creating and starting an audio worklet node, which provides low latency audio processing in modern web browsers. It takes care of requesting microphone access, error handling and browser specific quirks so you don't have to.

A live demo can be found here.

Adding the library to your project

As an ES module

Add start-audio-worklet to your package.json and import the library like so:

import { startAudioWorklet } from "start-audio-worklet"

As a standalone javascript file

The standalone version lib/start_audio_worklet.js can be used directly in an HTML file by adding a script tag like this

<script src="/some/url/to/start_audio_worklet.js"></script>

Usage

The startAudioWorklet function is used to create and start an audio worklet:

const options = {
  workletProcessorUrl: "my_worklet_processor.js",
  workletNodeName: "my_worklet",
  workletNodeOptions: {
    numberOfInputs: 0,
    numberOfOutputs: 1,
    outputChannelCount: [2]
  }
}

startAudioWorklet(options)
  .then((workletNode) => {
    // The worklet was started.
    // workletNode is the AudioWorkletNode instance
  })
  .catch((error) => {
    // Something went wrong. Handle error.
  })

See StartAudioWorkletOptions for allowed attributes of options.

⚠️ Note: Some browsers, for example Firefox and Chrome, won't allow an audio context to start automatically without user interaction. This means that startAudioWorklet should be called in response to a button press, for example. In these browsers, calling it on page load requires an additional resume() call on the worklet node's audio context when the user interacts with the page.

Microphone access

By default, if numberOfInputs is set to a number greater than zero, microphone access is requested and an error is thrown if access is denied. The microphoneMode attribute can be used to change this behavior, see MicrophoneMode.

Using WebAssembly

Running WebAssembly code in audio worklets is a three step process:

  1. Import the WebAssembly module from your main javascript code
  2. Pass the result to the worklet processor
  3. Instantiate and use the WebAssembly code in the worklet processor

If wasmUrl is specified in the options passed to startAudioWorklet, steps 1 and 2 are handled automatically. See the WebAssembly demo source for how to perform step 3.

The tone_generator folder contains a simple tone generator written in Rust, which is used in the WebAssembly demo.

Tweaking performance

Unfortunately, audio worklet performance is not consistent across browsers, but it's sometimes possible to pass additional options to improve things. Some info about how to reduce latency can be found here. If you need unprocessed microphone input without echo cancellation etc, you might find this Stack Overflow thread helpful.

Running the live demo locally

To run the live demo on your local machine

To allow for microphone access, the demo page is served over https using a self signed certificate. Any browser warnings can be safely ignored. Note that your browser may not allow self signed certificates by default. If you're running Brave or Chrome, you can change this behavior with

  • brave://flags/#allow-insecure-localhost (for Brave)
  • chrome://flags/#allow-insecure-localhost (for Chrome)