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

@webaudio-kit/core

v1.10.0

Published

Core browser audio primitives for webaudio-kit.

Downloads

342

Readme

@webaudio-kit/core

Core browser audio primitives for webaudio-kit.

This package has no React dependency. It exposes small helpers for safe Web Audio tone playback, frequency sweeps, short noise buffers, pitch helpers, and audio math.

Install

npm install @webaudio-kit/core
pnpm add @webaudio-kit/core
yarn add @webaudio-kit/core

Example

import { playTone } from "@webaudio-kit/core";

const context = new AudioContext();
const handle = playTone(context, {
  frequency: 440,
  gain: 0.2,
  type: "sine",
});

handle.stop();

Create or resume AudioContext from a user gesture in your app. This package does not create audio at module import time.

Repeat Patterns

Tone, sweep, and noise playback accept pattern: { repeat, gapMs } for notification-style cues. repeat is the total number of plays, and gapMs is the silence between plays.

const handle = playTone(context, {
  frequency: 880,
  durationMs: 120,
  gain: 0.12,
  type: "square",
  envelope: { attackMs: 8, releaseMs: 45 },
  pattern: { repeat: 3, gapMs: 90 },
});

handle.stop(); // stops the current and future scheduled voices

Envelopes

Use envelope to fade generated cues in and out. Attack, decay, and release values are milliseconds. sustain is a 0..1 multiplier of the requested gain.

playFrequencySweep(context, {
  from: 440,
  to: 880,
  durationMs: 500,
  gain: 0.12,
  envelope: { attackMs: 10, decayMs: 40, sustain: 0.7, releaseMs: 80 },
});

Filters And Voices

Use filter, detuneCents, and voices for richer procedural UI sounds without audio files. Voice gain is divided across the voice count so the requested gain stays the target loudness.

playTone(context, {
  frequency: 660,
  durationMs: 220,
  gain: 0.15,
  type: "sawtooth",
  envelope: { attackMs: 8, releaseMs: 55 },
  filter: { frequency: 1800, q: 0.7 },
  voices: { count: 2, spreadCents: 10 },
});

Browser Gesture Setup

import {
  frequencyToNoteName,
  playFrequencySweep,
  playTone,
} from "@webaudio-kit/core";

const button = document.querySelector<HTMLButtonElement>("#play")!;
const context = new AudioContext();

button.addEventListener("click", async () => {
  await context.resume();

  playTone(context, { frequency: 440, gain: 0.12, durationMs: 500 });
  playFrequencySweep(context, {
    from: 250,
    to: 8000,
    durationMs: 1600,
    gain: 0.08,
  });

  console.log(frequencyToNoteName(440));
});

API

  • playTone(context, options, destination?)
  • playFrequencySweep(context, options, destination?)
  • playNoise(context, options, destination?)
  • dbToGain(db)
  • gainToDb(gain)
  • clampFrequency(value, min?, max?)
  • midiToFrequency(midiNote, concertA?)
  • frequencyToMidi(frequency, concertA?)
  • frequencyToNoteName(frequency, options?)

Docs And Examples

  • API reference: https://webaudio-kit.afaqrashid.com/docs/api
  • Hooks vs Core: https://github.com/i-afaqrashid/webaudio-kit/blob/main/docs/hooks-vs-core.md
  • Scope and limitations: https://github.com/i-afaqrashid/webaudio-kit/blob/main/docs/scope-and-limitations.md
  • Recipes: https://webaudio-kit.afaqrashid.com/docs/recipes
  • Example apps: https://webaudio-kit.afaqrashid.com/docs/examples
  • Markdown docs: https://github.com/i-afaqrashid/webaudio-kit/tree/main/docs
  • LLM docs index: https://webaudio-kit.afaqrashid.com/llms.txt
  • Interactive demos: https://webaudio-kit.afaqrashid.com/demos

Release History

Every npm version maps to a GitHub tag and a CHANGELOG.md section.

  • Changelog: https://webaudio-kit.afaqrashid.com/changelog
  • GitHub Releases: https://github.com/i-afaqrashid/webaudio-kit/releases
  • npm versions: https://www.npmjs.com/package/@webaudio-kit/core?activeTab=versions

The published npm tarball includes CHANGELOG.md so version history is available with the package contents.

This library is for browser audio interfaces and prototypes. It is not a certified audiology or medical testing system.