dp

detect-pitch

Detects the pitch of an audio snippet

Showing:

Popularity

Downloads/wk

16

GitHub Stars

60

Maintenance

Last Commit

6yrs ago

Contributors

0

Package

Dependencies

6

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

detect-pitch

Detects the pitch of a signal using the autocorrelation method.

Example

var detectPitch = require('detect-pitch')

var n = 1024
var ω = 2.0 * Math.PI / n

//Initialize signal
var signal = new Float32Array(n)
for(var i=0; i<n; ++i) {
  signal[i] = Math.sin(100 * i * ω)
}

console.log(Math.round(n / detectPitch(signal)))

//Prints out:
//
//    100
//

Install

npm install detect-pitch

require('detect-pitch')(signal[, threshold])

Detects the pitch of signal by computing the period by autocorrelation.

  • signal is a snippet of an audio signal. Represented as either a typed array or an ndarray.
  • threshold is an optional parameter between 0 and 1 which determines the cutoff for reporting a successful detection. Higher values indicate stricture cutoff. Default is 0

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

Credits

(c) 2013-2015 Mikola Lysenko. MIT License

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial