@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,161 @@
|
|
|
1
|
+
import { getSonareModule } from './module_state';
|
|
2
|
+
|
|
3
|
+
function requireModule() {
|
|
4
|
+
return getSonareModule();
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Mastering repair (declick, denoise_classical, declip, decrackle, dehum,
|
|
9
|
+
// dereverb_classical, trim_silence) — hand-written bindings.
|
|
10
|
+
// ============================================================================
|
|
11
|
+
|
|
12
|
+
/** Options for `masteringRepairDeclick`. */
|
|
13
|
+
export interface DeclickOptions {
|
|
14
|
+
threshold?: number;
|
|
15
|
+
neighborRatio?: number;
|
|
16
|
+
maxClickSamples?: number;
|
|
17
|
+
lpcOrder?: number;
|
|
18
|
+
residualRatio?: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Algorithms accepted by `masteringRepairDenoiseClassical`. */
|
|
22
|
+
export type DenoiseClassicalMode = 'logMmse' | 'mmseStsa' | 'spectralSubtraction';
|
|
23
|
+
|
|
24
|
+
/** Noise PSD estimators accepted by `masteringRepairDenoiseClassical`. */
|
|
25
|
+
export type DenoiseClassicalNoiseEstimator = 'quantile' | 'mcra' | 'imcra';
|
|
26
|
+
|
|
27
|
+
/** Options for `masteringRepairDenoiseClassical`. */
|
|
28
|
+
export interface DenoiseClassicalOptions {
|
|
29
|
+
mode?: DenoiseClassicalMode;
|
|
30
|
+
noiseEstimator?: DenoiseClassicalNoiseEstimator;
|
|
31
|
+
nFft?: number;
|
|
32
|
+
hopLength?: number;
|
|
33
|
+
ddAlpha?: number;
|
|
34
|
+
gainFloor?: number;
|
|
35
|
+
overSubtraction?: number;
|
|
36
|
+
spectralFloor?: number;
|
|
37
|
+
noiseEstimationQuantile?: number;
|
|
38
|
+
speechPresenceGain?: boolean;
|
|
39
|
+
gainSmoothing?: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Offline LPC-based declicker. */
|
|
43
|
+
export function masteringRepairDeclick(
|
|
44
|
+
samples: Float32Array,
|
|
45
|
+
sampleRate: number,
|
|
46
|
+
options: DeclickOptions = {},
|
|
47
|
+
): Float32Array {
|
|
48
|
+
return requireModule().masteringRepairDeclick(samples, sampleRate, options);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Offline STFT-domain classical denoiser (LogMMSE / MMSE-STSA / SpectralSubtraction). */
|
|
52
|
+
export function masteringRepairDenoiseClassical(
|
|
53
|
+
samples: Float32Array,
|
|
54
|
+
sampleRate: number,
|
|
55
|
+
options: DenoiseClassicalOptions = {},
|
|
56
|
+
): Float32Array {
|
|
57
|
+
return requireModule().masteringRepairDenoiseClassical(samples, sampleRate, options);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Options for `masteringRepairDeclip`. */
|
|
61
|
+
export interface DeclipOptions {
|
|
62
|
+
clipThreshold?: number;
|
|
63
|
+
lpcOrder?: number;
|
|
64
|
+
iterations?: number;
|
|
65
|
+
lpcBlend?: number;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Algorithms accepted by `masteringRepairDecrackle`. */
|
|
69
|
+
export type DecrackleMode = 'median' | 'waveletShrinkage';
|
|
70
|
+
|
|
71
|
+
/** Options for `masteringRepairDecrackle`. */
|
|
72
|
+
export interface DecrackleOptions {
|
|
73
|
+
threshold?: number;
|
|
74
|
+
mode?: DecrackleMode;
|
|
75
|
+
levels?: number;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Options for `masteringRepairDehum`. */
|
|
79
|
+
export interface DehumOptions {
|
|
80
|
+
fundamentalHz?: number;
|
|
81
|
+
harmonics?: number;
|
|
82
|
+
q?: number;
|
|
83
|
+
adaptive?: boolean;
|
|
84
|
+
searchRangeHz?: number;
|
|
85
|
+
adaptation?: number;
|
|
86
|
+
frameSize?: number;
|
|
87
|
+
pllBandwidth?: number;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Options for `masteringRepairDereverbClassical`. */
|
|
91
|
+
export interface DereverbClassicalOptions {
|
|
92
|
+
threshold?: number;
|
|
93
|
+
attenuation?: number;
|
|
94
|
+
nFft?: number;
|
|
95
|
+
hopLength?: number;
|
|
96
|
+
t60Sec?: number;
|
|
97
|
+
lateDelayMs?: number;
|
|
98
|
+
overSubtraction?: number;
|
|
99
|
+
spectralFloor?: number;
|
|
100
|
+
wpeEnabled?: boolean;
|
|
101
|
+
wpeIterations?: number;
|
|
102
|
+
wpeTaps?: number;
|
|
103
|
+
wpeStrength?: number;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Trimming modes accepted by `masteringRepairTrimSilence`. */
|
|
107
|
+
export type TrimSilenceMode = 'peak' | 'lufsGated';
|
|
108
|
+
|
|
109
|
+
/** Options for `masteringRepairTrimSilence`. */
|
|
110
|
+
export interface TrimSilenceOptions {
|
|
111
|
+
threshold?: number;
|
|
112
|
+
paddingSamples?: number;
|
|
113
|
+
mode?: TrimSilenceMode;
|
|
114
|
+
gateLufs?: number;
|
|
115
|
+
windowMs?: number;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Offline LPC-based declipper. */
|
|
119
|
+
export function masteringRepairDeclip(
|
|
120
|
+
samples: Float32Array,
|
|
121
|
+
sampleRate: number,
|
|
122
|
+
options: DeclipOptions = {},
|
|
123
|
+
): Float32Array {
|
|
124
|
+
return requireModule().masteringRepairDeclip(samples, sampleRate, options);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Offline crackle suppressor (median or wavelet-shrinkage). */
|
|
128
|
+
export function masteringRepairDecrackle(
|
|
129
|
+
samples: Float32Array,
|
|
130
|
+
sampleRate: number,
|
|
131
|
+
options: DecrackleOptions = {},
|
|
132
|
+
): Float32Array {
|
|
133
|
+
return requireModule().masteringRepairDecrackle(samples, sampleRate, options);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Offline mains-hum remover. */
|
|
137
|
+
export function masteringRepairDehum(
|
|
138
|
+
samples: Float32Array,
|
|
139
|
+
sampleRate: number,
|
|
140
|
+
options: DehumOptions = {},
|
|
141
|
+
): Float32Array {
|
|
142
|
+
return requireModule().masteringRepairDehum(samples, sampleRate, options);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Offline classical dereverberator (spectral subtraction + optional WPE). */
|
|
146
|
+
export function masteringRepairDereverbClassical(
|
|
147
|
+
samples: Float32Array,
|
|
148
|
+
sampleRate: number,
|
|
149
|
+
options: DereverbClassicalOptions = {},
|
|
150
|
+
): Float32Array {
|
|
151
|
+
return requireModule().masteringRepairDereverbClassical(samples, sampleRate, options);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** Offline silence trimmer (peak threshold or LUFS-gated). */
|
|
155
|
+
export function masteringRepairTrimSilence(
|
|
156
|
+
samples: Float32Array,
|
|
157
|
+
sampleRate: number,
|
|
158
|
+
options: TrimSilenceOptions = {},
|
|
159
|
+
): Float32Array {
|
|
160
|
+
return requireModule().masteringRepairTrimSilence(samples, sampleRate, options);
|
|
161
|
+
}
|
package/src/mixer.ts
CHANGED
|
@@ -522,6 +522,14 @@ export class Mixer {
|
|
|
522
522
|
return this.mixer.tailSamples();
|
|
523
523
|
}
|
|
524
524
|
|
|
525
|
+
/**
|
|
526
|
+
* Reported latency (samples) of the compiled mixer graph, for aligning
|
|
527
|
+
* dry/wet material. Lazily compiles the routing graph if the topology is dirty.
|
|
528
|
+
*/
|
|
529
|
+
latencySamples(): number {
|
|
530
|
+
return this.mixer.latencySamples();
|
|
531
|
+
}
|
|
532
|
+
|
|
525
533
|
/**
|
|
526
534
|
* Drain delayed / tail audio by processing a zero-input block of `numSamples`
|
|
527
535
|
* frames after the host stops feeding strip inputs. Returns the mixed stereo
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { getSonareModule } from './module_state';
|
|
2
|
+
import type { MixOptions, MixResult } from './public_types';
|
|
3
|
+
|
|
4
|
+
function requireModule() {
|
|
5
|
+
return getSonareModule();
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function mixingScenePresetNames(): string[] {
|
|
9
|
+
return Array.from(requireModule().mixingScenePresetNames());
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Get a built-in mixing scene preset serialized as JSON. This is the canonical
|
|
14
|
+
* name shared with the Node and Python bindings; the returned JSON loads
|
|
15
|
+
* directly into a {@link Mixer} via {@link Mixer.fromSceneJson}.
|
|
16
|
+
*
|
|
17
|
+
* @param presetName - Preset name (see {@link mixingScenePresetNames})
|
|
18
|
+
* @returns Scene JSON string
|
|
19
|
+
*/
|
|
20
|
+
export function mixingScenePresetJson(presetName: string): string {
|
|
21
|
+
return requireModule().mixingScenePresetJson(presetName);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* One-shot stereo mix of multiple strips through the routing graph + master bus.
|
|
26
|
+
*
|
|
27
|
+
* Each returned per-strip meter reflects only this single one-shot block. The
|
|
28
|
+
* integrating-meter fields (`momentaryLufs`, `shortTermLufs`, `integratedLufs`
|
|
29
|
+
* and the true-peak fields) require sustained streaming to populate; on a short
|
|
30
|
+
* one-shot mix they read the -120 dB floor sentinel. Drive a streaming
|
|
31
|
+
* {@link Mixer} block-by-block if you need meaningful loudness/true-peak
|
|
32
|
+
* readings.
|
|
33
|
+
*
|
|
34
|
+
* @param leftChannels - Per-strip left input buffers (all the same length)
|
|
35
|
+
* @param rightChannels - Per-strip right input buffers (all the same length)
|
|
36
|
+
* @param sampleRate - Sample rate in Hz
|
|
37
|
+
* @param options - Per-strip mix options (trim, fader, pan, width, mute)
|
|
38
|
+
*/
|
|
39
|
+
export function mixStereo(
|
|
40
|
+
leftChannels: Float32Array[],
|
|
41
|
+
rightChannels: Float32Array[],
|
|
42
|
+
sampleRate = 48000,
|
|
43
|
+
options: MixOptions = {},
|
|
44
|
+
): MixResult {
|
|
45
|
+
if (leftChannels.length === 0 || leftChannels.length !== rightChannels.length) {
|
|
46
|
+
throw new Error('leftChannels and rightChannels must have the same non-zero length.');
|
|
47
|
+
}
|
|
48
|
+
return requireModule().mixStereo(
|
|
49
|
+
leftChannels,
|
|
50
|
+
rightChannels,
|
|
51
|
+
sampleRate,
|
|
52
|
+
options as Record<string, unknown>,
|
|
53
|
+
);
|
|
54
|
+
}
|
package/src/module_state.ts
CHANGED
|
@@ -65,8 +65,7 @@ function makeSonareError(raw: SonareModule, thrown: number): SonareError {
|
|
|
65
65
|
* {@link SonareError}. Only function-valued
|
|
66
66
|
* members are wrapped, and the wrapper is cached per member so repeated access
|
|
67
67
|
* stays cheap; non-function members (typed-array heap views, etc.) pass through
|
|
68
|
-
* unchanged.
|
|
69
|
-
* affected by this wrapper.
|
|
68
|
+
* unchanged.
|
|
70
69
|
*/
|
|
71
70
|
function wrapModuleErrors(raw: SonareModule): SonareModule {
|
|
72
71
|
const cache = new Map<PropertyKey, unknown>();
|