audio

@audio/pitch-yin1.1.0

YIN pitch detection

YIN pitch detection (de Cheveigné & Kawahara, 2002)

Status
calibrated
Updated
Family
pitch, 8 packages under it
Plugin
pitch, effect, streaming, 1 parameter
Category
analysis
Licence
MIT
Dependencies
none
Downloads
5,453 last month
Tests
67 in audiojs/pitch's CI, passed at 0f3d116,

Parameters

  • effect
  • streaming
threshold
0.1
0.05 to 0.5
import yin from '@audio/pitch-yin'

de Cheveigné & Kawahara, 2002. The reference algorithm for monophonic pitch estimation. Most cited, most tested, most robust.

let result = yin(samples, { fs: 44100 })
// → { freq: 440.1, clarity: 0.97 }  or  null
Param Default
fs 44100 Sample rate (Hz)
threshold 0.15 CMND threshold — lower = stricter, fewer detections
minFreq — Minimum frequency (Hz); also uses more of the frame for low pitches
maxFreq — Maximum frequency (Hz)

Pass the expected range when known: yin(samples, { fs, minFreq: 60, maxFreq: 520 }). Besides rejecting out-of-range results, minFreq lets YIN use a longer comparison window and improves low-pitch detection near onsets.

yinInto(data, k, d, cmndf) is the same estimate allocating nothing, for a caller that runs it frame after frame: k, a Float64Array of 6, holds fs, threshold, minFreq and maxFreq (NaN where there is none) and takes the pitch and the clarity at 4 and 5 where it returns 1; d and cmndf are scratch Float64Arrays of half the frame. The ./audio processor runs it on 2048-sample frames.

Use when: General-purpose monophonic pitch tracking — speech, singing, solo instruments. The most reliable choice when in doubt.
Not for: Polyphonic audio (returns dominant or null), real-time with hard latency budgets (needs full window).
Ref: de Cheveigné & Kawahara, "YIN, a fundamental frequency estimator for speech and music", JASA 2002.
Complexity: O(N2/4)O(N^2/4) — two nested passes over half the window.


Part of @audio/pitch — the pitch family umbrella. This README is generated from the umbrella docs.

MIT © audiojs