@libraz/libsonare 1.4.1 → 1.5.1
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 +51 -20
- package/dist/index.d.ts +5416 -1
- package/dist/index.js +938 -583
- package/dist/index.js.map +1 -1
- package/dist/sonare.js +2 -2
- package/dist/sonare.wasm +0 -0
- package/dist/worklet.d.ts +1083 -5227
- package/dist/worklet.js +2683 -2451
- package/dist/worklet.js.map +1 -1
- package/package.json +4 -9
- package/src/clip_page_streamer.ts +298 -0
- package/src/effects_mastering.ts +85 -1089
- package/src/effects_transform.ts +286 -0
- package/src/effects_voice_change.ts +118 -0
- package/src/feature_music.ts +5 -2
- package/src/feature_spectrogram.ts +42 -2
- package/src/features.ts +1 -0
- package/src/index.ts +23 -0
- package/src/mastering_chain.ts +200 -0
- package/src/mastering_core.ts +248 -0
- package/src/mastering_dynamics.ts +105 -0
- package/src/mastering_repair.ts +161 -0
- package/src/mixer.ts +8 -0
- package/src/mixing_oneshot.ts +54 -0
- package/src/module_state.ts +1 -2
- package/src/project.ts +71 -1712
- package/src/project_class.ts +871 -0
- package/src/project_internal.ts +333 -0
- package/src/project_synth.ts +43 -0
- package/src/project_types.ts +570 -0
- package/src/public_types.ts +6 -1221
- package/src/public_types_acoustic.ts +115 -0
- package/src/public_types_mastering.ts +333 -0
- package/src/public_types_mixing.ts +97 -0
- package/src/public_types_music.ts +352 -0
- package/src/public_types_realtime.ts +163 -0
- package/src/public_types_spectral.ts +194 -0
- package/src/realtime_engine.ts +94 -0
- package/src/sonare.js.d.ts +117 -38
- package/src/stream_analyzer.ts +3 -0
- package/src/stream_types.ts +4 -0
- package/src/worklet/engine-automation.ts +73 -0
- package/src/worklet/engine-capture-facade.ts +80 -0
- package/src/worklet/engine-clips.ts +71 -0
- package/src/worklet/engine-markers.ts +93 -0
- package/src/worklet/engine-mixer-facade.ts +186 -0
- package/src/worklet/engine-node.ts +451 -0
- package/src/worklet/engine-offline.ts +162 -0
- package/src/worklet/engine-options.ts +13 -0
- package/src/worklet/engine-parameter-facade.ts +172 -0
- package/src/worklet/engine-processor.ts +764 -0
- package/src/worklet/engine-register.ts +136 -0
- package/src/worklet/engine-strips.ts +315 -0
- package/src/worklet/engine-sync.ts +94 -0
- package/src/worklet/engine-tempo-facade.ts +141 -0
- package/src/worklet/engine.ts +998 -0
- package/src/worklet/guards.ts +14 -1
- package/src/worklet/messages.ts +60 -20
- package/src/worklet/mixer-processor.ts +368 -0
- package/src/worklet/protocol.ts +3 -0
- package/src/worklet/voice-changer-processor.ts +246 -0
- package/src/worklet.ts +20 -3549
- package/dist/sonare-rt-module.js +0 -2
- package/dist/sonare-rt.js +0 -2
- package/dist/sonare-rt.wasm +0 -0
- package/src/sonare-rt.d.ts +0 -93
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import type { ValidateOptions } from './validation';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pitch class enum (C=0, C#=1, ..., B=11)
|
|
5
|
+
*/
|
|
6
|
+
export const PitchClass = {
|
|
7
|
+
C: 0,
|
|
8
|
+
Cs: 1,
|
|
9
|
+
D: 2,
|
|
10
|
+
Ds: 3,
|
|
11
|
+
E: 4,
|
|
12
|
+
F: 5,
|
|
13
|
+
Fs: 6,
|
|
14
|
+
G: 7,
|
|
15
|
+
Gs: 8,
|
|
16
|
+
A: 9,
|
|
17
|
+
As: 10,
|
|
18
|
+
B: 11,
|
|
19
|
+
} as const;
|
|
20
|
+
|
|
21
|
+
export type PitchClass = (typeof PitchClass)[keyof typeof PitchClass];
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Musical mode
|
|
25
|
+
*/
|
|
26
|
+
export const Mode = {
|
|
27
|
+
Major: 0,
|
|
28
|
+
Minor: 1,
|
|
29
|
+
Dorian: 2,
|
|
30
|
+
Phrygian: 3,
|
|
31
|
+
Lydian: 4,
|
|
32
|
+
Mixolydian: 5,
|
|
33
|
+
Locrian: 6,
|
|
34
|
+
} as const;
|
|
35
|
+
|
|
36
|
+
export type Mode = (typeof Mode)[keyof typeof Mode];
|
|
37
|
+
|
|
38
|
+
export type TempogramMode = 'autocorrelation' | 'auto' | 'ac' | 'cosine' | 0 | 1;
|
|
39
|
+
|
|
40
|
+
export const KeyProfile = {
|
|
41
|
+
KrumhanslSchmuckler: 0,
|
|
42
|
+
Temperley: 1,
|
|
43
|
+
Shaath: 2,
|
|
44
|
+
FaraldoEDMT: 3,
|
|
45
|
+
FaraldoEDMA: 4,
|
|
46
|
+
FaraldoEDMM: 5,
|
|
47
|
+
BellmanBudge: 6,
|
|
48
|
+
} as const;
|
|
49
|
+
|
|
50
|
+
export type KeyProfile = (typeof KeyProfile)[keyof typeof KeyProfile];
|
|
51
|
+
|
|
52
|
+
export type KeyProfileName =
|
|
53
|
+
| 'ks'
|
|
54
|
+
| 'krumhansl'
|
|
55
|
+
| 'temperley'
|
|
56
|
+
| 'shaath'
|
|
57
|
+
| 'keyfinder'
|
|
58
|
+
| 'faraldo-edmt'
|
|
59
|
+
| 'edmt'
|
|
60
|
+
| 'faraldo-edma'
|
|
61
|
+
| 'edma'
|
|
62
|
+
| 'faraldo-edmm'
|
|
63
|
+
| 'edmm'
|
|
64
|
+
| 'bellman-budge'
|
|
65
|
+
| 'bellman';
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Chord quality
|
|
69
|
+
*/
|
|
70
|
+
export const ChordQuality = {
|
|
71
|
+
Major: 0,
|
|
72
|
+
Minor: 1,
|
|
73
|
+
Diminished: 2,
|
|
74
|
+
Augmented: 3,
|
|
75
|
+
Dominant7: 4,
|
|
76
|
+
Major7: 5,
|
|
77
|
+
Minor7: 6,
|
|
78
|
+
Sus2: 7,
|
|
79
|
+
Sus4: 8,
|
|
80
|
+
Unknown: 9,
|
|
81
|
+
Add9: 10,
|
|
82
|
+
MinorAdd9: 11,
|
|
83
|
+
Dim7: 12,
|
|
84
|
+
HalfDim7: 13,
|
|
85
|
+
Major9: 14,
|
|
86
|
+
Dominant9: 15,
|
|
87
|
+
Sus2Add4: 16,
|
|
88
|
+
} as const;
|
|
89
|
+
|
|
90
|
+
export type ChordQuality = (typeof ChordQuality)[keyof typeof ChordQuality];
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Section type
|
|
94
|
+
*/
|
|
95
|
+
export const SectionType = {
|
|
96
|
+
Intro: 0,
|
|
97
|
+
Verse: 1,
|
|
98
|
+
PreChorus: 2,
|
|
99
|
+
Chorus: 3,
|
|
100
|
+
Bridge: 4,
|
|
101
|
+
Instrumental: 5,
|
|
102
|
+
Outro: 6,
|
|
103
|
+
Unknown: 7,
|
|
104
|
+
} as const;
|
|
105
|
+
|
|
106
|
+
export type SectionType = (typeof SectionType)[keyof typeof SectionType];
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Detected musical key
|
|
110
|
+
*/
|
|
111
|
+
export interface Key {
|
|
112
|
+
root: PitchClass;
|
|
113
|
+
mode: Mode;
|
|
114
|
+
confidence: number;
|
|
115
|
+
name: string;
|
|
116
|
+
shortName: string;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface KeyDetectionOptions extends ValidateOptions {
|
|
120
|
+
nFft?: number;
|
|
121
|
+
hopLength?: number;
|
|
122
|
+
useHpss?: boolean;
|
|
123
|
+
loudnessWeighted?: boolean;
|
|
124
|
+
highPassHz?: number;
|
|
125
|
+
modes?:
|
|
126
|
+
| Mode[]
|
|
127
|
+
| ('major' | 'minor' | 'dorian' | 'phrygian' | 'lydian' | 'mixolydian' | 'locrian')[]
|
|
128
|
+
| 'major-minor'
|
|
129
|
+
| 'all'
|
|
130
|
+
| 'modal';
|
|
131
|
+
profile?: KeyProfile | KeyProfileName;
|
|
132
|
+
genreHint?: 'auto' | 'edm' | 'electronic' | 'dance' | 'pop' | 'classical' | 'jazz' | string;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface KeyCandidate {
|
|
136
|
+
key: Key;
|
|
137
|
+
correlation: number;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface ChordDetectionOptions extends ValidateOptions {
|
|
141
|
+
minDuration?: number;
|
|
142
|
+
smoothingWindow?: number;
|
|
143
|
+
threshold?: number;
|
|
144
|
+
useTriadsOnly?: boolean;
|
|
145
|
+
nFft?: number;
|
|
146
|
+
hopLength?: number;
|
|
147
|
+
useBeatSync?: boolean;
|
|
148
|
+
useHmm?: boolean;
|
|
149
|
+
hmmBeamWidth?: number;
|
|
150
|
+
useKeyContext?: boolean;
|
|
151
|
+
keyRoot?: PitchClass;
|
|
152
|
+
keyMode?: Mode;
|
|
153
|
+
detectInversions?: boolean;
|
|
154
|
+
chromaMethod?: 'stft' | 'nnls';
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Options for `analyzeBpm`. All fields are optional. */
|
|
158
|
+
export interface AnalyzeBpmOptions extends ValidateOptions {
|
|
159
|
+
/** Lowest BPM to consider. Default 30. */
|
|
160
|
+
bpmMin?: number;
|
|
161
|
+
/** Highest BPM to consider. Default 300. */
|
|
162
|
+
bpmMax?: number;
|
|
163
|
+
/** Tempo prior the tracker is biased toward. Default 120. */
|
|
164
|
+
startBpm?: number;
|
|
165
|
+
/** FFT size for the onset envelope. Default 2048. */
|
|
166
|
+
nFft?: number;
|
|
167
|
+
/** Hop length for the onset envelope. Default 512. */
|
|
168
|
+
hopLength?: number;
|
|
169
|
+
/** Number of tempo candidates to return. Default 5. */
|
|
170
|
+
maxCandidates?: number;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** Options for `analyzeRhythm`. All fields are optional. */
|
|
174
|
+
export interface AnalyzeRhythmOptions extends ValidateOptions {
|
|
175
|
+
/** Lowest BPM to consider. Default 60. */
|
|
176
|
+
bpmMin?: number;
|
|
177
|
+
/** Highest BPM to consider. Default 200. */
|
|
178
|
+
bpmMax?: number;
|
|
179
|
+
/** Tempo prior the tracker is biased toward. Default 120. */
|
|
180
|
+
startBpm?: number;
|
|
181
|
+
/** FFT size for the onset envelope. Default 2048. */
|
|
182
|
+
nFft?: number;
|
|
183
|
+
/** Hop length for the onset envelope. Default 512. */
|
|
184
|
+
hopLength?: number;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** Options for `analyzeDynamics`. All fields are optional. */
|
|
188
|
+
export interface AnalyzeDynamicsOptions extends ValidateOptions {
|
|
189
|
+
/** Loudness-curve window length in seconds. Default 0.4. */
|
|
190
|
+
windowSec?: number;
|
|
191
|
+
/** Hop length for the loudness curve. Default 512. */
|
|
192
|
+
hopLength?: number;
|
|
193
|
+
/** Crest-factor (dB) below which the signal is flagged as compressed. Default 6. */
|
|
194
|
+
compressionThreshold?: number;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** Options for `analyzeTimbre`. All fields are optional. */
|
|
198
|
+
export interface AnalyzeTimbreOptions extends ValidateOptions {
|
|
199
|
+
/** FFT size. Default 2048. */
|
|
200
|
+
nFft?: number;
|
|
201
|
+
/** Hop length. Default 512. */
|
|
202
|
+
hopLength?: number;
|
|
203
|
+
/** Number of Mel bands. Default 128. */
|
|
204
|
+
nMels?: number;
|
|
205
|
+
/** Number of MFCCs. Default 13. */
|
|
206
|
+
nMfcc?: number;
|
|
207
|
+
/** Per-window analysis length in seconds. Default 0.5. */
|
|
208
|
+
windowSec?: number;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** Options for `analyzeSections`. All fields are optional. */
|
|
212
|
+
export interface AnalyzeSectionsOptions {
|
|
213
|
+
/** FFT size. Default 2048. */
|
|
214
|
+
nFft?: number;
|
|
215
|
+
/** Hop length. Default 512. */
|
|
216
|
+
hopLength?: number;
|
|
217
|
+
/** Minimum section duration in seconds. Default 4. */
|
|
218
|
+
minSectionSec?: number;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Detected beat
|
|
223
|
+
*/
|
|
224
|
+
export interface Beat {
|
|
225
|
+
time: number;
|
|
226
|
+
strength: number;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Detected chord
|
|
231
|
+
*/
|
|
232
|
+
export interface Chord {
|
|
233
|
+
root: PitchClass;
|
|
234
|
+
bass: PitchClass;
|
|
235
|
+
quality: ChordQuality;
|
|
236
|
+
start: number;
|
|
237
|
+
end: number;
|
|
238
|
+
confidence: number;
|
|
239
|
+
name: string;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export interface ChordAnalysisResult {
|
|
243
|
+
chords: Chord[];
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Detected section
|
|
248
|
+
*/
|
|
249
|
+
export interface Section {
|
|
250
|
+
type: SectionType;
|
|
251
|
+
start: number;
|
|
252
|
+
end: number;
|
|
253
|
+
energyLevel: number;
|
|
254
|
+
confidence: number;
|
|
255
|
+
name: string;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* A single melody contour point (mirrors the C `SonareMelodyPoint`).
|
|
260
|
+
*/
|
|
261
|
+
export interface MelodyPoint {
|
|
262
|
+
/** Frame time in seconds. */
|
|
263
|
+
time: number;
|
|
264
|
+
/** Estimated fundamental frequency in Hz (0 when unvoiced). */
|
|
265
|
+
frequency: number;
|
|
266
|
+
/** Voicing confidence in `[0, 1]`. */
|
|
267
|
+
confidence: number;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Melody analysis result (mirrors the C `SonareMelodyResult`).
|
|
272
|
+
*/
|
|
273
|
+
export interface MelodyResult {
|
|
274
|
+
points: MelodyPoint[];
|
|
275
|
+
pitchRangeOctaves: number;
|
|
276
|
+
pitchStability: number;
|
|
277
|
+
meanFrequency: number;
|
|
278
|
+
vibratoRate: number;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Timbre characteristics
|
|
283
|
+
*/
|
|
284
|
+
export interface Timbre {
|
|
285
|
+
brightness: number;
|
|
286
|
+
warmth: number;
|
|
287
|
+
density: number;
|
|
288
|
+
roughness: number;
|
|
289
|
+
complexity: number;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Dynamics characteristics
|
|
294
|
+
*/
|
|
295
|
+
export interface Dynamics {
|
|
296
|
+
dynamicRangeDb: number;
|
|
297
|
+
peakDb: number;
|
|
298
|
+
rmsDb: number;
|
|
299
|
+
loudnessRangeDb: number;
|
|
300
|
+
crestFactor: number;
|
|
301
|
+
isCompressed: boolean;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Time signature
|
|
306
|
+
*/
|
|
307
|
+
export interface TimeSignature {
|
|
308
|
+
numerator: number;
|
|
309
|
+
denominator: number;
|
|
310
|
+
confidence: number;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Rhythm features
|
|
315
|
+
*/
|
|
316
|
+
export interface RhythmFeatures {
|
|
317
|
+
syncopation: number;
|
|
318
|
+
grooveType: string;
|
|
319
|
+
patternRegularity: number;
|
|
320
|
+
tempoStability: number;
|
|
321
|
+
timeSignature: TimeSignature;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Melody contour from the unified analysis (pitch trajectory + summary stats).
|
|
326
|
+
*/
|
|
327
|
+
export interface MelodyContour {
|
|
328
|
+
pitchRangeOctaves: number;
|
|
329
|
+
pitchStability: number;
|
|
330
|
+
meanFrequency: number;
|
|
331
|
+
vibratoRate: number;
|
|
332
|
+
pitches: MelodyPoint[];
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Complete analysis result
|
|
337
|
+
*/
|
|
338
|
+
export interface AnalysisResult {
|
|
339
|
+
bpm: number;
|
|
340
|
+
bpmConfidence: number;
|
|
341
|
+
key: Key;
|
|
342
|
+
timeSignature: TimeSignature;
|
|
343
|
+
beatTimes: Float32Array;
|
|
344
|
+
beats: Beat[];
|
|
345
|
+
chords: Chord[];
|
|
346
|
+
sections: Section[];
|
|
347
|
+
timbre: Timbre;
|
|
348
|
+
dynamics: Dynamics;
|
|
349
|
+
rhythm: RhythmFeatures;
|
|
350
|
+
melody: MelodyContour;
|
|
351
|
+
form: string;
|
|
352
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Realtime equalizer spectrum snapshot.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the C++ `EqualizerSpectrumSnapshot`: `preLeft`/`preRight` and
|
|
5
|
+
* `postLeft`/`postRight` are the pre- and post-EQ spectrum streams (trimmed to
|
|
6
|
+
* their valid count). `bandGainDb` holds per-band applied gain (24 entries),
|
|
7
|
+
* `profileDb` the smoothed magnitude profile (16 entries), `lastAutoGainDb`
|
|
8
|
+
* the latest auto-gain compensation, and `seq` increments each time a new
|
|
9
|
+
* snapshot is published.
|
|
10
|
+
*/
|
|
11
|
+
export interface EqSpectrumSnapshot {
|
|
12
|
+
preLeft: Float32Array;
|
|
13
|
+
preRight: Float32Array;
|
|
14
|
+
postLeft: Float32Array;
|
|
15
|
+
postRight: Float32Array;
|
|
16
|
+
bandGainDb: Float32Array;
|
|
17
|
+
profileDb: Float32Array;
|
|
18
|
+
lastAutoGainDb: number;
|
|
19
|
+
seq: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Equalizer band type (string union mirroring `sonare::mastering::eq::EqBandType`).
|
|
24
|
+
*/
|
|
25
|
+
export type EqBandType =
|
|
26
|
+
| 'Peak'
|
|
27
|
+
| 'LowShelf'
|
|
28
|
+
| 'HighShelf'
|
|
29
|
+
| 'LowPass'
|
|
30
|
+
| 'HighPass'
|
|
31
|
+
| 'BandPass'
|
|
32
|
+
| 'Notch'
|
|
33
|
+
| 'TiltShelf'
|
|
34
|
+
| 'FlatTilt';
|
|
35
|
+
|
|
36
|
+
/** Biquad coefficient design mode. */
|
|
37
|
+
export type EqCoeffMode = 'Rbj' | 'Vicanek';
|
|
38
|
+
|
|
39
|
+
/** Stereo placement for an EQ band. */
|
|
40
|
+
export type EqStereoPlacement = 'Stereo' | 'Left' | 'Right' | 'Mid' | 'Side';
|
|
41
|
+
|
|
42
|
+
/** Per-band phase behaviour. */
|
|
43
|
+
export type EqBandPhase = 'Inherit' | 'ZeroLatency' | 'NaturalPhase' | 'LinearPhase';
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Equalizer band configuration accepted by {@link StreamingEqualizer.setBand}.
|
|
47
|
+
*
|
|
48
|
+
* All fields are optional; omitted values fall back to the C++ band defaults
|
|
49
|
+
* (Peak, 1000 Hz, 0 dB gain, Butterworth Q, disabled).
|
|
50
|
+
*/
|
|
51
|
+
export interface EqBand {
|
|
52
|
+
type?: EqBandType;
|
|
53
|
+
frequencyHz?: number;
|
|
54
|
+
gainDb?: number;
|
|
55
|
+
q?: number;
|
|
56
|
+
enabled?: boolean;
|
|
57
|
+
coeffMode?: EqCoeffMode;
|
|
58
|
+
slopeDbOct?: number;
|
|
59
|
+
placement?: EqStereoPlacement;
|
|
60
|
+
phase?: EqBandPhase;
|
|
61
|
+
soloed?: boolean;
|
|
62
|
+
bypassed?: boolean;
|
|
63
|
+
proportionalQ?: boolean;
|
|
64
|
+
proportionalQStrength?: number;
|
|
65
|
+
dynamic?: boolean;
|
|
66
|
+
thresholdDb?: number;
|
|
67
|
+
autoThreshold?: boolean;
|
|
68
|
+
ratio?: number;
|
|
69
|
+
rangeDb?: number;
|
|
70
|
+
attackMs?: number;
|
|
71
|
+
releaseMs?: number;
|
|
72
|
+
lookaheadMs?: number;
|
|
73
|
+
externalSidechain?: boolean;
|
|
74
|
+
sidechainFreqHz?: number;
|
|
75
|
+
sidechainQ?: number;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Construction options for {@link StreamingEqualizer}. */
|
|
79
|
+
export interface StreamingEqualizerConfig {
|
|
80
|
+
sampleRate?: number;
|
|
81
|
+
maxBlockSize?: number;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Configuration for {@link StreamingRetune}. */
|
|
85
|
+
export interface StreamingRetuneConfig {
|
|
86
|
+
/** Pitch shift in semitones, clamped by the native processor to +/-24. */
|
|
87
|
+
semitones?: number;
|
|
88
|
+
/** Wet/dry mix, clamped by the native processor to 0..1. */
|
|
89
|
+
mix?: number;
|
|
90
|
+
/** Grain size in samples. Use 0/omit to derive it from the sample rate. */
|
|
91
|
+
grainSize?: number;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Options for {@link StreamingEqualizer.match}. */
|
|
95
|
+
export interface EqMatchOptions {
|
|
96
|
+
sampleRate?: number;
|
|
97
|
+
maxBands?: number;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export type VoicePresetId =
|
|
101
|
+
| 'neutral-monitor'
|
|
102
|
+
| 'bright-idol'
|
|
103
|
+
| 'soft-whisper'
|
|
104
|
+
| 'deep-narrator'
|
|
105
|
+
| 'robot-mascot'
|
|
106
|
+
| 'dark-villain';
|
|
107
|
+
|
|
108
|
+
export interface RealtimeVoiceChangerPreset {
|
|
109
|
+
schemaVersion: 1;
|
|
110
|
+
id?: string;
|
|
111
|
+
name?: string;
|
|
112
|
+
description?: string;
|
|
113
|
+
macros?: Record<string, number>;
|
|
114
|
+
dsp?: Record<string, unknown>;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export type RealtimeVoiceChangerConfigInput = VoicePresetId | RealtimeVoiceChangerPreset;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Flat (POD) realtime voice-changer configuration. Keys are camelCase to match
|
|
121
|
+
* the Node addon getter, so a preset config reads identically across both JS
|
|
122
|
+
* surfaces (the underlying C ABI / Python POD uses the snake_case equivalents).
|
|
123
|
+
*/
|
|
124
|
+
export interface RealtimeVoiceChangerPodConfig {
|
|
125
|
+
inputGainDb: number;
|
|
126
|
+
outputGainDb: number;
|
|
127
|
+
wetMix: number;
|
|
128
|
+
retuneSemitones: number;
|
|
129
|
+
retuneMix: number;
|
|
130
|
+
retuneGrainSize: number;
|
|
131
|
+
formantFactor: number;
|
|
132
|
+
formantAmount: number;
|
|
133
|
+
formantBody: number;
|
|
134
|
+
formantBrightness: number;
|
|
135
|
+
formantNasal: number;
|
|
136
|
+
eqHighpassHz: number;
|
|
137
|
+
eqBodyDb: number;
|
|
138
|
+
eqPresenceDb: number;
|
|
139
|
+
eqAirDb: number;
|
|
140
|
+
gateThresholdDb: number;
|
|
141
|
+
gateAttackMs: number;
|
|
142
|
+
gateReleaseMs: number;
|
|
143
|
+
gateRangeDb: number;
|
|
144
|
+
compressorThresholdDb: number;
|
|
145
|
+
compressorRatio: number;
|
|
146
|
+
compressorAttackMs: number;
|
|
147
|
+
compressorReleaseMs: number;
|
|
148
|
+
compressorMakeupGainDb: number;
|
|
149
|
+
deesserFrequencyHz: number;
|
|
150
|
+
deesserThresholdDb: number;
|
|
151
|
+
deesserRatio: number;
|
|
152
|
+
deesserRangeDb: number;
|
|
153
|
+
reverbMix: number;
|
|
154
|
+
reverbTimeMs: number;
|
|
155
|
+
reverbDamping: number;
|
|
156
|
+
reverbSeed: number;
|
|
157
|
+
limiterCeilingDb: number;
|
|
158
|
+
limiterReleaseMs: number;
|
|
159
|
+
/** Non-zero enables the 4x-oversampled inter-sample-peak limiter (default enabled). */
|
|
160
|
+
limiterEnableIspLimiter: boolean;
|
|
161
|
+
/** True-peak ceiling in dBTP applied by the ISP limiter (default -1.0). */
|
|
162
|
+
limiterIspCeilingDbtp: number;
|
|
163
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import type { ValidateOptions } from './validation';
|
|
2
|
+
|
|
3
|
+
/** Options for `pitchCorrectTimevarying`. All fields are optional. */
|
|
4
|
+
export interface PitchCorrectOptions extends ValidateOptions {
|
|
5
|
+
/** `'midi'` retunes toward `targetMidi`; `'scale'` snaps to the key. Default `'midi'`. */
|
|
6
|
+
mode?: 'midi' | 'scale';
|
|
7
|
+
/** Fixed target note when `mode` is `'midi'`, in `[0, 127]`. Default 69 (A4). */
|
|
8
|
+
targetMidi?: number;
|
|
9
|
+
/** Scale root pitch class (0=C .. 11=B) when `mode` is `'scale'`. Default 0. */
|
|
10
|
+
scaleRoot?: number;
|
|
11
|
+
/** 12-bit degree mask, bit `i` = semitone `i` above the root enabled. Default C major. */
|
|
12
|
+
scaleModeMask?: number;
|
|
13
|
+
/** Reference MIDI anchoring the scale grid. Default 69 (A4). */
|
|
14
|
+
referenceMidi?: number;
|
|
15
|
+
/** Correction strength in `[0, 1]`; 1 = full snap, 0 = bypass. Default 1. */
|
|
16
|
+
retuneAmount?: number;
|
|
17
|
+
/** Hard clamp on per-frame correction magnitude (semitones). Default 12. */
|
|
18
|
+
maxCorrectionSemitones?: number;
|
|
19
|
+
/** Retune IIR time constant (ms); larger = slower glide. Default 50. */
|
|
20
|
+
retuneSpeedMs?: number;
|
|
21
|
+
/** Corrections below this are bypassed to preserve vibrato (cents). Default 20. */
|
|
22
|
+
vibratoThresholdCents?: number;
|
|
23
|
+
/** Per-frame voiced flags (non-zero = voiced); omit to treat all frames as voiced. */
|
|
24
|
+
voiced?: Int32Array;
|
|
25
|
+
/** Per-frame voicing probability in `[0, 1]`; omit to derive from `voiced`. */
|
|
26
|
+
voicedProb?: Float32Array;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Options for `noteStretch`. All fields are optional. */
|
|
30
|
+
export interface NoteStretchOptions {
|
|
31
|
+
/** Note onset position in samples (selects the region). Default 0. */
|
|
32
|
+
onsetSample?: number;
|
|
33
|
+
/** Note offset position in samples (selects the region). Default 0. */
|
|
34
|
+
offsetSample?: number;
|
|
35
|
+
/** Stretch ratio (0.5 = double duration, 2.0 = half duration). Default 1. */
|
|
36
|
+
stretchRatio?: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** How a `spectralEdit` region op modifies the masked bins. */
|
|
40
|
+
export type SpectralEditMode = 'gain' | 'attenuate' | 'mute' | 'heal';
|
|
41
|
+
|
|
42
|
+
/** Analysis/synthesis window used by `spectralEdit`. */
|
|
43
|
+
export type SpectralEditWindow = 'hann' | 'hamming' | 'blackman' | 'rectangular';
|
|
44
|
+
|
|
45
|
+
/** One time x frequency rectangle edit op for `spectralEdit`. */
|
|
46
|
+
export interface SpectralRegionOp {
|
|
47
|
+
/** Region time start (input samples); clamped to [0, length]. Default 0. */
|
|
48
|
+
startSample?: number;
|
|
49
|
+
/** Region time end, exclusive (input samples); clamped to [0, length]. Default = signal length. */
|
|
50
|
+
endSample?: number;
|
|
51
|
+
/** Region frequency low edge in Hz; clamped to [0, nyquist]. Default 0. */
|
|
52
|
+
lowHz?: number;
|
|
53
|
+
/** Region frequency high edge in Hz; <=0 or >= nyquist means nyquist. Default 0. */
|
|
54
|
+
highHz?: number;
|
|
55
|
+
/** Linear gain in dB for 'gain'/'attenuate'; ignored by 'mute'/'heal'. Default 0. */
|
|
56
|
+
gainDb?: number;
|
|
57
|
+
/** Edit mode. Default 'gain'. */
|
|
58
|
+
mode?: SpectralEditMode;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** STFT + heal parameters for `spectralEdit`. All fields are optional. */
|
|
62
|
+
export interface SpectralEditOptions {
|
|
63
|
+
/** FFT size; must be a power of two (>= 2). Default 2048. */
|
|
64
|
+
nFft?: number;
|
|
65
|
+
/** Hop length; must satisfy 0 < hop <= nFft/2. Default 512. */
|
|
66
|
+
hopLength?: number;
|
|
67
|
+
/** Analysis + synthesis window. Default 'hann'. */
|
|
68
|
+
window?: SpectralEditWindow;
|
|
69
|
+
/** Neighbour frames each side used by 'heal' (>= 1). Default 2. */
|
|
70
|
+
healRadiusFrames?: number;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Constant-Q / Variable-Q transform magnitude result (mirrors the C
|
|
75
|
+
* `SonareCqtResult`).
|
|
76
|
+
*/
|
|
77
|
+
export interface CqtResult {
|
|
78
|
+
/** Number of frequency bins. */
|
|
79
|
+
nBins: number;
|
|
80
|
+
/** Number of time frames. */
|
|
81
|
+
nFrames: number;
|
|
82
|
+
/** Hop length in samples. */
|
|
83
|
+
hopLength: number;
|
|
84
|
+
/** Sample rate in Hz. */
|
|
85
|
+
sampleRate: number;
|
|
86
|
+
/** Row-major `[nBins x nFrames]` magnitude matrix. */
|
|
87
|
+
magnitude: Float32Array;
|
|
88
|
+
/** Center frequency (Hz) of each of the `nBins` bins. */
|
|
89
|
+
frequencies: Float32Array;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Multi-band onset strength matrix result.
|
|
94
|
+
*/
|
|
95
|
+
export interface OnsetStrengthMultiResult {
|
|
96
|
+
nBands: number;
|
|
97
|
+
nFrames: number;
|
|
98
|
+
data: Float32Array;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* STFT (Short-Time Fourier Transform) result
|
|
103
|
+
*/
|
|
104
|
+
export interface StftResult {
|
|
105
|
+
nBins: number;
|
|
106
|
+
nFrames: number;
|
|
107
|
+
nFft: number;
|
|
108
|
+
hopLength: number;
|
|
109
|
+
sampleRate: number;
|
|
110
|
+
magnitude: Float32Array;
|
|
111
|
+
power: Float32Array;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Mel spectrogram result
|
|
116
|
+
*/
|
|
117
|
+
export interface MelSpectrogramResult {
|
|
118
|
+
nMels: number;
|
|
119
|
+
nFrames: number;
|
|
120
|
+
sampleRate: number;
|
|
121
|
+
hopLength: number;
|
|
122
|
+
power: Float32Array;
|
|
123
|
+
db: Float32Array;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* MFCC result
|
|
128
|
+
*/
|
|
129
|
+
export interface MfccResult {
|
|
130
|
+
nMfcc: number;
|
|
131
|
+
nFrames: number;
|
|
132
|
+
coefficients: Float32Array;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* STFT power spectrogram result (from inverse Mel reconstruction)
|
|
137
|
+
*/
|
|
138
|
+
export interface StftPowerResult {
|
|
139
|
+
nBins: number;
|
|
140
|
+
nFrames: number;
|
|
141
|
+
power: Float32Array;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Mel power spectrogram result (from inverse MFCC reconstruction)
|
|
146
|
+
*/
|
|
147
|
+
export interface MelPowerResult {
|
|
148
|
+
nMels: number;
|
|
149
|
+
nFrames: number;
|
|
150
|
+
power: Float32Array;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Chroma features result
|
|
155
|
+
*/
|
|
156
|
+
export interface ChromaResult {
|
|
157
|
+
nChroma: number;
|
|
158
|
+
nFrames: number;
|
|
159
|
+
sampleRate: number;
|
|
160
|
+
hopLength: number;
|
|
161
|
+
features: Float32Array;
|
|
162
|
+
meanEnergy: number[];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Pitch detection result
|
|
167
|
+
*/
|
|
168
|
+
export interface PitchResult {
|
|
169
|
+
f0: Float32Array;
|
|
170
|
+
voicedProb: Float32Array;
|
|
171
|
+
voicedFlag: boolean[];
|
|
172
|
+
nFrames: number;
|
|
173
|
+
medianF0: number;
|
|
174
|
+
meanF0: number;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Loudness measurement result (EBU R128 / ITU-R BS.1770)
|
|
179
|
+
*/
|
|
180
|
+
export interface LufsResult {
|
|
181
|
+
integratedLufs: number;
|
|
182
|
+
momentaryLufs: number;
|
|
183
|
+
shortTermLufs: number;
|
|
184
|
+
loudnessRange: number;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* HPSS (Harmonic-Percussive Source Separation) result
|
|
189
|
+
*/
|
|
190
|
+
export interface HpssResult {
|
|
191
|
+
harmonic: Float32Array;
|
|
192
|
+
percussive: Float32Array;
|
|
193
|
+
sampleRate: number;
|
|
194
|
+
}
|