Home

Awesome

<p align="center"> <a href="https://standardjs.com"><img src="https://img.shields.io/badge/code_style-standard-brightgreen.svg" alt="Standard - JavaScript Style Guide"></a> <a href="https://www.npmjs.com/package/node-pitchfinder"><img src="https://img.shields.io/npm/v/node-pitchfinder" alt="NPM version badge"></a> </p>

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

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

YIN

AMDF

MacLeod

Dynamic Wavelet

no special config

MORE API

YIN and MacLeod

Usage

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

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

Todo

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