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

stringpitcher-wasm

v0.1.3

Published

WebAssembly bindings for the StringPitcher pitch detection library

Readme

StringPitcher

Ultra low-latency pitch detection library for guitar and bass instruments. Works in browsers and Node.js via WebAssembly.

Features

  • Real-time pitch detection using McLeod Pitch Method (MPM)
  • Support for 6-string guitar, 4-string bass, and 5-string bass
  • 12 built-in tuning presets (Standard, Drop D, Open G, etc.)
  • Chromatic mode for detecting any note
  • Configurable A4 reference pitch (432-448 Hz)
  • < 20ms latency

Installation

npm install stringpitcher-wasm
# or
pnpm add stringpitcher-wasm
# or
yarn add stringpitcher-wasm

Quick Start

import { StringPitcher, Instrument, TuningPreset } from 'stringpitcher-wasm';

// Create tuner with your audio sample rate
const tuner = new StringPitcher(48000);

// Configure instrument and tuning
tuner.setInstrument(Instrument.Guitar6String);
tuner.setTuningPreset(TuningPreset.Standard);

// Process audio samples (from Web Audio API, etc.)
function processAudio(audioBuffer) {
  const samples = audioBuffer.getChannelData(0); // Float32Array
  const result = tuner.processAudio(samples);

  if (result) {
    console.log(`Note: ${result.noteName}${result.octave}`);
    console.log(`Frequency: ${result.frequency.toFixed(1)} Hz`);
    console.log(`Cents off: ${result.centDeviation.toFixed(1)}`);
    console.log(`In tune: ${result.isInTune}`);
    console.log(`Direction: ${result.tuningDirection}`); // -1: flat, 0: in tune, 1: sharp
  }
}

Web Audio API Example

import { StringPitcher } from 'stringpitcher-wasm';

async function startTuner() {
  const audioContext = new AudioContext();
  const tuner = new StringPitcher(audioContext.sampleRate);

  // Get microphone access
  const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
  const source = audioContext.createMediaStreamSource(stream);

  // Create analyzer for getting audio data
  const analyzer = audioContext.createAnalyser();
  analyzer.fftSize = 4096;
  source.connect(analyzer);

  const buffer = new Float32Array(analyzer.fftSize);

  function detect() {
    analyzer.getFloatTimeDomainData(buffer);
    const result = tuner.processAudio(buffer);

    if (result && result.confidence > 0.5) {
      updateUI(result);
    }

    requestAnimationFrame(detect);
  }

  detect();
}

API Reference

StringPitcher

Constructor

new StringPitcher(sampleRate: number)

Methods

| Method | Description | |--------|-------------| | processAudio(samples: Float32Array) | Process audio samples, returns PitchResult or null | | reset() | Reset tuner state (call after audio interruption) | | setInstrument(instrument: number) | Set instrument type | | setTuningPreset(preset: number) | Set tuning preset | | setReferencePitch(pitch: number) | Set A4 reference (432-448 Hz) | | setChromaticMode(enabled: boolean) | Enable/disable chromatic mode | | setNoiseGate(thresholdDb: number) | Set noise gate (-60 to 0 dB) |

PitchResult

| Property | Type | Description | |----------|------|-------------| | frequency | number | Detected frequency in Hz | | confidence | number | Detection confidence (0-1) | | noteName | string | Note name (e.g., "E", "A#") | | octave | number | Octave number | | centDeviation | number | Cents off from target (-50 to +50) | | isInTune | boolean | Whether note is in tune (within threshold) | | tuningDirection | number | -1: flat, 0: in tune, 1: sharp | | matchedString | number | Matched string index (0-5) or -1 | | signalLevel | number | Input signal level (0-1) |

Instrument

| Constant | Value | Description | |----------|-------|-------------| | Guitar6String | 0 | 6-string guitar | | Bass4String | 1 | 4-string bass | | Bass5String | 2 | 5-string bass |

TuningPreset

| Constant | Value | Description | |----------|-------|-------------| | Standard | 0 | Standard tuning | | HalfStepDown | 1 | Half step down | | WholeStepDown | 2 | Whole step down | | DropD | 5 | Drop D | | DropC | 6 | Drop C | | OpenG | 9 | Open G | | OpenD | 10 | Open D | | DADGAD | 11 | DADGAD |

License

MIT