@audio/pitch 2.0.4 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -3
- package/index.d.ts +20 -0
- package/members/amdf.d.ts +2 -0
- package/members/amdf.js +2 -0
- package/members/autocorrelation.d.ts +2 -0
- package/members/autocorrelation.js +2 -0
- package/members/cepstrum.d.ts +2 -0
- package/members/cepstrum.js +2 -0
- package/members/hps.d.ts +2 -0
- package/members/hps.js +2 -0
- package/members/mcleod.d.ts +2 -0
- package/members/mcleod.js +2 -0
- package/members/pyin.d.ts +2 -0
- package/members/pyin.js +2 -0
- package/members/swipe.d.ts +2 -0
- package/members/swipe.js +2 -0
- package/members/yin/audio.d.ts +1 -0
- package/members/yin/audio.js +1 -0
- package/members/yin.d.ts +2 -0
- package/members/yin.js +2 -0
- package/package.json +26 -14
package/README.md
CHANGED
|
@@ -150,9 +150,36 @@ let result = pyin(samples, { fs: 44100 })
|
|
|
150
150
|
| `minFreq` | `50` | Minimum detectable frequency (Hz) |
|
|
151
151
|
| `maxFreq` | `2000` | Maximum detectable frequency (Hz) |
|
|
152
152
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
Over a sequence of frames, `track` runs pYIN's second stage and `notes` segments its result into notes:
|
|
154
|
+
|
|
155
|
+
```js
|
|
156
|
+
import { track, notes } from '@audio/pitch-pyin'
|
|
157
|
+
|
|
158
|
+
let { times, f0, voiced, prob } = track(samples, { fs: 44100 }) // frame i at i·hopSize/fs, f0 0 where unvoiced
|
|
159
|
+
let events = notes(samples, { fs: 44100 }) // → [{ time, duration, freq, midi, clarity }, ...]
|
|
160
|
+
|
|
161
|
+
let write = notes({ fs: 44100 }) // streaming, track too
|
|
162
|
+
write(block) // → the notes finished so far
|
|
163
|
+
write() // → the rest
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
| Param | Default | |
|
|
167
|
+
|---|---|---|
|
|
168
|
+
| `frameSize` | `2048` at 44.1 kHz | Frame (samples): the shortest power of 2 whose YIN window holds a period of `minFreq` |
|
|
169
|
+
| `hopSize` | `256` at 44.1 kHz | Hop (samples), ≈ 5.8 ms |
|
|
170
|
+
| `lag` | `4096` | Frames within which every frame is decided: a stream runs at most this far behind its input |
|
|
171
|
+
| `minDuration` | `0.1` | `notes`: shortest note kept (s) |
|
|
172
|
+
| `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 |
|
|
173
|
+
|
|
174
|
+
`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, or, if they have not met within `lag` frames, along the best path then (fixed-lag decoding, as the pYIN Vamp plugin): memory stays bounded at any length, and a stream with a short `lag` decides each frame a fixed latency behind its input. 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.
|
|
175
|
+
|
|
176
|
+
`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.
|
|
177
|
+
|
|
178
|
+
`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.
|
|
179
|
+
|
|
180
|
+
**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>
|
|
181
|
+
**Not for:** Polyphonic audio: one pitch per frame.<br>
|
|
182
|
+
**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.
|
|
156
183
|
|
|
157
184
|
|
|
158
185
|
## Autocorrelation
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// @audio/pitch — pitch detection umbrella re-exporting every @audio/pitch-* atom.
|
|
2
|
+
// For smaller bundles, depend directly on the individual atom.
|
|
3
|
+
// Chroma / chord / key detection moved to @audio/mir.
|
|
4
|
+
|
|
5
|
+
export { default as yin } from '@audio/pitch-yin'
|
|
6
|
+
export { default as mcleod } from '@audio/pitch-mcleod'
|
|
7
|
+
export { default as pyin } from '@audio/pitch-pyin'
|
|
8
|
+
export { default as hps } from '@audio/pitch-hps'
|
|
9
|
+
export { default as cepstrum } from '@audio/pitch-cepstrum'
|
|
10
|
+
export { default as swipe } from '@audio/pitch-swipe'
|
|
11
|
+
export { default as autocorrelation } from '@audio/pitch-autocorrelation'
|
|
12
|
+
export { default as amdf } from '@audio/pitch-amdf'
|
|
13
|
+
export type { AmdfOptions } from '@audio/pitch-amdf'
|
|
14
|
+
export type { AutocorrelationOptions } from '@audio/pitch-autocorrelation'
|
|
15
|
+
export type { CepstrumOptions } from '@audio/pitch-cepstrum'
|
|
16
|
+
export type { HpsOptions } from '@audio/pitch-hps'
|
|
17
|
+
export type { McleodOptions } from '@audio/pitch-mcleod'
|
|
18
|
+
export type { PyinOptions, PyinCandidate } from '@audio/pitch-pyin'
|
|
19
|
+
export type { SwipeOptions } from '@audio/pitch-swipe'
|
|
20
|
+
export type { YinOptions } from '@audio/pitch-yin'
|
package/members/amdf.js
ADDED
package/members/hps.d.ts
ADDED
package/members/hps.js
ADDED
package/members/pyin.js
ADDED
package/members/swipe.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/pitch-yin/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/pitch-yin/audio'
|
package/members/yin.d.ts
ADDED
package/members/yin.js
ADDED
package/package.json
CHANGED
|
@@ -1,19 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@audio/pitch",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Pitch detection — umbrella for @audio/pitch-* atoms (YIN, pYIN, McLeod, HPS, cepstrum, SWIPE, autocorrelation, AMDF)",
|
|
6
6
|
"exports": {
|
|
7
|
-
".":
|
|
8
|
-
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./index.d.ts",
|
|
9
|
+
"default": "./index.js"
|
|
10
|
+
},
|
|
11
|
+
"./package.json": "./package.json",
|
|
12
|
+
"./*": {
|
|
13
|
+
"types": "./members/*.d.ts",
|
|
14
|
+
"default": "./members/*.js"
|
|
15
|
+
}
|
|
9
16
|
},
|
|
10
17
|
"files": [
|
|
11
|
-
"index.js"
|
|
18
|
+
"index.js",
|
|
19
|
+
"*.d.ts",
|
|
20
|
+
"members/"
|
|
12
21
|
],
|
|
13
22
|
"scripts": {
|
|
14
23
|
"test": "node test.js",
|
|
15
24
|
"test:all": "npm test --workspaces --if-present && npm test",
|
|
16
|
-
"publish:all": "npm publish --workspaces && npm publish"
|
|
25
|
+
"publish:all": "npm publish --workspaces && npm publish",
|
|
26
|
+
"members": "node scripts/members.js",
|
|
27
|
+
"prepublishOnly": "node scripts/members.js --check"
|
|
17
28
|
},
|
|
18
29
|
"repository": {
|
|
19
30
|
"type": "git",
|
|
@@ -55,14 +66,14 @@
|
|
|
55
66
|
"node": ">=18"
|
|
56
67
|
},
|
|
57
68
|
"dependencies": {
|
|
58
|
-
"@audio/pitch-yin": "^1.0.
|
|
59
|
-
"@audio/pitch-mcleod": "^1.0.
|
|
60
|
-
"@audio/pitch-pyin": "^1.0
|
|
61
|
-
"@audio/pitch-hps": "^1.0.
|
|
62
|
-
"@audio/pitch-cepstrum": "^1.0.
|
|
63
|
-
"@audio/pitch-swipe": "^1.0.
|
|
64
|
-
"@audio/pitch-autocorrelation": "^1.0.
|
|
65
|
-
"@audio/pitch-amdf": "^1.0.
|
|
69
|
+
"@audio/pitch-yin": "^1.0.6",
|
|
70
|
+
"@audio/pitch-mcleod": "^1.0.2",
|
|
71
|
+
"@audio/pitch-pyin": "^2.1.0",
|
|
72
|
+
"@audio/pitch-hps": "^1.0.2",
|
|
73
|
+
"@audio/pitch-cepstrum": "^1.0.2",
|
|
74
|
+
"@audio/pitch-swipe": "^1.0.2",
|
|
75
|
+
"@audio/pitch-autocorrelation": "^1.0.2",
|
|
76
|
+
"@audio/pitch-amdf": "^1.0.2"
|
|
66
77
|
},
|
|
67
78
|
"devDependencies": {
|
|
68
79
|
"tst": "^9.4.0"
|
|
@@ -75,5 +86,6 @@
|
|
|
75
86
|
"workspaces": [
|
|
76
87
|
"packages/*"
|
|
77
88
|
],
|
|
78
|
-
"funding": "https://github.com/sponsors/audiojs"
|
|
89
|
+
"funding": "https://github.com/sponsors/audiojs",
|
|
90
|
+
"types": "./index.d.ts"
|
|
79
91
|
}
|