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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@playground-sessions/basic-pitch

v0.1.0

Published

Experimental browser pitch detection sandbox (naive autocorrelation/AMDF/FFT). My first try at Web Audio pitch detection, rough

Readme

@playground-sessions/basic-pitch

A sandbox implementation of three different pitch detection algorithms for comparison:

  1. Autocorrelation (time-domain)
  2. Average Magnitude Difference Function (AMDF)
  3. Fast Fourier Transform (FFT) with Harmonic Product Spectrum

This is kind of a failure. I didn't get it to work.

Features

  • Three different pitch detection methods in one package
  • Compare algorithms side-by-side
  • Interactive demo with real-time visualization
  • TypeScript types included
  • Zero dependencies

Installation

npm install @playground-sessions/basic-pitch

Usage

import {
  AutocorrelationPitchDetector,
  AmdfPitchDetector,
  FftPitchDetector,
  CombinedPitchDetector
} from '@playground-sessions/basic-pitch';

// Use individual detectors
const detector = new AutocorrelationPitchDetector({
  frameSize: 2048,
  sampleRate: 44100,
  minFrequency: 50,
  maxFrequency: 2000
});

// Or use the combined detector that picks the best result
const combined = new CombinedPitchDetector({
  frameSize: 2048,
  sampleRate: 44100
});

// Analyze audio frames
const frame = new Float32Array(2048); // Your audio data here
const result = detector.analyze(frame);
console.log(`Frequency: ${result.frequency} Hz`);
console.log(`Confidence: ${result.confidence}`);
console.log(`Method: ${result.method}`);

Demo

An interactive demo is included that lets you compare all three methods in real-time:

  1. Clone this repository
  2. Run npm install
  3. Run npm run dev
  4. Open your browser and try the pitch detector

How it Works

Autocorrelation Method

  • Compares the signal with delayed versions of itself
  • Finds periodic patterns in the time domain
  • Good for clean, monophonic signals

AMDF Method

  • Similar to autocorrelation but uses differences instead of products
  • Can be more robust to noise in some cases
  • Computationally efficient

FFT Method

  • Transforms the signal to the frequency domain
  • Uses Harmonic Product Spectrum for better accuracy
  • Good for complex tones with strong harmonics

Options

All detectors accept these options:

  • frameSize: Size of the analysis frame (default: 2048)
  • sampleRate: Sample rate of the audio (default: 44100)
  • minFrequency: Minimum frequency to detect (default: 50 Hz)
  • maxFrequency: Maximum frequency to detect (default: 2000 Hz)

Contributing

This is an educational project built during the WebAudio Pitch Jam '25. Contributions are welcome!