@libraz/libsonare 1.7.2 → 1.8.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/NOTICE +178 -0
- package/README.md +26 -203
- package/dist/_chain_config.d.ts +14 -0
- package/dist/_chain_config.d.ts.map +1 -0
- package/dist/_effects_common.d.ts +7 -0
- package/dist/_effects_common.d.ts.map +1 -0
- package/dist/_feature_validation.d.ts +8 -0
- package/dist/_feature_validation.d.ts.map +1 -0
- package/dist/_fft_options.d.ts +24 -0
- package/dist/_fft_options.d.ts.map +1 -0
- package/dist/align_take.d.ts +50 -0
- package/dist/align_take.d.ts.map +1 -0
- package/dist/analysis.d.ts +29 -5840
- package/dist/analysis.d.ts.map +1 -0
- package/dist/analysis.js +874 -722
- package/dist/analysis.js.map +1 -1
- package/dist/analysis_helpers.d.ts +9 -0
- package/dist/analysis_helpers.d.ts.map +1 -0
- package/dist/audio.d.ts +163 -0
- package/dist/audio.d.ts.map +1 -0
- package/dist/clip_page_streamer.d.ts +133 -0
- package/dist/clip_page_streamer.d.ts.map +1 -0
- package/dist/codes.d.ts +44 -0
- package/dist/codes.d.ts.map +1 -0
- package/dist/effects_mastering.d.ts +23 -0
- package/dist/effects_mastering.d.ts.map +1 -0
- package/dist/effects_note_ops.d.ts +502 -0
- package/dist/effects_note_ops.d.ts.map +1 -0
- package/dist/effects_percussive.d.ts +185 -0
- package/dist/effects_percussive.d.ts.map +1 -0
- package/dist/effects_separation.d.ts +65 -0
- package/dist/effects_separation.d.ts.map +1 -0
- package/dist/effects_spectral.d.ts +28 -0
- package/dist/effects_spectral.d.ts.map +1 -0
- package/dist/effects_timepitch.d.ts +134 -0
- package/dist/effects_timepitch.d.ts.map +1 -0
- package/dist/effects_voice_change.d.ts +53 -0
- package/dist/effects_voice_change.d.ts.map +1 -0
- package/dist/errors.d.ts +51 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/feature_core.d.ts +341 -0
- package/dist/feature_core.d.ts.map +1 -0
- package/dist/feature_decompose.d.ts +278 -0
- package/dist/feature_decompose.d.ts.map +1 -0
- package/dist/feature_inverse.d.ts +128 -0
- package/dist/feature_inverse.d.ts.map +1 -0
- package/dist/feature_loudness.d.ts +66 -0
- package/dist/feature_loudness.d.ts.map +1 -0
- package/dist/feature_music.d.ts +307 -0
- package/dist/feature_music.d.ts.map +1 -0
- package/dist/feature_pitch.d.ts +108 -0
- package/dist/feature_pitch.d.ts.map +1 -0
- package/dist/feature_resample.d.ts +16 -0
- package/dist/feature_resample.d.ts.map +1 -0
- package/dist/feature_spectral.d.ts +137 -0
- package/dist/feature_spectral.d.ts.map +1 -0
- package/dist/feature_spectrogram.d.ts +198 -0
- package/dist/feature_spectrogram.d.ts.map +1 -0
- package/dist/features.d.ts +10 -0
- package/dist/features.d.ts.map +1 -0
- package/dist/hrtf/default.shrf +0 -0
- package/dist/index.d.ts +74 -7431
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4173 -1621
- package/dist/index.js.map +1 -1
- package/dist/instrument_types.d.ts +517 -0
- package/dist/instrument_types.d.ts.map +1 -0
- package/dist/live_audio.d.ts +35 -0
- package/dist/live_audio.d.ts.map +1 -0
- package/dist/mastering_chain.d.ts +213 -0
- package/dist/mastering_chain.d.ts.map +1 -0
- package/dist/mastering_core.d.ts +483 -0
- package/dist/mastering_core.d.ts.map +1 -0
- package/dist/mastering_dynamics.d.ts +80 -0
- package/dist/mastering_dynamics.d.ts.map +1 -0
- package/dist/metering.d.ts +287 -0
- package/dist/metering.d.ts.map +1 -0
- package/dist/mixer.d.ts +464 -0
- package/dist/mixer.d.ts.map +1 -0
- package/dist/mixing_assistant.d.ts +62 -0
- package/dist/mixing_assistant.d.ts.map +1 -0
- package/dist/mixing_oneshot.d.ts +40 -0
- package/dist/mixing_oneshot.d.ts.map +1 -0
- package/dist/module_state.d.ts +15 -0
- package/dist/module_state.d.ts.map +1 -0
- package/dist/opfs_clip_pages.d.ts +28 -0
- package/dist/opfs_clip_pages.d.ts.map +1 -0
- package/dist/playback_renderer.d.ts +128 -0
- package/dist/playback_renderer.d.ts.map +1 -0
- package/dist/polyphony.d.ts +202 -0
- package/dist/polyphony.d.ts.map +1 -0
- package/dist/project.d.ts +8 -0
- package/dist/project.d.ts.map +1 -0
- package/dist/project_class.d.ts +562 -0
- package/dist/project_class.d.ts.map +1 -0
- package/dist/project_internal.d.ts +194 -0
- package/dist/project_internal.d.ts.map +1 -0
- package/dist/project_synth.d.ts +74 -0
- package/dist/project_synth.d.ts.map +1 -0
- package/dist/project_types.d.ts +654 -0
- package/dist/project_types.d.ts.map +1 -0
- package/dist/public_types.d.ts +185 -0
- package/dist/public_types.d.ts.map +1 -0
- package/dist/public_types_acoustic.d.ts +215 -0
- package/dist/public_types_acoustic.d.ts.map +1 -0
- package/dist/public_types_mastering.d.ts +528 -0
- package/dist/public_types_mastering.d.ts.map +1 -0
- package/dist/public_types_mixing.d.ts +436 -0
- package/dist/public_types_mixing.d.ts.map +1 -0
- package/dist/public_types_music.d.ts +619 -0
- package/dist/public_types_music.d.ts.map +1 -0
- package/dist/public_types_playback.d.ts +165 -0
- package/dist/public_types_playback.d.ts.map +1 -0
- package/dist/public_types_realtime.d.ts +174 -0
- package/dist/public_types_realtime.d.ts.map +1 -0
- package/dist/public_types_repair.d.ts +424 -0
- package/dist/public_types_repair.d.ts.map +1 -0
- package/dist/public_types_spectral.d.ts +697 -0
- package/dist/public_types_spectral.d.ts.map +1 -0
- package/dist/quick_analysis.d.ts +445 -0
- package/dist/quick_analysis.d.ts.map +1 -0
- package/dist/realtime_engine.d.ts +893 -0
- package/dist/realtime_engine.d.ts.map +1 -0
- package/dist/realtime_voice_changer.d.ts +158 -0
- package/dist/realtime_voice_changer.d.ts.map +1 -0
- package/dist/repair_dereverb.d.ts +187 -0
- package/dist/repair_dereverb.d.ts.map +1 -0
- package/dist/repair_impulsive.d.ts +186 -0
- package/dist/repair_impulsive.d.ts.map +1 -0
- package/dist/repair_noise.d.ts +239 -0
- package/dist/repair_noise.d.ts.map +1 -0
- package/dist/repair_trim.d.ts +123 -0
- package/dist/repair_trim.d.ts.map +1 -0
- package/dist/sample_bank.d.ts +84 -0
- package/dist/sample_bank.d.ts.map +1 -0
- package/dist/scale.d.ts +10 -0
- package/dist/scale.d.ts.map +1 -0
- package/dist/schemas/mixer-scene.schema.json +393 -0
- package/dist/schemas/playback-renderer-config.schema.json +392 -0
- package/dist/sonare-analysis.d.ts +8 -0
- package/dist/sonare-analysis.js +2 -2
- package/dist/sonare-analysis.wasm +0 -0
- package/dist/sonare.d.ts +3945 -0
- package/dist/sonare.js +2 -2
- package/dist/sonare.wasm +0 -0
- package/dist/stream_analyzer.d.ts +163 -0
- package/dist/stream_analyzer.d.ts.map +1 -0
- package/dist/stream_types.d.ts +214 -0
- package/dist/stream_types.d.ts.map +1 -0
- package/dist/streaming_mixing.d.ts +6 -0
- package/dist/streaming_mixing.d.ts.map +1 -0
- package/dist/streaming_processors.d.ts +340 -0
- package/dist/streaming_processors.d.ts.map +1 -0
- package/dist/transcribe.d.ts +77 -0
- package/dist/transcribe.d.ts.map +1 -0
- package/dist/validation.d.ts +140 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/web_midi.d.ts +77 -0
- package/dist/web_midi.d.ts.map +1 -0
- package/dist/worker.d.ts +5 -48
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +94 -41
- package/dist/worker.js.map +1 -1
- package/dist/worker_client.d.ts +96 -0
- package/dist/worker_client.d.ts.map +1 -0
- package/dist/worker_protocol.d.ts +43 -0
- package/dist/worker_protocol.d.ts.map +1 -0
- package/dist/worklet/audio_types.d.ts +21 -0
- package/dist/worklet/audio_types.d.ts.map +1 -0
- package/dist/worklet/engine-automation.d.ts +29 -0
- package/dist/worklet/engine-automation.d.ts.map +1 -0
- package/dist/worklet/engine-capture-facade.d.ts +35 -0
- package/dist/worklet/engine-capture-facade.d.ts.map +1 -0
- package/dist/worklet/engine-clips.d.ts +23 -0
- package/dist/worklet/engine-clips.d.ts.map +1 -0
- package/dist/worklet/engine-markers.d.ts +40 -0
- package/dist/worklet/engine-markers.d.ts.map +1 -0
- package/dist/worklet/engine-mixer-facade.d.ts +164 -0
- package/dist/worklet/engine-mixer-facade.d.ts.map +1 -0
- package/dist/worklet/engine-node.d.ts +83 -0
- package/dist/worklet/engine-node.d.ts.map +1 -0
- package/dist/worklet/engine-offline.d.ts +81 -0
- package/dist/worklet/engine-offline.d.ts.map +1 -0
- package/dist/worklet/engine-options.d.ts +12 -0
- package/dist/worklet/engine-options.d.ts.map +1 -0
- package/dist/worklet/engine-parameter-facade.d.ts +106 -0
- package/dist/worklet/engine-parameter-facade.d.ts.map +1 -0
- package/dist/worklet/engine-processor.d.ts +72 -0
- package/dist/worklet/engine-processor.d.ts.map +1 -0
- package/dist/worklet/engine-register.d.ts +2 -0
- package/dist/worklet/engine-register.d.ts.map +1 -0
- package/dist/worklet/engine-strips.d.ts +75 -0
- package/dist/worklet/engine-strips.d.ts.map +1 -0
- package/dist/worklet/engine-sync.d.ts +39 -0
- package/dist/worklet/engine-sync.d.ts.map +1 -0
- package/dist/worklet/engine-tempo-facade.d.ts +48 -0
- package/dist/worklet/engine-tempo-facade.d.ts.map +1 -0
- package/dist/worklet/engine.d.ts +418 -0
- package/dist/worklet/engine.d.ts.map +1 -0
- package/dist/worklet/guards.d.ts +53 -0
- package/dist/worklet/guards.d.ts.map +1 -0
- package/dist/worklet/messages.d.ts +710 -0
- package/dist/worklet/messages.d.ts.map +1 -0
- package/dist/worklet/mixer-processor.d.ts +46 -0
- package/dist/worklet/mixer-processor.d.ts.map +1 -0
- package/dist/worklet/playback-processor.d.ts +62 -0
- package/dist/worklet/playback-processor.d.ts.map +1 -0
- package/dist/worklet/protocol.d.ts +331 -0
- package/dist/worklet/protocol.d.ts.map +1 -0
- package/dist/worklet/voice-changer-processor.d.ts +41 -0
- package/dist/worklet/voice-changer-processor.d.ts.map +1 -0
- package/dist/worklet.d.ts +16 -2515
- package/dist/worklet.d.ts.map +1 -0
- package/dist/worklet.js +3200 -541
- package/dist/worklet.js.map +1 -1
- package/package.json +23 -12
- package/src/_effects_common.ts +47 -0
- package/src/_feature_validation.ts +34 -0
- package/src/_fft_options.ts +39 -0
- package/src/align_take.ts +64 -0
- package/src/analysis.ts +56 -3
- package/src/analysis_helpers.ts +7 -0
- package/src/audio.ts +106 -3
- package/src/codes.ts +39 -2
- package/src/effects_mastering.ts +101 -22
- package/src/effects_note_ops.ts +683 -0
- package/src/effects_percussive.ts +217 -0
- package/src/effects_separation.ts +150 -0
- package/src/effects_spectral.ts +60 -0
- package/src/effects_timepitch.ts +388 -0
- package/src/errors.ts +23 -1
- package/src/feature_core.ts +127 -2
- package/src/feature_decompose.ts +633 -0
- package/src/feature_inverse.ts +454 -0
- package/src/feature_loudness.ts +125 -0
- package/src/feature_music.ts +107 -14
- package/src/feature_pitch.ts +96 -1
- package/src/feature_spectral.ts +16 -611
- package/src/feature_spectrogram.ts +63 -450
- package/src/features.ts +36 -22
- package/src/index.ts +288 -30
- package/src/instrument_types.ts +645 -0
- package/src/live_audio.ts +27 -1
- package/src/mastering_chain.ts +184 -0
- package/src/mastering_core.ts +441 -32
- package/src/mastering_dynamics.ts +22 -11
- package/src/metering.ts +67 -24
- package/src/mixer.ts +251 -22
- package/src/mixing_assistant.ts +138 -0
- package/src/mixing_oneshot.ts +10 -5
- package/src/module_state.ts +24 -2
- package/src/playback_renderer.ts +252 -0
- package/src/polyphony.ts +279 -0
- package/src/project.ts +61 -24
- package/src/project_class.ts +450 -27
- package/src/project_internal.ts +149 -42
- package/src/project_synth.ts +67 -1
- package/src/project_types.ts +271 -271
- package/src/public_types.ts +122 -3
- package/src/public_types_acoustic.ts +112 -3
- package/src/public_types_mastering.ts +275 -73
- package/src/public_types_mixing.ts +363 -1
- package/src/public_types_music.ts +312 -2
- package/src/public_types_playback.ts +196 -0
- package/src/public_types_realtime.ts +39 -7
- package/src/public_types_repair.ts +446 -0
- package/src/public_types_spectral.ts +491 -5
- package/src/quick_analysis.ts +203 -26
- package/src/realtime_engine.ts +773 -34
- package/src/realtime_voice_changer.ts +55 -1
- package/src/repair_dereverb.ts +299 -0
- package/src/repair_impulsive.ts +395 -0
- package/src/repair_noise.ts +425 -0
- package/src/repair_trim.ts +226 -0
- package/src/sample_bank.ts +113 -0
- package/src/sonare.js.d.ts +1158 -30
- package/src/stream_analyzer.ts +36 -4
- package/src/stream_types.ts +37 -0
- package/src/streaming_mixing.ts +1 -1
- package/src/streaming_processors.ts +202 -10
- package/src/transcribe.ts +89 -0
- package/src/validation.ts +285 -11
- package/src/web_midi.ts +1 -6
- package/src/worker.ts +18 -2
- package/src/worklet/audio_types.ts +37 -0
- package/src/worklet/engine-mixer-facade.ts +800 -32
- package/src/worklet/engine-node.ts +99 -29
- package/src/worklet/engine-offline.ts +14 -8
- package/src/worklet/engine-parameter-facade.ts +21 -0
- package/src/worklet/engine-processor.ts +332 -93
- package/src/worklet/engine-register.ts +32 -18
- package/src/worklet/engine-strips.ts +275 -9
- package/src/worklet/engine-sync.ts +20 -7
- package/src/worklet/engine.ts +394 -48
- package/src/worklet/guards.ts +195 -44
- package/src/worklet/messages.ts +229 -2
- package/src/worklet/mixer-processor.ts +117 -48
- package/src/worklet/playback-processor.ts +300 -0
- package/src/worklet/protocol.ts +82 -11
- package/src/worklet/voice-changer-processor.ts +17 -11
- package/src/worklet.ts +17 -0
- package/src/effects_transform.ts +0 -718
- package/src/mastering_repair.ts +0 -273
package/src/mastering_chain.ts
CHANGED
|
@@ -7,11 +7,170 @@ import type {
|
|
|
7
7
|
MasteringPreset,
|
|
8
8
|
} from './public_types';
|
|
9
9
|
import type { ProgressCallback } from './sonare.js';
|
|
10
|
+
import type { ValidateOptions } from './validation';
|
|
11
|
+
import { assertSamples } from './validation';
|
|
10
12
|
|
|
11
13
|
function requireModule() {
|
|
12
14
|
return getSonareModule();
|
|
13
15
|
}
|
|
14
16
|
|
|
17
|
+
export type NormalizeMode = 'peak' | 'rms';
|
|
18
|
+
|
|
19
|
+
// `context` is the calling entry point's name: the refusal is about that
|
|
20
|
+
// caller's argument, so naming a fixed one would send a normalizeStereo user
|
|
21
|
+
// looking at normalize.
|
|
22
|
+
function resolveNormalizeMode(value: unknown, context = 'normalize'): NormalizeMode {
|
|
23
|
+
if (value === undefined) {
|
|
24
|
+
return 'peak';
|
|
25
|
+
}
|
|
26
|
+
if (typeof value !== 'string') {
|
|
27
|
+
throw new TypeError(`${context}: mode must be the string 'peak' or 'rms'`);
|
|
28
|
+
}
|
|
29
|
+
if (value !== 'peak' && value !== 'rms') {
|
|
30
|
+
throw new RangeError(`${context}: mode must be the string 'peak' or 'rms'`);
|
|
31
|
+
}
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface NormalizeRequest extends ValidateOptions {
|
|
36
|
+
samples: Float32Array;
|
|
37
|
+
sampleRate?: number;
|
|
38
|
+
targetDb?: number;
|
|
39
|
+
mode?: NormalizeMode;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Normalize audio to a target peak or RMS level.
|
|
44
|
+
*
|
|
45
|
+
* @param samples - Audio samples (mono, float32)
|
|
46
|
+
* @param sampleRate - Sample rate in Hz (default: 22050)
|
|
47
|
+
* @param targetDb - Finite target at or below 0 dBFS (default: 0 dB = full scale).
|
|
48
|
+
* For `mode: 'peak'`, this is the peak target; for `mode: 'rms'`, this is the RMS target.
|
|
49
|
+
* @param mode - Normalization mode: `'peak'` (default) or `'rms'`.
|
|
50
|
+
* @returns Normalized audio
|
|
51
|
+
*/
|
|
52
|
+
export function normalize(request: NormalizeRequest): Float32Array;
|
|
53
|
+
export function normalize(
|
|
54
|
+
samples: Float32Array,
|
|
55
|
+
sampleRate: number,
|
|
56
|
+
targetDb?: number,
|
|
57
|
+
options?: ValidateOptions,
|
|
58
|
+
): Float32Array;
|
|
59
|
+
export function normalize(
|
|
60
|
+
samples: Float32Array,
|
|
61
|
+
sampleRate: number,
|
|
62
|
+
targetDb?: number,
|
|
63
|
+
mode?: NormalizeMode,
|
|
64
|
+
options?: ValidateOptions,
|
|
65
|
+
): Float32Array;
|
|
66
|
+
export function normalize(
|
|
67
|
+
samples: Float32Array | NormalizeRequest,
|
|
68
|
+
sampleRate?: number,
|
|
69
|
+
targetDb = 0.0,
|
|
70
|
+
modeOrOptions: NormalizeMode | ValidateOptions = 'peak',
|
|
71
|
+
options: ValidateOptions = {},
|
|
72
|
+
): Float32Array {
|
|
73
|
+
if (
|
|
74
|
+
modeOrOptions !== undefined &&
|
|
75
|
+
modeOrOptions !== null &&
|
|
76
|
+
typeof modeOrOptions !== 'string' &&
|
|
77
|
+
typeof modeOrOptions !== 'object'
|
|
78
|
+
) {
|
|
79
|
+
throw new TypeError("normalize: mode must be the string 'peak' or 'rms'");
|
|
80
|
+
}
|
|
81
|
+
if (modeOrOptions === null) {
|
|
82
|
+
throw new TypeError("normalize: mode must be the string 'peak' or 'rms'");
|
|
83
|
+
}
|
|
84
|
+
const positionalOptions =
|
|
85
|
+
typeof modeOrOptions === 'object' && modeOrOptions !== null ? modeOrOptions : options;
|
|
86
|
+
const positionalMode = typeof modeOrOptions === 'string' ? modeOrOptions : undefined;
|
|
87
|
+
const request: NormalizeRequest =
|
|
88
|
+
samples instanceof Float32Array
|
|
89
|
+
? { samples, sampleRate, targetDb, mode: positionalMode, ...positionalOptions }
|
|
90
|
+
: samples;
|
|
91
|
+
assertSamples('normalize', request.samples, request.validate !== false);
|
|
92
|
+
const mode = resolveNormalizeMode(request.mode);
|
|
93
|
+
return requireModule().normalizeEx(
|
|
94
|
+
request.samples,
|
|
95
|
+
request.sampleRate ?? 22050,
|
|
96
|
+
request.targetDb ?? 0.0,
|
|
97
|
+
mode,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface NormalizeStereoRequest extends ValidateOptions {
|
|
102
|
+
left: Float32Array;
|
|
103
|
+
right: Float32Array;
|
|
104
|
+
sampleRate?: number;
|
|
105
|
+
targetDb?: number;
|
|
106
|
+
mode?: NormalizeMode;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** A normalized channel pair and the gain both channels were moved by. */
|
|
110
|
+
export interface NormalizeStereoResult {
|
|
111
|
+
left: Float32Array;
|
|
112
|
+
right: Float32Array;
|
|
113
|
+
/**
|
|
114
|
+
* One figure rather than a pair: the gain is one decision shared by both
|
|
115
|
+
* channels. Silence leaves the pair untouched and reports 0.
|
|
116
|
+
*/
|
|
117
|
+
appliedGainDb: number;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Normalize a stereo pair on a gain measured across both channels.
|
|
122
|
+
*
|
|
123
|
+
* Normalizing the two channels separately lifts the quieter one until the peaks
|
|
124
|
+
* match, which changes the balance rather than the level. The level here is read
|
|
125
|
+
* from the pair and the resulting gain goes to both channels, so the image is
|
|
126
|
+
* preserved: for `mode: 'peak'` the louder channel reaches `targetDb` and the
|
|
127
|
+
* other keeps its distance from it; for `mode: 'rms'` the quantity driven to
|
|
128
|
+
* `targetDb` is the root mean square over both channels' samples together — the
|
|
129
|
+
* quadratic mean of the per-channel figures, not their average — and the output
|
|
130
|
+
* is hard-clipped to [-1, 1].
|
|
131
|
+
*
|
|
132
|
+
* @param request.left - Left channel samples (float32)
|
|
133
|
+
* @param request.right - Right channel samples, same length as `left`
|
|
134
|
+
* @param request.sampleRate - Sample rate in Hz (default: 22050)
|
|
135
|
+
* @param request.targetDb - Finite target at or below 0 dBFS. Defaults to 0 for
|
|
136
|
+
* `mode: 'peak'` and -20 for `mode: 'rms'`, matching the library and the other
|
|
137
|
+
* language surfaces.
|
|
138
|
+
* @param request.mode - `'peak'` (default) or `'rms'`
|
|
139
|
+
* @returns The normalized pair and the shared gain in dB
|
|
140
|
+
* @throws RangeError when the two channels differ in length
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```ts
|
|
144
|
+
* const { left, right, appliedGainDb } = normalizeStereo({
|
|
145
|
+
* left: leftSamples,
|
|
146
|
+
* right: rightSamples,
|
|
147
|
+
* sampleRate: 44100,
|
|
148
|
+
* targetDb: -1,
|
|
149
|
+
* });
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
export function normalizeStereo(request: NormalizeStereoRequest): NormalizeStereoResult {
|
|
153
|
+
assertSamples('normalizeStereo', request.left, request.validate !== false);
|
|
154
|
+
assertSamples('normalizeStereo', request.right, request.validate !== false);
|
|
155
|
+
if (request.left.length !== request.right.length) {
|
|
156
|
+
throw new RangeError('Stereo channel lengths must match.');
|
|
157
|
+
}
|
|
158
|
+
const mode = resolveNormalizeMode(request.mode, 'normalizeStereo');
|
|
159
|
+
// Mode-dependent, unlike the mono `normalize` on this surface, which defaults
|
|
160
|
+
// to 0 dB in both modes. 0 dBFS RMS is not a usable default -- the peaks sit
|
|
161
|
+
// well above the RMS, so every one of them clips -- and the library and the
|
|
162
|
+
// other surfaces all default RMS to -20. A new entry point takes the shared
|
|
163
|
+
// default rather than inheriting a surface-local one.
|
|
164
|
+
const targetDb = request.targetDb ?? (mode === 'rms' ? -20.0 : 0.0);
|
|
165
|
+
return requireModule().normalizeStereo(
|
|
166
|
+
request.left,
|
|
167
|
+
request.right,
|
|
168
|
+
request.sampleRate ?? 22050,
|
|
169
|
+
targetDb,
|
|
170
|
+
mode,
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
15
174
|
/** Internal envelope selecting the core dotted-param parser in the embind layer. */
|
|
16
175
|
function canonicalChainConfig(config: MasteringChainConfig): Record<string, unknown> {
|
|
17
176
|
return { __flatParams: flattenChainConfig(config) };
|
|
@@ -279,6 +438,31 @@ export function masteringPresetNames(): MasteringPreset[] {
|
|
|
279
438
|
return Array.from(requireModule().masteringPresetNames()) as MasteringPreset[];
|
|
280
439
|
}
|
|
281
440
|
|
|
441
|
+
/**
|
|
442
|
+
* The flat `{key: number|boolean}` params of preset `preset`'s built-in chain
|
|
443
|
+
* configuration, in the same key space {@link masteringAssistantSuggestChain}
|
|
444
|
+
* returns. Passing this straight through as `overrides` to {@link masterAudio}
|
|
445
|
+
* reproduces the preset unchanged, bit for bit in the C++ core.
|
|
446
|
+
*
|
|
447
|
+
* @param preset - Preset identifier from {@link masteringPresetNames}.
|
|
448
|
+
* @throws For an unknown `preset`.
|
|
449
|
+
*/
|
|
450
|
+
export function masteringPresetParams(preset: MasteringPreset): Record<string, number | boolean> {
|
|
451
|
+
return requireModule().masteringPresetParams(preset);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* List the delivery targets the mastering assistant accepts as `targetPlatform`.
|
|
456
|
+
*
|
|
457
|
+
* Read from the library rather than from a list kept here, so a target added in
|
|
458
|
+
* the core is discoverable without a binding change.
|
|
459
|
+
*
|
|
460
|
+
* @returns Target names in index order (e.g. "streaming", "broadcast", "club")
|
|
461
|
+
*/
|
|
462
|
+
export function masteringPlatformNames(): string[] {
|
|
463
|
+
return Array.from(requireModule().masteringPlatformNames());
|
|
464
|
+
}
|
|
465
|
+
|
|
282
466
|
/**
|
|
283
467
|
* Apply a named mastering preset chain to mono audio.
|
|
284
468
|
*
|