@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
package/src/effects_mastering.ts
CHANGED
|
@@ -1,1089 +1,85 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Time-stretch audio without changing pitch.
|
|
89
|
-
*
|
|
90
|
-
* @param samples - Audio samples (mono, float32)
|
|
91
|
-
* @param sampleRate - Sample rate in Hz
|
|
92
|
-
* @param rate - Time stretch rate (0.5 = double duration, 2.0 = half duration)
|
|
93
|
-
* @returns Time-stretched audio
|
|
94
|
-
*/
|
|
95
|
-
export function timeStretch(
|
|
96
|
-
samples: Float32Array,
|
|
97
|
-
sampleRate: number,
|
|
98
|
-
rate: number,
|
|
99
|
-
options: ValidateOptions = {},
|
|
100
|
-
): Float32Array {
|
|
101
|
-
assertSamples('timeStretch', samples, options.validate !== false);
|
|
102
|
-
return requireModule().timeStretch(samples, sampleRate, rate);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Pitch-shift audio without changing duration.
|
|
107
|
-
*
|
|
108
|
-
* @param samples - Audio samples (mono, float32)
|
|
109
|
-
* @param sampleRate - Sample rate in Hz
|
|
110
|
-
* @param semitones - Pitch shift in semitones (+12 = one octave up, -12 = one octave down)
|
|
111
|
-
* @returns Pitch-shifted audio
|
|
112
|
-
*/
|
|
113
|
-
export function pitchShift(
|
|
114
|
-
samples: Float32Array,
|
|
115
|
-
sampleRate: number,
|
|
116
|
-
semitones: number,
|
|
117
|
-
options: ValidateOptions = {},
|
|
118
|
-
): Float32Array {
|
|
119
|
-
assertSamples('pitchShift', samples, options.validate !== false);
|
|
120
|
-
return requireModule().pitchShift(samples, sampleRate, semitones);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Pitch-correct audio from a current MIDI note to a target MIDI note.
|
|
125
|
-
*
|
|
126
|
-
* @param samples - Audio samples (mono, float32)
|
|
127
|
-
* @param sampleRate - Sample rate in Hz
|
|
128
|
-
* @param currentMidi - Detected/current MIDI note number
|
|
129
|
-
* @param targetMidi - Desired MIDI note number
|
|
130
|
-
* @returns Pitch-corrected audio
|
|
131
|
-
*/
|
|
132
|
-
export function pitchCorrectToMidi(
|
|
133
|
-
samples: Float32Array,
|
|
134
|
-
sampleRate = 22050,
|
|
135
|
-
currentMidi = 69.0,
|
|
136
|
-
targetMidi = 69.0,
|
|
137
|
-
options: ValidateOptions = {},
|
|
138
|
-
): Float32Array {
|
|
139
|
-
assertSamples('pitchCorrectToMidi', samples, options.validate !== false);
|
|
140
|
-
return requireModule().pitchCorrectToMidi(samples, sampleRate, currentMidi, targetMidi);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Contour-following ("time-varying") pitch correction toward a MIDI target.
|
|
145
|
-
*
|
|
146
|
-
* Unlike {@link pitchCorrectToMidi} (a single constant transpose), this follows
|
|
147
|
-
* the caller-supplied per-frame `f0Hz` contour and retunes every voiced frame
|
|
148
|
-
* toward `targetMidi`, so vibrato/drift in the source is tracked rather than
|
|
149
|
-
* flattened. `voiced` (non-zero = voiced) and `voicedProb` ([0,1]) are optional;
|
|
150
|
-
* omitting them treats every frame as voiced.
|
|
151
|
-
*
|
|
152
|
-
* @param samples - Audio samples (mono, float32)
|
|
153
|
-
* @param f0Hz - Per-frame measured F0 in Hz (one entry per analysis frame)
|
|
154
|
-
* @param targetMidi - Desired MIDI note number
|
|
155
|
-
* @param sampleRate - Sample rate in Hz
|
|
156
|
-
* @param hopLength - F0 hop in samples (frame i covers sample i*hopLength)
|
|
157
|
-
* @param voiced - Optional per-frame voiced flags (non-zero = voiced)
|
|
158
|
-
* @param voicedProb - Optional per-frame voicing probability in [0, 1]
|
|
159
|
-
* @returns Pitch-corrected audio
|
|
160
|
-
*/
|
|
161
|
-
export function pitchCorrectToMidiTimevarying(
|
|
162
|
-
samples: Float32Array,
|
|
163
|
-
f0Hz: Float32Array,
|
|
164
|
-
targetMidi: number,
|
|
165
|
-
sampleRate = 22050,
|
|
166
|
-
hopLength = 512,
|
|
167
|
-
voiced?: Int32Array,
|
|
168
|
-
voicedProb?: Float32Array,
|
|
169
|
-
options: ValidateOptions = {},
|
|
170
|
-
): Float32Array {
|
|
171
|
-
assertSamples('pitchCorrectToMidiTimevarying', samples, options.validate !== false);
|
|
172
|
-
if (voiced && voiced.length !== f0Hz.length) {
|
|
173
|
-
throw new RangeError('pitchCorrectToMidiTimevarying: voiced length must match f0Hz length');
|
|
174
|
-
}
|
|
175
|
-
if (voicedProb && voicedProb.length !== f0Hz.length) {
|
|
176
|
-
throw new RangeError('pitchCorrectToMidiTimevarying: voicedProb length must match f0Hz length');
|
|
177
|
-
}
|
|
178
|
-
// The embind layer reads the companion arrays as Float32Array (voiced uses
|
|
179
|
-
// 0.0/1.0); convert here so a single native conversion path suffices.
|
|
180
|
-
const voicedF32 = voiced ? Float32Array.from(voiced) : undefined;
|
|
181
|
-
return requireModule().pitchCorrectToMidiTimevarying(
|
|
182
|
-
samples,
|
|
183
|
-
sampleRate,
|
|
184
|
-
f0Hz,
|
|
185
|
-
targetMidi,
|
|
186
|
-
hopLength,
|
|
187
|
-
voicedF32,
|
|
188
|
-
voicedProb,
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Time-stretch a note region between two sample offsets without changing pitch.
|
|
194
|
-
*
|
|
195
|
-
* @param samples - Audio samples (mono, float32)
|
|
196
|
-
* @param sampleRate - Sample rate in Hz
|
|
197
|
-
* @param onsetSample - Note onset position in samples
|
|
198
|
-
* @param offsetSample - Note offset position in samples
|
|
199
|
-
* @param stretchRatio - Stretch ratio (0.5 = double duration, 2.0 = half duration)
|
|
200
|
-
* @returns Audio with the note region stretched
|
|
201
|
-
*/
|
|
202
|
-
export function noteStretch(
|
|
203
|
-
samples: Float32Array,
|
|
204
|
-
sampleRate = 22050,
|
|
205
|
-
options: NoteStretchOptions & ValidateOptions = {},
|
|
206
|
-
): Float32Array {
|
|
207
|
-
assertSamples('noteStretch', samples, options.validate !== false);
|
|
208
|
-
return requireModule().noteStretch(
|
|
209
|
-
samples,
|
|
210
|
-
sampleRate,
|
|
211
|
-
options.onsetSample ?? 0,
|
|
212
|
-
options.offsetSample ?? 0,
|
|
213
|
-
options.stretchRatio ?? 1.0,
|
|
214
|
-
);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/** Options for {@link voiceChange}. All fields are optional. */
|
|
218
|
-
export interface VoiceChangeOptions extends ValidateOptions {
|
|
219
|
-
/** Pitch shift in semitones (negative = down). Default 0. */
|
|
220
|
-
pitchSemitones?: number;
|
|
221
|
-
/** Formant scale factor (>1 brightens, <1 darkens). Default 1. */
|
|
222
|
-
formantFactor?: number;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Apply a voice change by shifting pitch and formants independently.
|
|
227
|
-
*
|
|
228
|
-
* @param samples - Audio samples (mono, float32)
|
|
229
|
-
* @param sampleRate - Sample rate in Hz
|
|
230
|
-
* @param options - Pitch/formant settings ({@link VoiceChangeOptions})
|
|
231
|
-
* @returns Voice-changed audio
|
|
232
|
-
*/
|
|
233
|
-
export function voiceChange(
|
|
234
|
-
samples: Float32Array,
|
|
235
|
-
sampleRate = 22050,
|
|
236
|
-
options: VoiceChangeOptions = {},
|
|
237
|
-
): Float32Array {
|
|
238
|
-
assertSamples('voiceChange', samples, options.validate !== false);
|
|
239
|
-
return requireModule().voiceChange(
|
|
240
|
-
samples,
|
|
241
|
-
sampleRate,
|
|
242
|
-
options.pitchSemitones ?? 0.0,
|
|
243
|
-
options.formantFactor ?? 1.0,
|
|
244
|
-
);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
/** Options for the offline {@link voiceChangeRealtime} convenience wrapper. */
|
|
248
|
-
export interface VoiceChangeRealtimeOptions extends ValidateOptions {
|
|
249
|
-
sampleRate?: number;
|
|
250
|
-
/** Voice-changer preset id or full config object. */
|
|
251
|
-
preset?: RealtimeVoiceChangerConfigInput;
|
|
252
|
-
/** Channel count (1 = mono, 2 = interleaved stereo). */
|
|
253
|
-
channels?: 1 | 2;
|
|
254
|
-
/** Block size for the internal render loop (default 512). */
|
|
255
|
-
blockSize?: number;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
function latencyCompensatedVoiceChange(
|
|
259
|
-
changer: RealtimeVoiceChanger,
|
|
260
|
-
samples: Float32Array,
|
|
261
|
-
channels: 1 | 2,
|
|
262
|
-
blockFrames: number,
|
|
263
|
-
): Float32Array {
|
|
264
|
-
const latencyFrames = Math.max(0, changer.latencySamples());
|
|
265
|
-
if (channels === 1) {
|
|
266
|
-
const total = samples.length + latencyFrames;
|
|
267
|
-
const input = new Float32Array(total);
|
|
268
|
-
input.set(samples);
|
|
269
|
-
const processed = new Float32Array(total);
|
|
270
|
-
for (let offset = 0; offset < total; offset += blockFrames) {
|
|
271
|
-
const block = input.subarray(offset, Math.min(offset + blockFrames, total));
|
|
272
|
-
processed.set(changer.processMono(block), offset);
|
|
273
|
-
}
|
|
274
|
-
return processed.slice(latencyFrames, latencyFrames + samples.length);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
const frames = samples.length / 2;
|
|
278
|
-
const totalFrames = frames + latencyFrames;
|
|
279
|
-
const input = new Float32Array(totalFrames * 2);
|
|
280
|
-
input.set(samples);
|
|
281
|
-
const processed = new Float32Array(totalFrames * 2);
|
|
282
|
-
const frameStride = blockFrames * 2;
|
|
283
|
-
for (let offset = 0; offset < input.length; offset += frameStride) {
|
|
284
|
-
const block = input.subarray(offset, Math.min(offset + frameStride, input.length));
|
|
285
|
-
processed.set(changer.processInterleaved(block, 2), offset);
|
|
286
|
-
}
|
|
287
|
-
const start = latencyFrames * 2;
|
|
288
|
-
return processed.slice(start, start + samples.length);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* Applies the realtime voice-changer chain to a whole buffer in one call.
|
|
293
|
-
*
|
|
294
|
-
* Constructs and prepares a {@link RealtimeVoiceChanger}, runs the block loop
|
|
295
|
-
* for the caller, then disposes it — matching the Python `voice_change_realtime`
|
|
296
|
-
* and Node `voiceChangeRealtime` convenience wrappers. For mono, `samples` is a
|
|
297
|
-
* plain mono buffer; for stereo, `samples` is interleaved (L0,R0,L1,R1,...).
|
|
298
|
-
*
|
|
299
|
-
* @returns The processed buffer (same layout/length as the input).
|
|
300
|
-
*/
|
|
301
|
-
export function voiceChangeRealtime(
|
|
302
|
-
samples: Float32Array,
|
|
303
|
-
options: VoiceChangeRealtimeOptions = {},
|
|
304
|
-
): Float32Array {
|
|
305
|
-
assertSamples('voiceChangeRealtime', samples, options.validate !== false);
|
|
306
|
-
const channels = options.channels ?? 1;
|
|
307
|
-
if (channels !== 1 && channels !== 2) {
|
|
308
|
-
throw new Error('voiceChangeRealtime: channels must be 1 or 2.');
|
|
309
|
-
}
|
|
310
|
-
if (channels === 2 && samples.length % 2 !== 0) {
|
|
311
|
-
throw new Error('voiceChangeRealtime: stereo input length must be a multiple of 2.');
|
|
312
|
-
}
|
|
313
|
-
// 48000 matches the Python voice_change_realtime and Node voiceChangeRealtime
|
|
314
|
-
// convenience wrappers (and the RealtimeVoiceChanger default).
|
|
315
|
-
const sampleRate = options.sampleRate ?? 48000;
|
|
316
|
-
const blockSize = Math.max(1, Math.floor(options.blockSize ?? 512));
|
|
317
|
-
const changer = new RealtimeVoiceChanger(options.preset ?? 'neutral-monitor');
|
|
318
|
-
try {
|
|
319
|
-
changer.prepare(sampleRate, blockSize, channels);
|
|
320
|
-
return latencyCompensatedVoiceChange(changer, samples, channels, blockSize);
|
|
321
|
-
} finally {
|
|
322
|
-
changer.delete();
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Normalize audio to target peak level.
|
|
328
|
-
*
|
|
329
|
-
* @param samples - Audio samples (mono, float32)
|
|
330
|
-
* @param sampleRate - Sample rate in Hz
|
|
331
|
-
* @param targetDb - Target peak level in dB (default: 0 dB = full scale)
|
|
332
|
-
* @returns Normalized audio
|
|
333
|
-
*/
|
|
334
|
-
export function normalize(
|
|
335
|
-
samples: Float32Array,
|
|
336
|
-
sampleRate: number,
|
|
337
|
-
targetDb = 0.0,
|
|
338
|
-
options: ValidateOptions = {},
|
|
339
|
-
): Float32Array {
|
|
340
|
-
assertSamples('normalize', samples, options.validate !== false);
|
|
341
|
-
return requireModule().normalize(samples, sampleRate, targetDb);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* Apply region-based spectral edits (gain/attenuate/mute/heal) to mono audio.
|
|
346
|
-
*
|
|
347
|
-
* Each op is a time x frequency rectangle applied in array order over a single
|
|
348
|
-
* STFT buffer, so a later op observes the result of earlier ops. The output has
|
|
349
|
-
* the same length and sample rate as the input; an empty `ops` list is an
|
|
350
|
-
* identity transform (within the iSTFT's own tolerance).
|
|
351
|
-
*
|
|
352
|
-
* @param samples - Audio samples (mono, float32)
|
|
353
|
-
* @param sampleRate - Sample rate in Hz
|
|
354
|
-
* @param ops - Region edit ops applied in order ({@link SpectralRegionOp})
|
|
355
|
-
* @param options - STFT + heal configuration ({@link SpectralEditOptions})
|
|
356
|
-
* @returns Edited audio
|
|
357
|
-
*/
|
|
358
|
-
export function spectralEdit(
|
|
359
|
-
samples: Float32Array,
|
|
360
|
-
sampleRate: number,
|
|
361
|
-
ops: SpectralRegionOp[] = [],
|
|
362
|
-
options: SpectralEditOptions & ValidateOptions = {},
|
|
363
|
-
): Float32Array {
|
|
364
|
-
assertSamples('spectralEdit', samples, options.validate !== false);
|
|
365
|
-
assertSampleRate('spectralEdit', sampleRate);
|
|
366
|
-
return requireModule().spectralEdit(samples, sampleRate, ops, options as Record<string, unknown>);
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* Apply mastering loudness normalization with a true-peak ceiling.
|
|
371
|
-
*
|
|
372
|
-
* @param samples - Audio samples (mono, float32)
|
|
373
|
-
* @param sampleRate - Sample rate in Hz (default: 22050)
|
|
374
|
-
* @param options - Loudness/ceiling settings ({@link MasteringOptions})
|
|
375
|
-
* @returns Processed audio and loudness metadata
|
|
376
|
-
*/
|
|
377
|
-
export function mastering(
|
|
378
|
-
samples: Float32Array,
|
|
379
|
-
sampleRate = 22050,
|
|
380
|
-
options: MasteringOptions = {},
|
|
381
|
-
): MasteringResult {
|
|
382
|
-
return requireModule().mastering(
|
|
383
|
-
samples,
|
|
384
|
-
sampleRate,
|
|
385
|
-
options.targetLufs ?? -14.0,
|
|
386
|
-
options.ceilingDb ?? -1.0,
|
|
387
|
-
options.truePeakOversample ?? 4,
|
|
388
|
-
options.releaseMs ?? 0, // 0 => library default (50 ms)
|
|
389
|
-
options.applyGainAtInputRate ?? false,
|
|
390
|
-
);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
export function masteringProcessorNames(): SoloProcessor[] {
|
|
394
|
-
// embind hands back a vector whose constructor is not this realm's Array, so the
|
|
395
|
-
// result is not structured-cloneable (breaks postMessage to a Worker).
|
|
396
|
-
// Array.from() re-roots it as a plain Array. Same for the sibling *Names() below.
|
|
397
|
-
return Array.from(requireModule().masteringProcessorNames()) as SoloProcessor[];
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
/**
|
|
401
|
-
* Names of the insert processors the mastering chain can instantiate by name
|
|
402
|
-
* (`mastering::api::insert_factory_names`). Mirrors the C-ABI
|
|
403
|
-
* `sonare_mastering_insert_names` (which joins this list) as a `string[]`.
|
|
404
|
-
*/
|
|
405
|
-
export function masteringInsertNames(): string[] {
|
|
406
|
-
return (
|
|
407
|
-
requireModule() as unknown as { masteringInsertNames: () => string[] }
|
|
408
|
-
).masteringInsertNames();
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* Returns the camelCase parameter names a given insert / FX processor reads, for
|
|
413
|
-
* tooling/validation. Any key NOT in this list is silently ignored by the
|
|
414
|
-
* processor (and would be reported via {@link Mixer.sceneWarnings} when a scene
|
|
415
|
-
* carrying it is loaded). Band/sub-band processors enumerate their indexed
|
|
416
|
-
* `band{i}.<field>` keys. Returns an empty array for an unknown name (or one
|
|
417
|
-
* whose insert needs an unavailable build feature, e.g. FX).
|
|
418
|
-
*
|
|
419
|
-
* @param name - Insert processor name (see {@link masteringInsertNames}).
|
|
420
|
-
*/
|
|
421
|
-
export function masteringInsertParamNames(name: string): string[] {
|
|
422
|
-
return Array.from(
|
|
423
|
-
(
|
|
424
|
-
requireModule() as unknown as { masteringInsertParamNames: (name: string) => string[] }
|
|
425
|
-
).masteringInsertParamNames(name),
|
|
426
|
-
);
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
/** One realtime-automatable parameter of an insert processor. */
|
|
430
|
-
export interface MasteringInsertParamInfo {
|
|
431
|
-
/** JSON-key parameter name, as used in scene insert params. */
|
|
432
|
-
name: string;
|
|
433
|
-
/** Integer param id for realtime automation lanes / MIDI-CC binding. */
|
|
434
|
-
id: number;
|
|
435
|
-
/** Whether the param can be changed live from the audio thread. */
|
|
436
|
-
rtSafe: boolean;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
/**
|
|
440
|
-
* Returns the realtime-automatable parameter descriptors for an insert / FX
|
|
441
|
-
* processor: each entry maps a JSON-key parameter name to the integer id used by
|
|
442
|
-
* realtime automation and reports whether it is realtime-safe. Unlike
|
|
443
|
-
* {@link masteringInsertParamNames} (every construction key), this lists only the
|
|
444
|
-
* realtime-controllable subset — the keys accepted by
|
|
445
|
-
* {@link RealtimeEngine.setTrackStripInsertParamByName}. Returns an empty array
|
|
446
|
-
* for an unknown name or a processor with no automatable parameters.
|
|
447
|
-
*
|
|
448
|
-
* @param name - Insert processor name (see {@link masteringInsertNames}).
|
|
449
|
-
*/
|
|
450
|
-
export function masteringInsertParamInfo(name: string): MasteringInsertParamInfo[] {
|
|
451
|
-
const json = (
|
|
452
|
-
requireModule() as unknown as { masteringInsertParamInfo: (name: string) => string }
|
|
453
|
-
).masteringInsertParamInfo(name);
|
|
454
|
-
return JSON.parse(json) as MasteringInsertParamInfo[];
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
/**
|
|
458
|
-
* How a processor handles a buffer with more than two channels (a surround
|
|
459
|
-
* bed). "multichannel" processes every plane in one call; "stereoPairOnly"
|
|
460
|
-
* operates on the front L/R pair and passes any surround planes through dry.
|
|
461
|
-
* "perChannel"/"passthrough" are reserved and unused by the current catalog.
|
|
462
|
-
*/
|
|
463
|
-
export type MasteringChannelPolicy =
|
|
464
|
-
| 'multichannel'
|
|
465
|
-
| 'stereoPairOnly'
|
|
466
|
-
| 'perChannel'
|
|
467
|
-
| 'passthrough';
|
|
468
|
-
|
|
469
|
-
/** One processor's realtime/offline/pair classification in the catalog. */
|
|
470
|
-
export interface MasteringProcessorCatalogEntry {
|
|
471
|
-
/** Processor id (the name used for scene inserts / named processors). */
|
|
472
|
-
id: string;
|
|
473
|
-
/**
|
|
474
|
-
* Primary classification, by precedence pair > realtime > offline: "pair" for
|
|
475
|
-
* two-input match.* processors, "realtime" for ids that build as a realtime
|
|
476
|
-
* scene insert, "offline" for whole-file-only processors.
|
|
477
|
-
*/
|
|
478
|
-
kind: 'realtime' | 'offline' | 'pair';
|
|
479
|
-
/** True exactly for ids that always succeed as a realtime scene insert. */
|
|
480
|
-
realtimeInsertable: boolean;
|
|
481
|
-
/** True for processors with no mono implementation (stereo-only). */
|
|
482
|
-
stereoOnly: boolean;
|
|
483
|
-
/**
|
|
484
|
-
* How the mixer wraps the processor on a >2-channel (surround) bus insert:
|
|
485
|
-
* "multichannel" (one full-buffer call) or "stereoPairOnly" (front L/R pair,
|
|
486
|
-
* surround planes passed through dry).
|
|
487
|
-
*/
|
|
488
|
-
channelPolicy: MasteringChannelPolicy;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
/**
|
|
492
|
-
* Returns the machine-readable classification catalog for every named processor
|
|
493
|
-
* id, merging the offline registry, the realtime insert factory, and the pair
|
|
494
|
-
* registry. Lets a host filter a processor picker by realtime insertability
|
|
495
|
-
* instead of offering ids the realtime strip would reject.
|
|
496
|
-
*/
|
|
497
|
-
export function masteringProcessorCatalog(): MasteringProcessorCatalogEntry[] {
|
|
498
|
-
const json = (
|
|
499
|
-
requireModule() as unknown as { masteringProcessorCatalog: () => string }
|
|
500
|
-
).masteringProcessorCatalog();
|
|
501
|
-
return JSON.parse(json) as MasteringProcessorCatalogEntry[];
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
export function masteringPairProcessorNames(): PairProcessor[] {
|
|
505
|
-
return Array.from(requireModule().masteringPairProcessorNames()) as PairProcessor[];
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
export function masteringPairAnalysisNames(): PairAnalysis[] {
|
|
509
|
-
return Array.from(requireModule().masteringPairAnalysisNames()) as PairAnalysis[];
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
export function masteringStereoAnalysisNames(): StereoAnalysis[] {
|
|
513
|
-
return Array.from(requireModule().masteringStereoAnalysisNames()) as StereoAnalysis[];
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
export function masteringProcess(
|
|
517
|
-
processorName: SoloProcessor,
|
|
518
|
-
samples: Float32Array,
|
|
519
|
-
sampleRate = 22050,
|
|
520
|
-
params: MasteringProcessorParams = {},
|
|
521
|
-
): MasteringResult {
|
|
522
|
-
return requireModule().masteringProcess(processorName, samples, sampleRate, params);
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
export function masteringProcessStereo(
|
|
526
|
-
processorName: SoloProcessor,
|
|
527
|
-
left: Float32Array,
|
|
528
|
-
right: Float32Array,
|
|
529
|
-
sampleRate = 22050,
|
|
530
|
-
params: MasteringProcessorParams = {},
|
|
531
|
-
): MasteringStereoResult {
|
|
532
|
-
if (left.length !== right.length) {
|
|
533
|
-
throw new Error('Stereo channel lengths must match.');
|
|
534
|
-
}
|
|
535
|
-
return requireModule().masteringProcessStereo(processorName, left, right, sampleRate, params);
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
/**
|
|
539
|
-
* Apply a two-input `match.*` processor. `source` and `reference` may have
|
|
540
|
-
* independent lengths — the match primitives consume each buffer at its own
|
|
541
|
-
* length.
|
|
542
|
-
*/
|
|
543
|
-
export function masteringPairProcess(
|
|
544
|
-
processorName: PairProcessor,
|
|
545
|
-
source: Float32Array,
|
|
546
|
-
reference: Float32Array,
|
|
547
|
-
sampleRate = 22050,
|
|
548
|
-
params: MasteringProcessorParams = {},
|
|
549
|
-
): MasteringResult {
|
|
550
|
-
return requireModule().masteringPairProcess(processorName, source, reference, sampleRate, params);
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
/**
|
|
554
|
-
* Analyze a `source` against a `reference` with a two-input analysis. The two
|
|
555
|
-
* buffers may have independent lengths.
|
|
556
|
-
*/
|
|
557
|
-
export function masteringPairAnalyze(
|
|
558
|
-
analysisName: PairAnalysis,
|
|
559
|
-
source: Float32Array,
|
|
560
|
-
reference: Float32Array,
|
|
561
|
-
sampleRate = 22050,
|
|
562
|
-
params: MasteringProcessorParams = {},
|
|
563
|
-
): string {
|
|
564
|
-
return requireModule().masteringPairAnalyze(analysisName, source, reference, sampleRate, params);
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
export function masteringStereoAnalyze(
|
|
568
|
-
analysisName: StereoAnalysis,
|
|
569
|
-
left: Float32Array,
|
|
570
|
-
right: Float32Array,
|
|
571
|
-
sampleRate = 22050,
|
|
572
|
-
params: MasteringProcessorParams = {},
|
|
573
|
-
): string {
|
|
574
|
-
return requireModule().masteringStereoAnalyze(analysisName, left, right, sampleRate, params);
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
export function masteringAssistantSuggest(
|
|
578
|
-
samples: Float32Array,
|
|
579
|
-
sampleRate = 22050,
|
|
580
|
-
params: MasteringProcessorParams = {},
|
|
581
|
-
): string {
|
|
582
|
-
return requireModule().masteringAssistantSuggest(samples, sampleRate, params);
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
export function masteringAudioProfile(
|
|
586
|
-
samples: Float32Array,
|
|
587
|
-
sampleRate = 22050,
|
|
588
|
-
params: MasteringProcessorParams = {},
|
|
589
|
-
): string {
|
|
590
|
-
return requireModule().masteringAudioProfile(samples, sampleRate, params);
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
export function masteringStreamingPreview(
|
|
594
|
-
samples: Float32Array,
|
|
595
|
-
sampleRate = 22050,
|
|
596
|
-
platforms: StreamingPlatform[] = [],
|
|
597
|
-
): string {
|
|
598
|
-
return requireModule().masteringStreamingPreview(samples, sampleRate, platforms);
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
// ============================================================================
|
|
602
|
-
// Mastering repair (declick, denoise_classical, declip, decrackle, dehum,
|
|
603
|
-
// dereverb_classical, trim_silence) — hand-written bindings.
|
|
604
|
-
// ============================================================================
|
|
605
|
-
|
|
606
|
-
/** Options for `masteringRepairDeclick`. */
|
|
607
|
-
export interface DeclickOptions {
|
|
608
|
-
threshold?: number;
|
|
609
|
-
neighborRatio?: number;
|
|
610
|
-
maxClickSamples?: number;
|
|
611
|
-
lpcOrder?: number;
|
|
612
|
-
residualRatio?: number;
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
/** Algorithms accepted by `masteringRepairDenoiseClassical`. */
|
|
616
|
-
export type DenoiseClassicalMode = 'logMmse' | 'mmseStsa' | 'spectralSubtraction';
|
|
617
|
-
|
|
618
|
-
/** Noise PSD estimators accepted by `masteringRepairDenoiseClassical`. */
|
|
619
|
-
export type DenoiseClassicalNoiseEstimator = 'quantile' | 'mcra' | 'imcra';
|
|
620
|
-
|
|
621
|
-
/** Options for `masteringRepairDenoiseClassical`. */
|
|
622
|
-
export interface DenoiseClassicalOptions {
|
|
623
|
-
mode?: DenoiseClassicalMode;
|
|
624
|
-
noiseEstimator?: DenoiseClassicalNoiseEstimator;
|
|
625
|
-
nFft?: number;
|
|
626
|
-
hopLength?: number;
|
|
627
|
-
ddAlpha?: number;
|
|
628
|
-
gainFloor?: number;
|
|
629
|
-
overSubtraction?: number;
|
|
630
|
-
spectralFloor?: number;
|
|
631
|
-
noiseEstimationQuantile?: number;
|
|
632
|
-
speechPresenceGain?: boolean;
|
|
633
|
-
gainSmoothing?: boolean;
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
/** Offline LPC-based declicker. */
|
|
637
|
-
export function masteringRepairDeclick(
|
|
638
|
-
samples: Float32Array,
|
|
639
|
-
sampleRate: number,
|
|
640
|
-
options: DeclickOptions = {},
|
|
641
|
-
): Float32Array {
|
|
642
|
-
return requireModule().masteringRepairDeclick(samples, sampleRate, options);
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
/** Offline STFT-domain classical denoiser (LogMMSE / MMSE-STSA / SpectralSubtraction). */
|
|
646
|
-
export function masteringRepairDenoiseClassical(
|
|
647
|
-
samples: Float32Array,
|
|
648
|
-
sampleRate: number,
|
|
649
|
-
options: DenoiseClassicalOptions = {},
|
|
650
|
-
): Float32Array {
|
|
651
|
-
return requireModule().masteringRepairDenoiseClassical(samples, sampleRate, options);
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
/** Options for `masteringRepairDeclip`. */
|
|
655
|
-
export interface DeclipOptions {
|
|
656
|
-
clipThreshold?: number;
|
|
657
|
-
lpcOrder?: number;
|
|
658
|
-
iterations?: number;
|
|
659
|
-
lpcBlend?: number;
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
/** Algorithms accepted by `masteringRepairDecrackle`. */
|
|
663
|
-
export type DecrackleMode = 'median' | 'waveletShrinkage';
|
|
664
|
-
|
|
665
|
-
/** Options for `masteringRepairDecrackle`. */
|
|
666
|
-
export interface DecrackleOptions {
|
|
667
|
-
threshold?: number;
|
|
668
|
-
mode?: DecrackleMode;
|
|
669
|
-
levels?: number;
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
/** Options for `masteringRepairDehum`. */
|
|
673
|
-
export interface DehumOptions {
|
|
674
|
-
fundamentalHz?: number;
|
|
675
|
-
harmonics?: number;
|
|
676
|
-
q?: number;
|
|
677
|
-
adaptive?: boolean;
|
|
678
|
-
searchRangeHz?: number;
|
|
679
|
-
adaptation?: number;
|
|
680
|
-
frameSize?: number;
|
|
681
|
-
pllBandwidth?: number;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
/** Options for `masteringRepairDereverbClassical`. */
|
|
685
|
-
export interface DereverbClassicalOptions {
|
|
686
|
-
threshold?: number;
|
|
687
|
-
attenuation?: number;
|
|
688
|
-
nFft?: number;
|
|
689
|
-
hopLength?: number;
|
|
690
|
-
t60Sec?: number;
|
|
691
|
-
lateDelayMs?: number;
|
|
692
|
-
overSubtraction?: number;
|
|
693
|
-
spectralFloor?: number;
|
|
694
|
-
wpeEnabled?: boolean;
|
|
695
|
-
wpeIterations?: number;
|
|
696
|
-
wpeTaps?: number;
|
|
697
|
-
wpeStrength?: number;
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
/** Trimming modes accepted by `masteringRepairTrimSilence`. */
|
|
701
|
-
export type TrimSilenceMode = 'peak' | 'lufsGated';
|
|
702
|
-
|
|
703
|
-
/** Options for `masteringRepairTrimSilence`. */
|
|
704
|
-
export interface TrimSilenceOptions {
|
|
705
|
-
threshold?: number;
|
|
706
|
-
paddingSamples?: number;
|
|
707
|
-
mode?: TrimSilenceMode;
|
|
708
|
-
gateLufs?: number;
|
|
709
|
-
windowMs?: number;
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
/** Offline LPC-based declipper. */
|
|
713
|
-
export function masteringRepairDeclip(
|
|
714
|
-
samples: Float32Array,
|
|
715
|
-
sampleRate: number,
|
|
716
|
-
options: DeclipOptions = {},
|
|
717
|
-
): Float32Array {
|
|
718
|
-
return requireModule().masteringRepairDeclip(samples, sampleRate, options);
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
/** Offline crackle suppressor (median or wavelet-shrinkage). */
|
|
722
|
-
export function masteringRepairDecrackle(
|
|
723
|
-
samples: Float32Array,
|
|
724
|
-
sampleRate: number,
|
|
725
|
-
options: DecrackleOptions = {},
|
|
726
|
-
): Float32Array {
|
|
727
|
-
return requireModule().masteringRepairDecrackle(samples, sampleRate, options);
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
/** Offline mains-hum remover. */
|
|
731
|
-
export function masteringRepairDehum(
|
|
732
|
-
samples: Float32Array,
|
|
733
|
-
sampleRate: number,
|
|
734
|
-
options: DehumOptions = {},
|
|
735
|
-
): Float32Array {
|
|
736
|
-
return requireModule().masteringRepairDehum(samples, sampleRate, options);
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
/** Offline classical dereverberator (spectral subtraction + optional WPE). */
|
|
740
|
-
export function masteringRepairDereverbClassical(
|
|
741
|
-
samples: Float32Array,
|
|
742
|
-
sampleRate: number,
|
|
743
|
-
options: DereverbClassicalOptions = {},
|
|
744
|
-
): Float32Array {
|
|
745
|
-
return requireModule().masteringRepairDereverbClassical(samples, sampleRate, options);
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
/** Offline silence trimmer (peak threshold or LUFS-gated). */
|
|
749
|
-
export function masteringRepairTrimSilence(
|
|
750
|
-
samples: Float32Array,
|
|
751
|
-
sampleRate: number,
|
|
752
|
-
options: TrimSilenceOptions = {},
|
|
753
|
-
): Float32Array {
|
|
754
|
-
return requireModule().masteringRepairTrimSilence(samples, sampleRate, options);
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
// ============================================================================
|
|
758
|
-
// Mastering — offline dynamics processors (compressor / gate / transient_shaper)
|
|
759
|
-
// ============================================================================
|
|
760
|
-
|
|
761
|
-
/** Compressor sidechain detector mode. */
|
|
762
|
-
export type CompressorDetector = 'peak' | 'rms' | 'log_rms';
|
|
763
|
-
|
|
764
|
-
/** Options for `masteringDynamicsCompressor`. */
|
|
765
|
-
export interface CompressorOptions extends ValidateOptions {
|
|
766
|
-
thresholdDb?: number;
|
|
767
|
-
ratio?: number;
|
|
768
|
-
attackMs?: number;
|
|
769
|
-
releaseMs?: number;
|
|
770
|
-
kneeDb?: number;
|
|
771
|
-
makeupGainDb?: number;
|
|
772
|
-
autoMakeup?: boolean;
|
|
773
|
-
detector?: CompressorDetector | number;
|
|
774
|
-
sidechainHpfEnabled?: boolean;
|
|
775
|
-
sidechainHpfHz?: number;
|
|
776
|
-
pdrTimeMs?: number;
|
|
777
|
-
pdrReleaseScale?: number;
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
/** Options for `masteringDynamicsGate`. */
|
|
781
|
-
export interface GateOptions extends ValidateOptions {
|
|
782
|
-
thresholdDb?: number;
|
|
783
|
-
attackMs?: number;
|
|
784
|
-
releaseMs?: number;
|
|
785
|
-
rangeDb?: number;
|
|
786
|
-
holdMs?: number;
|
|
787
|
-
closeThresholdDb?: number;
|
|
788
|
-
keyHpfHz?: number;
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
/** Options for `masteringDynamicsTransientShaper`. */
|
|
792
|
-
export interface TransientShaperOptions extends ValidateOptions {
|
|
793
|
-
attackGainDb?: number;
|
|
794
|
-
sustainGainDb?: number;
|
|
795
|
-
fastAttackMs?: number;
|
|
796
|
-
fastReleaseMs?: number;
|
|
797
|
-
slowAttackMs?: number;
|
|
798
|
-
slowReleaseMs?: number;
|
|
799
|
-
sensitivity?: number;
|
|
800
|
-
maxGainDb?: number;
|
|
801
|
-
gainSmoothingMs?: number;
|
|
802
|
-
lookaheadMs?: number;
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
/** Result envelope returned by offline mastering dynamics processors. */
|
|
806
|
-
export interface DynamicsResult {
|
|
807
|
-
samples: Float32Array;
|
|
808
|
-
latencySamples: number;
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
const COMPRESSOR_DETECTOR_MAP: Record<CompressorDetector, number> = {
|
|
812
|
-
peak: 0,
|
|
813
|
-
rms: 1,
|
|
814
|
-
log_rms: 2,
|
|
815
|
-
};
|
|
816
|
-
|
|
817
|
-
/** Offline feed-forward compressor (soft knee, optional auto-makeup / sidechain HPF). */
|
|
818
|
-
export function masteringDynamicsCompressor(
|
|
819
|
-
samples: Float32Array,
|
|
820
|
-
sampleRate: number,
|
|
821
|
-
options: CompressorOptions = {},
|
|
822
|
-
): DynamicsResult {
|
|
823
|
-
assertSamples('masteringDynamicsCompressor', samples, options.validate !== false);
|
|
824
|
-
const detector =
|
|
825
|
-
typeof options.detector === 'string'
|
|
826
|
-
? COMPRESSOR_DETECTOR_MAP[options.detector]
|
|
827
|
-
: options.detector;
|
|
828
|
-
const opts: Record<string, unknown> = { ...options };
|
|
829
|
-
if (detector !== undefined) {
|
|
830
|
-
opts.detector = detector;
|
|
831
|
-
}
|
|
832
|
-
return requireModule().masteringDynamicsCompressor(samples, sampleRate, opts);
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
/** Offline noise gate (hysteresis, hold, optional key HPF). */
|
|
836
|
-
export function masteringDynamicsGate(
|
|
837
|
-
samples: Float32Array,
|
|
838
|
-
sampleRate: number,
|
|
839
|
-
options: GateOptions = {},
|
|
840
|
-
): DynamicsResult {
|
|
841
|
-
assertSamples('masteringDynamicsGate', samples, options.validate !== false);
|
|
842
|
-
return requireModule().masteringDynamicsGate(samples, sampleRate, options);
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
/** Offline transient shaper (envelope-difference attack/sustain control). */
|
|
846
|
-
export function masteringDynamicsTransientShaper(
|
|
847
|
-
samples: Float32Array,
|
|
848
|
-
sampleRate: number,
|
|
849
|
-
options: TransientShaperOptions = {},
|
|
850
|
-
): DynamicsResult {
|
|
851
|
-
assertSamples('masteringDynamicsTransientShaper', samples, options.validate !== false);
|
|
852
|
-
return requireModule().masteringDynamicsTransientShaper(samples, sampleRate, options);
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
/**
|
|
856
|
-
* Apply a configurable mastering chain in WASM.
|
|
857
|
-
*
|
|
858
|
-
* @param samples - Audio samples (mono, float32)
|
|
859
|
-
* @param sampleRate - Sample rate in Hz (default: 22050)
|
|
860
|
-
* @param config - Chain stage configuration
|
|
861
|
-
* @returns Processed audio, loudness metadata, and applied stage names
|
|
862
|
-
*/
|
|
863
|
-
export function masteringChain(
|
|
864
|
-
samples: Float32Array,
|
|
865
|
-
sampleRate = 22050,
|
|
866
|
-
config: MasteringChainConfig,
|
|
867
|
-
): MasteringChainResult {
|
|
868
|
-
return requireModule().masteringChain(samples, sampleRate, config as Record<string, unknown>);
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
/**
|
|
872
|
-
* Apply a configurable stereo mastering chain in WASM.
|
|
873
|
-
*
|
|
874
|
-
* @param left - Left channel samples
|
|
875
|
-
* @param right - Right channel samples
|
|
876
|
-
* @param sampleRate - Sample rate in Hz
|
|
877
|
-
* @param config - Chain stage configuration
|
|
878
|
-
* @returns Processed stereo audio, loudness metadata, and applied stage names
|
|
879
|
-
*/
|
|
880
|
-
export function masteringChainStereo(
|
|
881
|
-
left: Float32Array,
|
|
882
|
-
right: Float32Array,
|
|
883
|
-
sampleRate = 22050,
|
|
884
|
-
config: MasteringChainConfig,
|
|
885
|
-
): MasteringStereoChainResult {
|
|
886
|
-
if (left.length !== right.length) {
|
|
887
|
-
throw new Error('Stereo channel lengths must match.');
|
|
888
|
-
}
|
|
889
|
-
return requireModule().masteringChainStereo(
|
|
890
|
-
left,
|
|
891
|
-
right,
|
|
892
|
-
sampleRate,
|
|
893
|
-
config as Record<string, unknown>,
|
|
894
|
-
);
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
/**
|
|
898
|
-
* Apply a configurable mastering chain in WASM with progress reporting.
|
|
899
|
-
*
|
|
900
|
-
* @param samples - Audio samples (mono, float32)
|
|
901
|
-
* @param sampleRate - Sample rate in Hz (default: 22050)
|
|
902
|
-
* @param config - Chain stage configuration
|
|
903
|
-
* @param onProgress - Progress callback (progress: 0-1, stage: string)
|
|
904
|
-
* @returns Processed audio, loudness metadata, and applied stage names
|
|
905
|
-
*/
|
|
906
|
-
export function masteringChainWithProgress(
|
|
907
|
-
samples: Float32Array,
|
|
908
|
-
sampleRate = 22050,
|
|
909
|
-
config: MasteringChainConfig,
|
|
910
|
-
onProgress: ProgressCallback,
|
|
911
|
-
): MasteringChainResult {
|
|
912
|
-
return requireModule().masteringChainWithProgress(
|
|
913
|
-
samples,
|
|
914
|
-
sampleRate,
|
|
915
|
-
config as Record<string, unknown>,
|
|
916
|
-
onProgress,
|
|
917
|
-
);
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
/**
|
|
921
|
-
* Apply a configurable stereo mastering chain in WASM with progress reporting.
|
|
922
|
-
*
|
|
923
|
-
* @param left - Left channel samples
|
|
924
|
-
* @param right - Right channel samples
|
|
925
|
-
* @param sampleRate - Sample rate in Hz
|
|
926
|
-
* @param config - Chain stage configuration
|
|
927
|
-
* @param onProgress - Progress callback (progress: 0-1, stage: string)
|
|
928
|
-
* @returns Processed stereo audio, loudness metadata, and applied stage names
|
|
929
|
-
*/
|
|
930
|
-
export function masteringChainStereoWithProgress(
|
|
931
|
-
left: Float32Array,
|
|
932
|
-
right: Float32Array,
|
|
933
|
-
sampleRate = 22050,
|
|
934
|
-
config: MasteringChainConfig,
|
|
935
|
-
onProgress: ProgressCallback,
|
|
936
|
-
): MasteringStereoChainResult {
|
|
937
|
-
if (left.length !== right.length) {
|
|
938
|
-
throw new Error('Stereo channel lengths must match.');
|
|
939
|
-
}
|
|
940
|
-
return requireModule().masteringChainStereoWithProgress(
|
|
941
|
-
left,
|
|
942
|
-
right,
|
|
943
|
-
sampleRate,
|
|
944
|
-
config as Record<string, unknown>,
|
|
945
|
-
onProgress,
|
|
946
|
-
);
|
|
947
|
-
}
|
|
948
|
-
|
|
949
|
-
/**
|
|
950
|
-
* List built-in mastering preset identifiers.
|
|
951
|
-
*
|
|
952
|
-
* @returns Preset names in display order (e.g. "pop", "edm", "aiMusic")
|
|
953
|
-
*/
|
|
954
|
-
export function masteringPresetNames(): MasteringPreset[] {
|
|
955
|
-
return Array.from(requireModule().masteringPresetNames()) as MasteringPreset[];
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
/**
|
|
959
|
-
* Apply a named mastering preset chain to mono audio.
|
|
960
|
-
*
|
|
961
|
-
* @param samples - Audio samples (mono, float32)
|
|
962
|
-
* @param sampleRate - Sample rate in Hz (default: 22050)
|
|
963
|
-
* @param presetName - Preset identifier from {@link masteringPresetNames}
|
|
964
|
-
* @param overrides - Optional flat overrides (dot-notation, e.g. `'loudness.targetLufs'`) applied on top of the preset. Pass `null` for preset defaults.
|
|
965
|
-
* @returns Processed audio, loudness metadata, and applied stage names
|
|
966
|
-
*/
|
|
967
|
-
export function masterAudio(
|
|
968
|
-
samples: Float32Array,
|
|
969
|
-
sampleRate = 22050,
|
|
970
|
-
presetName: MasteringPreset = 'pop',
|
|
971
|
-
overrides: Record<string, number | boolean> = {},
|
|
972
|
-
): MasteringChainResult {
|
|
973
|
-
return requireModule().masterAudio(presetName, samples, sampleRate, overrides);
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
/**
|
|
977
|
-
* Apply a named mastering preset chain to stereo audio.
|
|
978
|
-
*
|
|
979
|
-
* @param left - Left channel samples
|
|
980
|
-
* @param right - Right channel samples
|
|
981
|
-
* @param sampleRate - Sample rate in Hz
|
|
982
|
-
* @param presetName - Preset identifier from {@link masteringPresetNames}
|
|
983
|
-
* @param overrides - Optional flat overrides (dot-notation, e.g. `'loudness.targetLufs'`) applied on top of the preset. Pass `null` for preset defaults.
|
|
984
|
-
* @returns Processed stereo audio, loudness metadata, and applied stage names
|
|
985
|
-
*/
|
|
986
|
-
export function masterAudioStereo(
|
|
987
|
-
left: Float32Array,
|
|
988
|
-
right: Float32Array,
|
|
989
|
-
sampleRate = 22050,
|
|
990
|
-
presetName: MasteringPreset = 'pop',
|
|
991
|
-
overrides: Record<string, number | boolean> = {},
|
|
992
|
-
): MasteringStereoChainResult {
|
|
993
|
-
if (left.length !== right.length) {
|
|
994
|
-
throw new Error('Stereo channel lengths must match.');
|
|
995
|
-
}
|
|
996
|
-
return requireModule().masterAudioStereo(presetName, left, right, sampleRate, overrides);
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
/**
|
|
1000
|
-
* Mono `masterAudio` with per-stage progress reporting. `onProgress` is invoked
|
|
1001
|
-
* with `(progress, stage)` between each chain stage (progress is in [0,1]).
|
|
1002
|
-
*/
|
|
1003
|
-
export function masterAudioWithProgress(
|
|
1004
|
-
samples: Float32Array,
|
|
1005
|
-
sampleRate = 22050,
|
|
1006
|
-
presetName: MasteringPreset,
|
|
1007
|
-
onProgress: ProgressCallback,
|
|
1008
|
-
overrides: Record<string, number | boolean> | null = null,
|
|
1009
|
-
): MasteringChainResult {
|
|
1010
|
-
return requireModule().masterAudioWithProgress(
|
|
1011
|
-
presetName,
|
|
1012
|
-
samples,
|
|
1013
|
-
sampleRate,
|
|
1014
|
-
overrides,
|
|
1015
|
-
onProgress,
|
|
1016
|
-
);
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
/**
|
|
1020
|
-
* Stereo `masterAudio` with per-stage progress reporting.
|
|
1021
|
-
*/
|
|
1022
|
-
export function masterAudioStereoWithProgress(
|
|
1023
|
-
left: Float32Array,
|
|
1024
|
-
right: Float32Array,
|
|
1025
|
-
sampleRate = 22050,
|
|
1026
|
-
presetName: MasteringPreset,
|
|
1027
|
-
onProgress: ProgressCallback,
|
|
1028
|
-
overrides: Record<string, number | boolean> | null = null,
|
|
1029
|
-
): MasteringStereoChainResult {
|
|
1030
|
-
if (left.length !== right.length) {
|
|
1031
|
-
throw new Error('Stereo channel lengths must match.');
|
|
1032
|
-
}
|
|
1033
|
-
return requireModule().masterAudioStereoWithProgress(
|
|
1034
|
-
presetName,
|
|
1035
|
-
left,
|
|
1036
|
-
right,
|
|
1037
|
-
sampleRate,
|
|
1038
|
-
overrides,
|
|
1039
|
-
onProgress,
|
|
1040
|
-
);
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
export function mixingScenePresetNames(): string[] {
|
|
1044
|
-
return Array.from(requireModule().mixingScenePresetNames());
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
/**
|
|
1048
|
-
* Get a built-in mixing scene preset serialized as JSON. This is the canonical
|
|
1049
|
-
* name shared with the Node and Python bindings; the returned JSON loads
|
|
1050
|
-
* directly into a {@link Mixer} via {@link Mixer.fromSceneJson}.
|
|
1051
|
-
*
|
|
1052
|
-
* @param presetName - Preset name (see {@link mixingScenePresetNames})
|
|
1053
|
-
* @returns Scene JSON string
|
|
1054
|
-
*/
|
|
1055
|
-
export function mixingScenePresetJson(presetName: string): string {
|
|
1056
|
-
return requireModule().mixingScenePresetJson(presetName);
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
/**
|
|
1060
|
-
* One-shot stereo mix of multiple strips through the routing graph + master bus.
|
|
1061
|
-
*
|
|
1062
|
-
* Each returned per-strip meter reflects only this single one-shot block. The
|
|
1063
|
-
* integrating-meter fields (`momentaryLufs`, `shortTermLufs`, `integratedLufs`
|
|
1064
|
-
* and the true-peak fields) require sustained streaming to populate; on a short
|
|
1065
|
-
* one-shot mix they read the -120 dB floor sentinel. Drive a streaming
|
|
1066
|
-
* {@link Mixer} block-by-block if you need meaningful loudness/true-peak
|
|
1067
|
-
* readings.
|
|
1068
|
-
*
|
|
1069
|
-
* @param leftChannels - Per-strip left input buffers (all the same length)
|
|
1070
|
-
* @param rightChannels - Per-strip right input buffers (all the same length)
|
|
1071
|
-
* @param sampleRate - Sample rate in Hz
|
|
1072
|
-
* @param options - Per-strip mix options (trim, fader, pan, width, mute)
|
|
1073
|
-
*/
|
|
1074
|
-
export function mixStereo(
|
|
1075
|
-
leftChannels: Float32Array[],
|
|
1076
|
-
rightChannels: Float32Array[],
|
|
1077
|
-
sampleRate = 48000,
|
|
1078
|
-
options: MixOptions = {},
|
|
1079
|
-
): MixResult {
|
|
1080
|
-
if (leftChannels.length === 0 || leftChannels.length !== rightChannels.length) {
|
|
1081
|
-
throw new Error('leftChannels and rightChannels must have the same non-zero length.');
|
|
1082
|
-
}
|
|
1083
|
-
return requireModule().mixStereo(
|
|
1084
|
-
leftChannels,
|
|
1085
|
-
rightChannels,
|
|
1086
|
-
sampleRate,
|
|
1087
|
-
options as Record<string, unknown>,
|
|
1088
|
-
);
|
|
1089
|
-
}
|
|
1
|
+
export {
|
|
2
|
+
harmonic,
|
|
3
|
+
hpss,
|
|
4
|
+
normalize,
|
|
5
|
+
noteStretch,
|
|
6
|
+
percussive,
|
|
7
|
+
pitchCorrectTimevarying,
|
|
8
|
+
pitchCorrectToMidi,
|
|
9
|
+
pitchCorrectToMidiTimevarying,
|
|
10
|
+
pitchShift,
|
|
11
|
+
spectralEdit,
|
|
12
|
+
timeStretch,
|
|
13
|
+
} from './effects_transform';
|
|
14
|
+
export type { VoiceChangeOptions, VoiceChangeRealtimeOptions } from './effects_voice_change';
|
|
15
|
+
export { voiceChange, voiceChangeRealtime } from './effects_voice_change';
|
|
16
|
+
export {
|
|
17
|
+
masterAudio,
|
|
18
|
+
masterAudioStereo,
|
|
19
|
+
masterAudioStereoWithProgress,
|
|
20
|
+
masterAudioWithProgress,
|
|
21
|
+
masteringChain,
|
|
22
|
+
masteringChainStereo,
|
|
23
|
+
masteringChainStereoWithProgress,
|
|
24
|
+
masteringChainWithProgress,
|
|
25
|
+
masteringPresetNames,
|
|
26
|
+
} from './mastering_chain';
|
|
27
|
+
export type {
|
|
28
|
+
MasteringChannelPolicy,
|
|
29
|
+
MasteringInsertParamInfo,
|
|
30
|
+
MasteringProcessorCatalogEntry,
|
|
31
|
+
} from './mastering_core';
|
|
32
|
+
export {
|
|
33
|
+
mastering,
|
|
34
|
+
masteringAssistantSuggest,
|
|
35
|
+
masteringAudioProfile,
|
|
36
|
+
masteringInsertNames,
|
|
37
|
+
masteringInsertParamInfo,
|
|
38
|
+
masteringInsertParamNames,
|
|
39
|
+
masteringPairAnalysisNames,
|
|
40
|
+
masteringPairAnalyze,
|
|
41
|
+
masteringPairProcess,
|
|
42
|
+
masteringPairProcessorNames,
|
|
43
|
+
masteringProcess,
|
|
44
|
+
masteringProcessorCatalog,
|
|
45
|
+
masteringProcessorNames,
|
|
46
|
+
masteringProcessStereo,
|
|
47
|
+
masteringStereoAnalysisNames,
|
|
48
|
+
masteringStereoAnalyze,
|
|
49
|
+
masteringStreamingPreview,
|
|
50
|
+
} from './mastering_core';
|
|
51
|
+
export type {
|
|
52
|
+
CompressorDetector,
|
|
53
|
+
CompressorOptions,
|
|
54
|
+
DynamicsResult,
|
|
55
|
+
GateOptions,
|
|
56
|
+
TransientShaperOptions,
|
|
57
|
+
} from './mastering_dynamics';
|
|
58
|
+
export {
|
|
59
|
+
masteringDynamicsCompressor,
|
|
60
|
+
masteringDynamicsGate,
|
|
61
|
+
masteringDynamicsTransientShaper,
|
|
62
|
+
} from './mastering_dynamics';
|
|
63
|
+
export type {
|
|
64
|
+
DeclickOptions,
|
|
65
|
+
DeclipOptions,
|
|
66
|
+
DecrackleMode,
|
|
67
|
+
DecrackleOptions,
|
|
68
|
+
DehumOptions,
|
|
69
|
+
DenoiseClassicalMode,
|
|
70
|
+
DenoiseClassicalNoiseEstimator,
|
|
71
|
+
DenoiseClassicalOptions,
|
|
72
|
+
DereverbClassicalOptions,
|
|
73
|
+
TrimSilenceMode,
|
|
74
|
+
TrimSilenceOptions,
|
|
75
|
+
} from './mastering_repair';
|
|
76
|
+
export {
|
|
77
|
+
masteringRepairDeclick,
|
|
78
|
+
masteringRepairDeclip,
|
|
79
|
+
masteringRepairDecrackle,
|
|
80
|
+
masteringRepairDehum,
|
|
81
|
+
masteringRepairDenoiseClassical,
|
|
82
|
+
masteringRepairDereverbClassical,
|
|
83
|
+
masteringRepairTrimSilence,
|
|
84
|
+
} from './mastering_repair';
|
|
85
|
+
export { mixingScenePresetJson, mixingScenePresetNames, mixStereo } from './mixing_oneshot';
|