@ac-kit/media-piano-audio 0.2.0 → 0.3.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/CHANGELOG.md +120 -0
- package/README.md +20 -6
- package/dist/acoustics/_assert-piano-pitch.d.ts.map +1 -1
- package/dist/acoustics/_assert-piano-pitch.js +2 -1
- package/dist/acoustics/_assert-piano-pitch.js.map +1 -1
- package/dist/acoustics/_partial-pitch.d.ts +7 -0
- package/dist/acoustics/_partial-pitch.d.ts.map +1 -0
- package/dist/acoustics/_partial-pitch.js +9 -0
- package/dist/acoustics/_partial-pitch.js.map +1 -0
- package/dist/acoustics/piano-partials.d.ts.map +1 -1
- package/dist/acoustics/piano-partials.js +5 -4
- package/dist/acoustics/piano-partials.js.map +1 -1
- package/dist/calibrate/estimate-input-latency.d.ts.map +1 -1
- package/dist/calibrate/estimate-input-latency.js +6 -4
- package/dist/calibrate/estimate-input-latency.js.map +1 -1
- package/dist/synthesize/synthesize-piano.d.ts.map +1 -1
- package/dist/synthesize/synthesize-piano.js +2 -1
- package/dist/synthesize/synthesize-piano.js.map +1 -1
- package/dist/synthesize/synthesize-tick.d.ts.map +1 -1
- package/dist/synthesize/synthesize-tick.js +5 -4
- package/dist/synthesize/synthesize-tick.js.map +1 -1
- package/dist/verify/_onset-detector.d.ts.map +1 -1
- package/dist/verify/_onset-detector.js +6 -3
- package/dist/verify/_onset-detector.js.map +1 -1
- package/dist/verify/_templates.d.ts +6 -0
- package/dist/verify/_templates.d.ts.map +1 -1
- package/dist/verify/_templates.js +20 -9
- package/dist/verify/_templates.js.map +1 -1
- package/dist/verify/piano-chord-verifier.d.ts +80 -3
- package/dist/verify/piano-chord-verifier.d.ts.map +1 -1
- package/dist/verify/piano-chord-verifier.js +384 -82
- package/dist/verify/piano-chord-verifier.js.map +1 -1
- package/dist/verify/tuning.d.ts +27 -3
- package/dist/verify/tuning.d.ts.map +1 -1
- package/dist/verify/tuning.js +19 -2
- package/dist/verify/tuning.js.map +1 -1
- package/dist/verify/types.d.ts +9 -4
- package/dist/verify/types.d.ts.map +1 -1
- package/package.json +11 -10
|
@@ -36,7 +36,14 @@ export interface PianoChordVerifierOptions {
|
|
|
36
36
|
* decomposed onto harmonic templates of the 88 keys by KL-NMF activations, in
|
|
37
37
|
* which expected notes and notes heard in the last 1.5 s are free and other
|
|
38
38
|
* notes pay a penalty. A press whose new energy is too weak against what was
|
|
39
|
-
* already sounding gives no verdict.
|
|
39
|
+
* already sounding gives no verdict. A heard note that shares partials with
|
|
40
|
+
* another heard note — an octave, a twelfth — must then show the energy of its
|
|
41
|
+
* own against its single-note template: at its own partials when its
|
|
42
|
+
* fundamental is its own, or, when its fundamental lies on a lower note's
|
|
43
|
+
* partial, as an excess of that note's partials over its template.
|
|
44
|
+
*
|
|
45
|
+
* Where no onset was found, {@link recheck} judges a chord at the time it was
|
|
46
|
+
* due.
|
|
40
47
|
*
|
|
41
48
|
* Time 0 is the first sample processed, or the last {@link reset}.
|
|
42
49
|
*/
|
|
@@ -47,8 +54,8 @@ export declare class PianoChordVerifier {
|
|
|
47
54
|
readonly windowMs: number;
|
|
48
55
|
/** Frequency of A4 the templates are tuned to, Hz. */
|
|
49
56
|
readonly referenceHz: number;
|
|
50
|
-
/** The tuning in use, frozen. */
|
|
51
|
-
readonly tuning: PianoVerifierTuning
|
|
57
|
+
/** The tuning in use, its absent fields filled with the defaults, frozen. */
|
|
58
|
+
readonly tuning: Required<PianoVerifierTuning>;
|
|
52
59
|
private latencyMs_;
|
|
53
60
|
private readonly onset_;
|
|
54
61
|
private readonly ring_;
|
|
@@ -107,6 +114,15 @@ export declare class PianoChordVerifier {
|
|
|
107
114
|
private jobSet_;
|
|
108
115
|
private readonly allowed_;
|
|
109
116
|
private readonly recentUntil_;
|
|
117
|
+
private readonly recheckInitial_;
|
|
118
|
+
private readonly shift_;
|
|
119
|
+
private readonly inharmonicity_;
|
|
120
|
+
private readonly rechecks_;
|
|
121
|
+
private recheckCount_;
|
|
122
|
+
private readonly recheckLookback_;
|
|
123
|
+
private readonly recentIds_;
|
|
124
|
+
private readonly recentPitches_;
|
|
125
|
+
private recentNext_;
|
|
110
126
|
private calibrating_;
|
|
111
127
|
private calibrationStart_;
|
|
112
128
|
private calibrationEnd_;
|
|
@@ -141,6 +157,29 @@ export declare class PianoChordVerifier {
|
|
|
141
157
|
expect(id: number, pitches: readonly number[], options?: {
|
|
142
158
|
fromTime?: number;
|
|
143
159
|
}): void;
|
|
160
|
+
/**
|
|
161
|
+
* Judges expectation `id` at `frame` where no onset was found — a soft note
|
|
162
|
+
* right after a loud one, a note in the lowest octave — against the expected
|
|
163
|
+
* notes only: the window after `frame` against the one before it, as for an
|
|
164
|
+
* onset, with every other note left out and no gate on the whole press. A
|
|
165
|
+
* later {@link process} returns the verdict, with `source: "recheck"`; its
|
|
166
|
+
* `wrong` is empty, and an expected note is heard only when its own new level
|
|
167
|
+
* passes the gate. Ignored while {@link calibrating}.
|
|
168
|
+
*
|
|
169
|
+
* @param id - One of the last 16 ids given to {@link expect}; its latest
|
|
170
|
+
* pitches are judged.
|
|
171
|
+
* @param frame - The sample frame the chord was due at, on the
|
|
172
|
+
* {@link ChordVerdict.onsetFrame} clock: `Math.round((dueTime + latencyMs / 1000) *
|
|
173
|
+
* sampleRate)` for a due time on the `onsetTime` clock. At most half a
|
|
174
|
+
* second before the last frame processed; a later frame waits for its
|
|
175
|
+
* window.
|
|
176
|
+
* @throws {RangeError} On an id not among the recent expectations, a frame
|
|
177
|
+
* that is not a non-negative integer or is too old, or more than four
|
|
178
|
+
* rechecks waiting for their window.
|
|
179
|
+
*/
|
|
180
|
+
recheck(id: number, frame: number): void;
|
|
181
|
+
/** Moves the rechecks whose window is complete to the analysis queue. */
|
|
182
|
+
private releaseRechecks_;
|
|
144
183
|
/**
|
|
145
184
|
* Measures the background noise over the next `durationMs` of input, during
|
|
146
185
|
* which the player must keep silent, and uses it from then on. Pending
|
|
@@ -198,7 +237,45 @@ export declare class PianoChordVerifier {
|
|
|
198
237
|
private logSpectrum_;
|
|
199
238
|
/** New energy, allowed notes and penalties; loads the activations. */
|
|
200
239
|
private prepare_;
|
|
240
|
+
/**
|
|
241
|
+
* A note's new level against what already sounded at its partials.
|
|
242
|
+
* Fluctuations of ringing notes stay well below 1; a press, even soft under a
|
|
243
|
+
* loud chord, shows at its own partials.
|
|
244
|
+
*/
|
|
245
|
+
private gateRatio_;
|
|
201
246
|
/** The gate and the verdict, from the activations. */
|
|
202
247
|
private finish_;
|
|
248
|
+
private verdict_;
|
|
249
|
+
/** Partial `h` (from 1) of `pitch`, in semitones on the template grid. */
|
|
250
|
+
private partialPitch_;
|
|
251
|
+
/**
|
|
252
|
+
* The partial of `pitch` that lies within the overlap distance of `at`, its
|
|
253
|
+
* number from 1, or 0: any partial, not only the template's first
|
|
254
|
+
* `maxPartials`, since a string has them all.
|
|
255
|
+
*/
|
|
256
|
+
private partialOn_;
|
|
257
|
+
/** Whether a partial of a sounding note other than `except…` lies on `at`. */
|
|
258
|
+
private liesOnOther_;
|
|
259
|
+
/** Peak new energy (normalised) within a bin of a partial at `at`. */
|
|
260
|
+
private partialEnergy_;
|
|
261
|
+
/**
|
|
262
|
+
* The doubling check of a heard note against the other `sounding` notes. A
|
|
263
|
+
* note none of whose first `doublingPartials` partials another sounding note
|
|
264
|
+
* shares passes. Otherwise its partials are measured in the new energy and
|
|
265
|
+
* divided by its single-note template's amplitudes:
|
|
266
|
+
*
|
|
267
|
+
* - With its fundamental its own, the level of its own partials must reach
|
|
268
|
+
* `doublingOwnShare` of the shared ones' — a missing lower note of an
|
|
269
|
+
* octave shows its upper note's energy at its even partials and next to
|
|
270
|
+
* none at its fundamental;
|
|
271
|
+
* - With its fundamental on a lower note's partial (an octave, a twelfth above
|
|
272
|
+
* it): on one of those lower notes, the partials that are the note's must
|
|
273
|
+
* exceed the lower note's others by `doublingExcess`, or the lower note's
|
|
274
|
+
* own timbre explains them.
|
|
275
|
+
*
|
|
276
|
+
* A partial is shared when any partial of another sounding note lies within
|
|
277
|
+
* `overlapSemitones` of it, however high, as a string has them all.
|
|
278
|
+
*/
|
|
279
|
+
private hasOwnEnergy_;
|
|
203
280
|
}
|
|
204
281
|
//# sourceMappingURL=piano-chord-verifier.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"piano-chord-verifier.d.ts","sourceRoot":"","sources":["../../src/verify/piano-chord-verifier.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"piano-chord-verifier.d.ts","sourceRoot":"","sources":["../../src/verify/piano-chord-verifier.ts"],"names":[],"mappings":"AA4BA,OAAO,EAGN,KAAK,mBAAmB,EACxB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAoB,MAAM,YAAY,CAAC;AAE/E,6CAA6C;AAC7C,MAAM,WAAW,yBAAyB;IACzC,wDAAwD;IACxD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,6EAA6E;IAC7E,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,8EAA8E;IAC9E,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,qDAAqD;IACrD,QAAQ,CAAC,MAAM,CAAC,EAAE,mBAAmB,CAAC;IACtC,yEAAyE;IACzE,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;CACrC;AAsFD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,kBAAkB;IAC9B,sCAAsC;IACtC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,2BAA2B;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,sDAAsD;IACtD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,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