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 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-pitchfinder

v2.1.0

Published

A pitch-detection library for node (using C++ Addon)

Downloads

50

Readme

node-pitchfinder

A compilation of pitch detection algorithms for Node (Using native C++ Addon). Based on pitchfinder, but running a lot faster (because it's native)

Provided pitch-finding algorithms

  • MacLeod - Best results for instruments
  • YIN - The best balance of accuracy and speed, in my experience. Occasionally provides values that are wildly incorrect.
  • AMDF - Slow and only accurate to around +/- 2%, but finds a frequency more consistenly than others. NOT AN ADDON
  • Dynamic Wavelet - Very fast, but struggles to identify lower frequencies. NOT AN ADDON
  • YIN w/ FFT TODO
  • Goertzel TODO

Installation

npm install --save node-pitchfinder

For node < 10 use version ^1.x, version 2+ is for node >= 10

Usage

Finding the pitch of a wav file in node

const fs = require('fs')
const WavDecoder = require('wav-decoder')
const { YIN } = require('node-pitchfinder')

// see below for option parameters.
const detectPitch = YIN({ sampleRate: 44100 })

const buffer = fs.readFileSync(PATH_TO_FILE)
const decoded = WavDecoder.decode(buffer) // get audio data from file using `wav-decoder`
const float64Array = decoded.channelData[0] // get a single channel of sound
const pitch = detectPitch(float64Array) // All detectors are using float64Array internally, but you can also give an ordinary array of numbers

Configuration

All detectors

  • sampleRate - defaults to 44100

YIN

  • threshold - used by the algorithm
  • probabilityThreshold - don't return a pitch if probability estimate is below this number.

AMDF

  • minFrequency - Lowest frequency detectable
  • maxFrequency - Highest frequency detectable
  • sensitivity
  • ratio

MacLeod

  • bufferSize - Maximum data size (default 1024)
  • cutoff - Defines the relative size the chosen peak (pitch) has. 0.93 means: choose the first peak that is higher than 93% of the highest peak detected. 93% is the default value used in the Tartini user interface.
  • freqCutoff - Minimum frequency to be detected (default 80Hz)
  • probabilityThreshold - don't return a pitch if probability estimate is below this number.

Dynamic Wavelet

no special config

MORE API

YIN and MacLeod

  • method: getResult (data) - does not use probabilityThreshold, returns an object with probability instead, like { pitch: number, probability: number }

Usage

const {MacLeod} = require('node-pitchfinder')
const detectPitch = MacLeod().getResult

detectPitch(data)
// {pitch: 440, probability: 1}

Todo

  • MacLeod using FFT

Thanks

Several of these algorithms were ported from Jonas Six's excellent TarsosDSP library (written in Java). If you're looking for a far deeper set of tools than this, check out his work on his website or on Github.

Thanks to Aubio for his YIN code