Detects the pitch of a signal using the autocorrelation method.
var detectPitch =var n = 1024var ω = 20 * MathPI / n//Initialize signalvar signal = nforvar i=0; i<n; ++isignali = Mathconsole//Prints out://// 100//
npm install detect-pitch
Detects the pitch of
signal by computing the period by autocorrelation.
signalis a snippet of an audio signal. Represented as either a typed array or an ndarray.
thresholdis an optional parameter between
1which determines the cutoff for reporting a successful detection. Higher values indicate stricture cutoff. Default is
Returns The number of samples in the period of the signal. If no pitch was detected, returns
0. To recover the pitch frequency, you need to divide the sample rate by this number (note that this will be
NaN for signals with no pitch):
var pitchInHz = sampleRateInHz / periodInSamples
(c) 2013-2015 Mikola Lysenko. MIT License