All Projects → cristovao-trevisan → node-pitchfinder

cristovao-trevisan / node-pitchfinder

Licence: MIT License
A compilation of pitch detection algorithms for Javascript.

Programming Languages

C++
36643 projects - #6 most used programming language
javascript
184084 projects - #8 most used programming language
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to node-pitchfinder

Arduino Pitch-Detector
Pitch Detection on Arduino using Autocorrelation
Stars: ✭ 21 (-16%)
Mutual labels:  pitch-detection
node-mac-contacts
Create, read, update, and delete contacts from users' contacts databases on macOS.
Stars: ✭ 48 (+92%)
Mutual labels:  node-addon
Arduino-FrequencyDetector
Fast audio frequency detector without fft for plain Arduino and Attiny85. Whistle switch example included.
Stars: ✭ 22 (-12%)
Mutual labels:  pitch-detection
node-jsonnet
libjsonnet binding for Node.js
Stars: ✭ 20 (-20%)
Mutual labels:  node-addon
node-gyp
Node.js native addon build tool
Stars: ✭ 8,850 (+35300%)
Mutual labels:  node-addon
Bayesian-Pitch-Tracking-Using-Harmonic-model
Pitch detection and pitch tracking, voicing unvoicing detection (VAD),基音检测
Stars: ✭ 70 (+180%)
Mutual labels:  pitch-detection
imogen
ultimate vocal harmonizer
Stars: ✭ 169 (+576%)
Mutual labels:  pitch-detection
Nbind
✨ Magical headers that make your C++ library accessible from JavaScript 🚀
Stars: ✭ 1,829 (+7216%)
Mutual labels:  node-addon

Standard - JavaScript Style Guide NPM version badge

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].