Detects the pitch of an audio snippet
Detects the pitch of a signal using the autocorrelation method.
var detectPitch = require"detect-pitch"var n = 1024var signal = nvar omega = 2.0 * MathPI / nforvar i=0; i<n; ++isignali = Mathsin100 * i * omegaconsole.logMathroundn / detectPitchsignal//Prints out://// 100//
npm install detect-pitch
Detects the pitch of
signal by computing the period by autocorrelation.
signalis a (possibly windowed) snippet of an audio signal. Represented as either a typed array or an ndarray.
optionsis an object containing optional arguments to the function:
options.thresholda float between
[0,1]that determines how intense a peak needs to be before it is consider a pitch. (Default
options.start_binan integer representing 1/lowest freqeuency. (Default
Returns The period of the signal. To recover the pitch, divide the sample rate by it.
Note The return value was changed to period in 0.1.0 since it can be computed more accurately.
(c) 2013 Mikola Lysenko. MIT License