{"_id":"@audio/pitch-pyin","_rev":"3-de30e8faf2b57f50aebd72c916667346","name":"@audio/pitch-pyin","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"@audio/pitch-pyin","version":"1.0.0","keywords":["audio","dsp","pitch","pitch-detection","f0","pyin"],"author":{"name":"Dmitry Iv.","email":"dfcreative@gmail.com"},"license":"MIT","_id":"@audio/pitch-pyin@1.0.0","maintainers":[{"name":"jamen","email":"jamenmarz@gmail.com"},{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"df.creative@gmail.com"}],"homepage":"https://github.com/audiojs/pitch/tree/main/packages/pitch-pyin","bugs":{"url":"https://github.com/audiojs/pitch/issues"},"dist":{"shasum":"7ab052a6f41ac1e44f02431223934e234ce71a16","tarball":"https://registry.npmjs.org/@audio/pitch-pyin/-/pitch-pyin-1.0.0.tgz","fileCount":2,"integrity":"sha512-rgPSgrhcKubwdBih7y5XbZYtcbh7WdidfhMI4ji9I9MzHHGbVm8zrZJ43LG2TEZLQTypDmy65rt4/LtYSCZRoQ==","signatures":[{"sig":"MEQCIGJfXu7klQxzxZq4Q4vzHLSzgADAGp3RXyvGfQ5TipqiAiANZT7u0hfvnZlq7ACD6crBUjzIKqbLh9U2kLmzksJZbA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":4419},"main":"pyin.js","type":"module","engines":{"node":">=18"},"exports":{".":"./pyin.js","./package.json":"./package.json"},"gitHead":"984da555a04fddf53e71299736a2dc76311b2a49","_npmUser":{"name":"dy","email":"df.creative@gmail.com"},"repository":{"url":"git+https://github.com/audiojs/pitch.git","type":"git","directory":"packages/pitch-pyin"},"_npmVersion":"11.12.1","description":"pYIN — probabilistic YIN (Mauch & Dixon, 2014)","directories":{},"sideEffects":false,"_nodeVersion":"25.9.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/pitch-pyin_1.0.0_1783539938030_0.3668836551475154","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@audio/pitch-pyin","version":"1.0.1","keywords":["audio","dsp","pitch","pitch-detection","f0","pyin"],"author":{"name":"Dmitry Iv.","email":"dfcreative@gmail.com"},"license":"MIT","_id":"@audio/pitch-pyin@1.0.1","maintainers":[{"name":"jamen","email":"jamenmarz@gmail.com"},{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"df.creative@gmail.com"}],"homepage":"https://github.com/audiojs/pitch/tree/main/packages/pitch-pyin","bugs":{"url":"https://github.com/audiojs/pitch/issues"},"dist":{"shasum":"20e452b78a606ca2eed75ecb9e65d6942242b0c4","tarball":"https://registry.npmjs.org/@audio/pitch-pyin/-/pitch-pyin-1.0.1.tgz","fileCount":4,"integrity":"sha512-ecBicUx+arjwggUy/p0EbHRB9b28zoU5n3ESp0RRy/udvAT6c1bqCyqxFpaobDPG4oPVFLFEcVfmrOMFHgixqw==","signatures":[{"sig":"MEQCIFlwCVfEleC57ta33To+fbCbXXiRr28ezmSW2aPGRWgkAiBS+ASn1KYyb49eJG/ErFXtk7zI9TY2CwDUKjSDpTqdxg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":7479},"main":"pyin.js","type":"module","types":"index.d.ts","engines":{"node":">=18"},"exports":{".":"./pyin.js","./package.json":"./package.json"},"funding":"https://github.com/sponsors/audiojs","gitHead":"c388499cb8107c4fdcc0e314410327655222b5b1","_npmUser":{"name":"dy","email":"df.creative@gmail.com"},"repository":{"url":"git+https://github.com/audiojs/pitch.git","type":"git","directory":"packages/pitch-pyin"},"_npmVersion":"11.12.1","description":"pYIN — probabilistic YIN (Mauch & Dixon, 2014)","directories":{},"sideEffects":false,"_nodeVersion":"25.9.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/pitch-pyin_1.0.1_1783731717189_0.03517267897300358","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"_id":"@audio/pitch-pyin@2.0.0","bugs":{"url":"https://github.com/audiojs/pitch/issues"},"dist":{"shasum":"7940166d8b3304f093b07ec887c06b610bb79acd","tarball":"https://registry.npmjs.org/@audio/pitch-pyin/-/pitch-pyin-2.0.0.tgz","fileCount":8,"integrity":"sha512-0AbvLkfocOP8jlnbG2sJ48ZDBOk/lQhU5uPlBjVoG5t8OTgS+nW6rPyMpW4WKFgDo6A8CmfTb6pW1tbtTSpCqg==","signatures":[{"sig":"MEUCIGr6mQCWanaHGVuQQXPtE2W63iNrd8T4sN6i1NNcVpJ+AiEAiqnbrRwvfUe+AQcIbwBQZU8utkhsEydSPiBlbx6Ugtc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIC7pSY/TMWlOuyfZqzALIBo+yCRCtDvQUWJnVHgBKnPjAiB41+ZQhdNagbnA/R0ikqyNkl9mwVBqCEer05b0vlVyjw=="}],"unpackedSize":33890},"main":"pyin.js","name":"@audio/pitch-pyin","type":"module","types":"index.d.ts","author":{"name":"Dmitry Iv.","email":"dfcreative@gmail.com"},"engines":{"node":">=18"},"exports":{".":{"types":"./index.d.ts","default":"./pyin.js"},"./package.json":"./package.json"},"funding":"https://github.com/sponsors/audiojs","gitHead":"b0c1696d04df0a9d824700549bdefcef5669ace5","license":"MIT","version":"2.0.0","_npmUser":{"name":"dy","email":"df.creative@gmail.com"},"homepage":"https://github.com/audiojs/pitch/tree/main/packages/pitch-pyin","keywords":["audio","dsp","pitch","pitch-detection","f0","pyin","viterbi","note-transcription","tony"],"repository":{"url":"git+https://github.com/audiojs/pitch.git","type":"git","directory":"packages/pitch-pyin"},"_npmVersion":"11.12.1","description":"pYIN — probabilistic YIN (Mauch & Dixon, 2014)","directories":{},"maintainers":[{"name":"jamen","email":"jamenmarz@gmail.com"},{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"df.creative@gmail.com"}],"sideEffects":false,"_nodeVersion":"25.9.0","dependencies":{"fourier-transform":"^2.2.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pitch-pyin_2.0.0_1790652429887_0.8649994960554395"}}},"time":{"created":"2026-07-08T19:45:37.905Z","modified":"2026-09-29T03:27:10.199Z","1.0.0":"2026-07-08T19:45:38.162Z","1.0.1":"2026-07-11T01:01:57.330Z","2.0.0":"2026-09-29T03:27:09.975Z"},"bugs":{"url":"https://github.com/audiojs/pitch/issues"},"author":{"name":"Dmitry Iv.","email":"dfcreative@gmail.com"},"license":"MIT","homepage":"https://github.com/audiojs/pitch/tree/main/packages/pitch-pyin","keywords":["audio","dsp","pitch","pitch-detection","f0","pyin","viterbi","note-transcription","tony"],"repository":{"url":"git+https://github.com/audiojs/pitch.git","type":"git","directory":"packages/pitch-pyin"},"description":"pYIN — probabilistic YIN (Mauch & Dixon, 2014)","maintainers":[{"name":"jamen","email":"jamenmarz@gmail.com"},{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"df.creative@gmail.com"}],"readme":"# @audio/pitch-pyin [![npm](https://img.shields.io/npm/v/@audio/pitch-pyin)](https://www.npmjs.com/package/@audio/pitch-pyin) [![MIT](https://img.shields.io/badge/MIT-%E0%A5%90-white)](https://github.com/krishnized/license)\n\npYIN — probabilistic YIN (Mauch & Dixon, 2014)\n\n```\nnpm install @audio/pitch-pyin\n```\n\n```js\nimport pyin, { track, notes } from '@audio/pitch-pyin'\n```\n\n**Mauch & Dixon, 2014.** Probabilistic YIN — runs YIN at multiple thresholds weighted by a Beta(2, 18) prior, producing a distribution over candidate pitches instead of a single hard pick. More robust than YIN on ambiguous frames.\n\n```js\nlet result = pyin(samples, { fs: 44100 })\n// → { freq: 440.1, clarity: 0.92, candidates: [{ freq: 440.1, prob: 0.85 }, ...] }\n```\n\n| Param | Default | |\n|---|---|---|\n| `fs` | `44100` | Sample rate (Hz) |\n| `minFreq` | `50` | Minimum detectable frequency (Hz) |\n| `maxFreq` | `2000` | Maximum detectable frequency (Hz) |\n\nUnlike the other atoms, the single-frame result also carries `candidates` — the full posterior over detected periods, sorted by probability, each `{ freq, prob }` with `prob` normalized to sum to 1 across candidates. `clarity` is the (clamped) total probability mass captured by the candidate set, not a single-peak confidence.\n\nOver a sequence of frames, `track` runs pYIN's second stage and `notes` segments its result into notes:\n\n```js\nlet { times, f0, voiced, prob } = track(samples, { fs: 44100 })   // frame i at i·hopSize/fs, f0 0 where unvoiced\nlet events = notes(samples, { fs: 44100 })                        // → [{ time, duration, freq, midi, clarity }, ...]\n\nlet write = notes({ fs: 44100 })   // streaming, track too\nwrite(block)                       // → the notes finished so far\nwrite()                            // → the rest\n```\n\n| Param | Default | |\n|---|---|---|\n| `frameSize` | `2048` at 44.1 kHz | Frame (samples): the shortest power of 2 whose YIN window holds a period of `minFreq` |\n| `hopSize` | `256` at 44.1 kHz | Hop (samples), ≈ 5.8 ms |\n| `minDuration` | `0.1` | `notes`: shortest note kept (s) |\n| `candidates` | YIN's | Stage 1: another observation model for the HMM, such as [`@audio/neural-pitch`](https://github.com/audiojs/neural/tree/main/packages/neural-pitch)'s |\n\n`track` Viterbi-decodes pYIN's pitch HMM. States are 0.1-semitone bins from `minFreq` to `maxFreq`, voiced or unvoiced; pitch moves at most 35.92 octaves per second and voicing switches with probability 0.01 (librosa.pyin's defaults). Voiced states take half their candidates' probability (the Vamp plugin's `yinTrust`), which keeps an unvoiced path open, so a leap between notes is not followed an octave off. A frame is decided once every Viterbi path through it agrees, so memory stays bounded at any length. Against librosa.pyin 1.0: the difference function is YIN's own (librosa zero-extends the frame, which pulls low pitches sharp), candidates in one bin add up, and `f0` is the candidate inside the decoded bin, not the bin centre.\n\n`notes` is Tony's note model, with the pYIN Vamp plugin's parameters and output: attack, stable and silent states for 3 pitches per semitone. Vibrato and a scoop into a note stay inside it; the same pitch played again starts a new note where the level rises 1/0.7-fold within two frames; a fast glide joins the notes at its ends, a slow one steps through the notes it passes. `freq` is the median pitch of the note's frames, `clarity` their mean voiced probability.\n\n`candidates` replaces stage 1 and leaves the HMM and the note model as they are. It has `candidates.js`'s signature: `(frameSize, fs, minFreq, maxFreq) → run`, where `run(frame)` returns the candidate count after filling `run.freq`, `run.prob` (each candidate's pitch probability, at most 1 in all) and `run.rms` (the level the note onsets read); `run.frameSize` and `run.lead` set how many samples a frame holds and how many of them precede its time. Without it the output is the same, bit for bit.\n\n**Use when:** Ambiguous pitched content — breathy vocals, noisy recordings, or when you need a pitch posterior for downstream HMM tracking. Melody of a voice or solo instrument: smoothed f0 with voicing (`track`), note events (`notes`).<br>\n**Not for:** Polyphonic audio: one pitch per frame.<br>\n**Ref:** Mauch & Dixon, [\"pYIN: A Fundamental Frequency Estimator Using Probabilistic Threshold Distributions\"](https://doi.org/10.1109/ICASSP.2014.6853678), ICASSP 2014. Mauch et al., [\"Computer-aided Melody Note Transcription Using the Tony Software: Accuracy and Efficiency\"](https://www.tenor-conference.org/proceedings/2015/04-Mauch-Tony.pdf), TENOR 2015.\n\n---\n\nPart of [@audio/pitch](https://github.com/audiojs/pitch) — the pitch family umbrella. This README is generated from the umbrella docs.\n\nMIT © [audiojs](https://github.com/audiojs)\n","readmeFilename":"README.md"}