@libraz/libsonare 1.7.2 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +6 -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 +873 -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 +477 -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 +129 -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 +3758 -1362
- 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 +457 -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 +652 -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 +510 -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 +164 -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 +850 -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 +3909 -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 +335 -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 +128 -0
- package/dist/worklet/engine-mixer-facade.d.ts.map +1 -0
- package/dist/worklet/engine-node.d.ts +81 -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 +68 -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 +73 -0
- package/dist/worklet/engine-strips.d.ts.map +1 -0
- package/dist/worklet/engine-sync.d.ts +37 -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 +397 -0
- package/dist/worklet/engine.d.ts.map +1 -0
- package/dist/worklet/guards.d.ts +47 -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 +323 -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 +2763 -501
- package/dist/worklet.js.map +1 -1
- package/package.json +23 -12
- package/src/_effects_common.ts +17 -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 +97 -22
- package/src/effects_note_ops.ts +635 -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 +377 -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 +282 -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 +346 -32
- package/src/mastering_dynamics.ts +22 -11
- package/src/metering.ts +67 -24
- package/src/mixer.ts +212 -3
- 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 +268 -270
- package/src/public_types.ts +122 -3
- package/src/public_types_acoustic.ts +112 -3
- package/src/public_types_mastering.ts +254 -73
- package/src/public_types_mixing.ts +363 -1
- package/src/public_types_music.ts +312 -2
- package/src/public_types_playback.ts +195 -0
- package/src/public_types_realtime.ts +39 -7
- package/src/public_types_repair.ts +446 -0
- package/src/public_types_spectral.ts +487 -1
- package/src/quick_analysis.ts +203 -26
- package/src/realtime_engine.ts +711 -28
- 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 +1122 -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 +194 -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 +444 -10
- package/src/worklet/engine-node.ts +78 -26
- package/src/worklet/engine-offline.ts +14 -8
- package/src/worklet/engine-parameter-facade.ts +21 -0
- package/src/worklet/engine-processor.ts +272 -83
- package/src/worklet/engine-register.ts +32 -18
- package/src/worklet/engine-strips.ts +280 -9
- package/src/worklet/engine-sync.ts +14 -6
- package/src/worklet/engine.ts +365 -31
- package/src/worklet/guards.ts +140 -44
- package/src/worklet/messages.ts +227 -2
- package/src/worklet/mixer-processor.ts +109 -47
- package/src/worklet/playback-processor.ts +300 -0
- package/src/worklet/protocol.ts +53 -3
- 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
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Impulsive-defect repair: declick, declip and decrackle, with their detectors.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { getSonareModule } from './module_state';
|
|
6
|
+
import type {
|
|
7
|
+
ClickDetection,
|
|
8
|
+
ClipDetection,
|
|
9
|
+
CrackleDetection,
|
|
10
|
+
MasteringRepairDeclickStereoResult,
|
|
11
|
+
MasteringRepairDeclipStereoResult,
|
|
12
|
+
MasteringRepairDecrackleStereoResult,
|
|
13
|
+
} from './public_types_repair';
|
|
14
|
+
|
|
15
|
+
function requireModule() {
|
|
16
|
+
return getSonareModule();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Options for `masteringRepairDeclick`. */
|
|
20
|
+
export interface DeclickOptions {
|
|
21
|
+
threshold?: number;
|
|
22
|
+
neighborRatio?: number;
|
|
23
|
+
maxClickSamples?: number;
|
|
24
|
+
lpcOrder?: number;
|
|
25
|
+
residualRatio?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface MasteringRepairDeclickRequest extends DeclickOptions {
|
|
29
|
+
samples: Float32Array;
|
|
30
|
+
sampleRate: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Request form of `masteringRepairDeclickStereo`. */
|
|
34
|
+
export interface MasteringRepairDeclickStereoRequest extends DeclickOptions {
|
|
35
|
+
left: Float32Array;
|
|
36
|
+
right: Float32Array;
|
|
37
|
+
sampleRate?: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Offline LPC-based declicker for a stereo pair.
|
|
42
|
+
*
|
|
43
|
+
* A run either channel's own detection selects is repaired in BOTH channels —
|
|
44
|
+
* a common-mode click repaired on one side only would move the stereo image.
|
|
45
|
+
* Only the selection is shared: each channel's fill is computed from its own
|
|
46
|
+
* samples and its own AR model, which is why `leftReport` and `rightReport`
|
|
47
|
+
* genuinely differ. Prefer this over calling `masteringRepairDeclick` on each
|
|
48
|
+
* channel separately whenever a click may land in only one channel — a
|
|
49
|
+
* per-channel pass never repairs the other side's image-shifting click.
|
|
50
|
+
*/
|
|
51
|
+
export function masteringRepairDeclickStereo(
|
|
52
|
+
request: MasteringRepairDeclickStereoRequest,
|
|
53
|
+
): MasteringRepairDeclickStereoResult;
|
|
54
|
+
export function masteringRepairDeclickStereo(
|
|
55
|
+
left: Float32Array,
|
|
56
|
+
right: Float32Array,
|
|
57
|
+
sampleRate: number,
|
|
58
|
+
config?: DeclickOptions,
|
|
59
|
+
): MasteringRepairDeclickStereoResult;
|
|
60
|
+
export function masteringRepairDeclickStereo(
|
|
61
|
+
left: Float32Array | MasteringRepairDeclickStereoRequest,
|
|
62
|
+
right?: Float32Array,
|
|
63
|
+
sampleRate?: number,
|
|
64
|
+
config: DeclickOptions = {},
|
|
65
|
+
): MasteringRepairDeclickStereoResult {
|
|
66
|
+
const request: MasteringRepairDeclickStereoRequest =
|
|
67
|
+
left instanceof Float32Array
|
|
68
|
+
? { left, right: right as Float32Array, sampleRate, ...config }
|
|
69
|
+
: left;
|
|
70
|
+
const { left: leftSamples, right: rightSamples, sampleRate: rate, ...options } = request;
|
|
71
|
+
return requireModule().masteringRepairDeclickStereo(
|
|
72
|
+
leftSamples,
|
|
73
|
+
rightSamples,
|
|
74
|
+
rate ?? 22050,
|
|
75
|
+
options,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Offline LPC-based declicker. */
|
|
80
|
+
export function masteringRepairDeclick(request: MasteringRepairDeclickRequest): Float32Array;
|
|
81
|
+
export function masteringRepairDeclick(
|
|
82
|
+
samples: Float32Array,
|
|
83
|
+
sampleRate: number,
|
|
84
|
+
options?: DeclickOptions,
|
|
85
|
+
): Float32Array;
|
|
86
|
+
export function masteringRepairDeclick(
|
|
87
|
+
samples: Float32Array | MasteringRepairDeclickRequest,
|
|
88
|
+
sampleRate?: number,
|
|
89
|
+
options: DeclickOptions = {},
|
|
90
|
+
): Float32Array {
|
|
91
|
+
const request =
|
|
92
|
+
samples instanceof Float32Array
|
|
93
|
+
? { samples, sampleRate: sampleRate as number, ...options }
|
|
94
|
+
: samples;
|
|
95
|
+
return requireModule().masteringRepairDeclick(request.samples, request.sampleRate, request);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Options for `masteringRepairDeclip`. */
|
|
99
|
+
export interface DeclipOptions {
|
|
100
|
+
clipThreshold?: number;
|
|
101
|
+
lpcOrder?: number;
|
|
102
|
+
iterations?: number;
|
|
103
|
+
lpcBlend?: number;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface MasteringRepairDeclipRequest extends DeclipOptions {
|
|
107
|
+
samples: Float32Array;
|
|
108
|
+
sampleRate: number;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Request form of `masteringRepairDeclipStereo`. */
|
|
112
|
+
export interface MasteringRepairDeclipStereoRequest extends DeclipOptions {
|
|
113
|
+
left: Float32Array;
|
|
114
|
+
right: Float32Array;
|
|
115
|
+
sampleRate?: number;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Algorithms accepted by `masteringRepairDecrackle`. */
|
|
119
|
+
export type DecrackleMode = 'median' | 'waveletShrinkage';
|
|
120
|
+
|
|
121
|
+
/** Options for `masteringRepairDecrackle`. */
|
|
122
|
+
export interface DecrackleOptions {
|
|
123
|
+
threshold?: number;
|
|
124
|
+
mode?: DecrackleMode;
|
|
125
|
+
levels?: number;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface MasteringRepairDecrackleRequest extends DecrackleOptions {
|
|
129
|
+
samples: Float32Array;
|
|
130
|
+
sampleRate: number;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Request form of `masteringRepairDecrackleStereo`. */
|
|
134
|
+
export interface MasteringRepairDecrackleStereoRequest extends DecrackleOptions {
|
|
135
|
+
left: Float32Array;
|
|
136
|
+
right: Float32Array;
|
|
137
|
+
sampleRate?: number;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Offline LPC-based declipper.
|
|
142
|
+
*
|
|
143
|
+
* Only clipped runs of at most 512 consecutive samples are reconstructed with the LPC solver.
|
|
144
|
+
* The cap is a fixed sample count: it is not derived from `lpcOrder`, from `sampleRate`, or from
|
|
145
|
+
* any other option, so its duration depends on the rate (~10.7 ms at 48 kHz). A longer run is
|
|
146
|
+
* filled with cubic / linear interpolation instead, which keeps the solver's dense matrices
|
|
147
|
+
* bounded by the cap rather than by the input. Exceeding the cap silently changes the
|
|
148
|
+
* reconstruction method rather than throwing: `lpcOrder`, `iterations` and `lpcBlend` have no
|
|
149
|
+
* effect on the interpolated run.
|
|
150
|
+
*/
|
|
151
|
+
export function masteringRepairDeclip(request: MasteringRepairDeclipRequest): Float32Array;
|
|
152
|
+
export function masteringRepairDeclip(
|
|
153
|
+
samples: Float32Array,
|
|
154
|
+
sampleRate: number,
|
|
155
|
+
options?: DeclipOptions,
|
|
156
|
+
): Float32Array;
|
|
157
|
+
export function masteringRepairDeclip(
|
|
158
|
+
samples: Float32Array | MasteringRepairDeclipRequest,
|
|
159
|
+
sampleRate?: number,
|
|
160
|
+
options: DeclipOptions = {},
|
|
161
|
+
): Float32Array {
|
|
162
|
+
const request =
|
|
163
|
+
samples instanceof Float32Array
|
|
164
|
+
? { samples, sampleRate: sampleRate as number, ...options }
|
|
165
|
+
: samples;
|
|
166
|
+
return requireModule().masteringRepairDeclip(request.samples, request.sampleRate, request);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Offline LPC-based declipper for a stereo pair.
|
|
171
|
+
*
|
|
172
|
+
* Takes the union of both channels' clipped runs. Each channel reconstructs
|
|
173
|
+
* the whole of every union run it has at least one clipped sample in; a
|
|
174
|
+
* channel with none is left untouched there — reconstructing unclipped audio
|
|
175
|
+
* to match the other side would replace real samples with an estimate. A
|
|
176
|
+
* plateau clipped in only one channel therefore produces no linking:
|
|
177
|
+
* `linkedRuns` is non-zero only where both channels are clipped in the same
|
|
178
|
+
* region with different extents.
|
|
179
|
+
*/
|
|
180
|
+
export function masteringRepairDeclipStereo(
|
|
181
|
+
request: MasteringRepairDeclipStereoRequest,
|
|
182
|
+
): MasteringRepairDeclipStereoResult;
|
|
183
|
+
export function masteringRepairDeclipStereo(
|
|
184
|
+
left: Float32Array,
|
|
185
|
+
right: Float32Array,
|
|
186
|
+
sampleRate: number,
|
|
187
|
+
config?: DeclipOptions,
|
|
188
|
+
): MasteringRepairDeclipStereoResult;
|
|
189
|
+
export function masteringRepairDeclipStereo(
|
|
190
|
+
left: Float32Array | MasteringRepairDeclipStereoRequest,
|
|
191
|
+
right?: Float32Array,
|
|
192
|
+
sampleRate?: number,
|
|
193
|
+
config: DeclipOptions = {},
|
|
194
|
+
): MasteringRepairDeclipStereoResult {
|
|
195
|
+
const request: MasteringRepairDeclipStereoRequest =
|
|
196
|
+
left instanceof Float32Array
|
|
197
|
+
? { left, right: right as Float32Array, sampleRate, ...config }
|
|
198
|
+
: left;
|
|
199
|
+
const { left: leftSamples, right: rightSamples, sampleRate: rate, ...options } = request;
|
|
200
|
+
return requireModule().masteringRepairDeclipStereo(
|
|
201
|
+
leftSamples,
|
|
202
|
+
rightSamples,
|
|
203
|
+
rate ?? 22050,
|
|
204
|
+
options,
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** Offline crackle suppressor (median or wavelet-shrinkage). */
|
|
209
|
+
export function masteringRepairDecrackle(request: MasteringRepairDecrackleRequest): Float32Array;
|
|
210
|
+
export function masteringRepairDecrackle(
|
|
211
|
+
samples: Float32Array,
|
|
212
|
+
sampleRate: number,
|
|
213
|
+
options?: DecrackleOptions,
|
|
214
|
+
): Float32Array;
|
|
215
|
+
export function masteringRepairDecrackle(
|
|
216
|
+
samples: Float32Array | MasteringRepairDecrackleRequest,
|
|
217
|
+
sampleRate?: number,
|
|
218
|
+
options: DecrackleOptions = {},
|
|
219
|
+
): Float32Array {
|
|
220
|
+
const request =
|
|
221
|
+
samples instanceof Float32Array
|
|
222
|
+
? { samples, sampleRate: sampleRate as number, ...options }
|
|
223
|
+
: samples;
|
|
224
|
+
return requireModule().masteringRepairDecrackle(request.samples, request.sampleRate, request);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Offline crackle suppressor (median or wavelet-shrinkage) for a stereo pair.
|
|
229
|
+
*
|
|
230
|
+
* Crackle is surface damage: the two channels carry different scratches at different instants,
|
|
231
|
+
* so there is no common event for a shared decision to agree about. Each channel is decrackled
|
|
232
|
+
* on its own -- there is no linking, unlike {@link masteringRepairDeclickStereo} and
|
|
233
|
+
* {@link masteringRepairDeclipStereo} -- and this entry point exists to keep the reports and
|
|
234
|
+
* the channel-length contract in one place.
|
|
235
|
+
*/
|
|
236
|
+
export function masteringRepairDecrackleStereo(
|
|
237
|
+
request: MasteringRepairDecrackleStereoRequest,
|
|
238
|
+
): MasteringRepairDecrackleStereoResult;
|
|
239
|
+
export function masteringRepairDecrackleStereo(
|
|
240
|
+
left: Float32Array,
|
|
241
|
+
right: Float32Array,
|
|
242
|
+
sampleRate: number,
|
|
243
|
+
config?: DecrackleOptions,
|
|
244
|
+
): MasteringRepairDecrackleStereoResult;
|
|
245
|
+
export function masteringRepairDecrackleStereo(
|
|
246
|
+
left: Float32Array | MasteringRepairDecrackleStereoRequest,
|
|
247
|
+
right?: Float32Array,
|
|
248
|
+
sampleRate?: number,
|
|
249
|
+
config: DecrackleOptions = {},
|
|
250
|
+
): MasteringRepairDecrackleStereoResult {
|
|
251
|
+
const request: MasteringRepairDecrackleStereoRequest =
|
|
252
|
+
left instanceof Float32Array
|
|
253
|
+
? { left, right: right as Float32Array, sampleRate, ...config }
|
|
254
|
+
: left;
|
|
255
|
+
const { left: leftSamples, right: rightSamples, sampleRate: rate, ...options } = request;
|
|
256
|
+
return requireModule().masteringRepairDecrackleStereo(
|
|
257
|
+
leftSamples,
|
|
258
|
+
rightSamples,
|
|
259
|
+
rate ?? 22050,
|
|
260
|
+
options,
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** Request form of `masteringRepairDetectClicks`. */
|
|
265
|
+
export interface MasteringRepairDetectClicksRequest extends DeclickOptions {
|
|
266
|
+
samples: Float32Array;
|
|
267
|
+
sampleRate: number;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** Request form of `masteringRepairDetectClipping`. */
|
|
271
|
+
export interface MasteringRepairDetectClippingRequest extends DeclipOptions {
|
|
272
|
+
samples: Float32Array;
|
|
273
|
+
sampleRate: number;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/** Request form of `masteringRepairDetectCrackle`. */
|
|
277
|
+
export interface MasteringRepairDetectCrackleRequest extends DecrackleOptions {
|
|
278
|
+
samples: Float32Array;
|
|
279
|
+
sampleRate: number;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Measures clicks without repairing.
|
|
284
|
+
*
|
|
285
|
+
* Runs the same LPC analysis {@link masteringRepairDeclick} runs, so a run counted here is one
|
|
286
|
+
* the repair would act on — a cheaper threshold-only scan would report runs it leaves alone.
|
|
287
|
+
* That also means the options that shape the repair shape the count: a large `rejected` says
|
|
288
|
+
* `maxClickSamples` or `neighborRatio` is too tight for this material, not that the material is
|
|
289
|
+
* clean.
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* ```ts
|
|
293
|
+
* const detected = masteringRepairDetectClicks({ samples, sampleRate: 48000 });
|
|
294
|
+
* if (detected.perSecond > 1) samples = masteringRepairDeclick({ samples, sampleRate: 48000 });
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
|
+
export function masteringRepairDetectClicks(
|
|
298
|
+
request: MasteringRepairDetectClicksRequest,
|
|
299
|
+
): ClickDetection;
|
|
300
|
+
export function masteringRepairDetectClicks(
|
|
301
|
+
samples: Float32Array,
|
|
302
|
+
sampleRate: number,
|
|
303
|
+
options?: DeclickOptions,
|
|
304
|
+
): ClickDetection;
|
|
305
|
+
export function masteringRepairDetectClicks(
|
|
306
|
+
samples: Float32Array | MasteringRepairDetectClicksRequest,
|
|
307
|
+
sampleRate?: number,
|
|
308
|
+
options: DeclickOptions = {},
|
|
309
|
+
): ClickDetection {
|
|
310
|
+
const request =
|
|
311
|
+
samples instanceof Float32Array
|
|
312
|
+
? { samples, sampleRate: sampleRate as number, ...options }
|
|
313
|
+
: samples;
|
|
314
|
+
return requireModule().masteringRepairDetectClicks(request.samples, request.sampleRate, request);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Measures clipping without repairing.
|
|
319
|
+
*
|
|
320
|
+
* Counts samples at or past `clipThreshold`. No other option reaches the result — `lpcOrder`,
|
|
321
|
+
* `iterations` and `lpcBlend` are validated and then unread, since nothing here is
|
|
322
|
+
* reconstructed. `sampleRate` is validated without being read for the same reason: no field of
|
|
323
|
+
* the result is a rate.
|
|
324
|
+
*
|
|
325
|
+
* Compare `longestRunSamples` against the 512-sample LPC cap to tell in advance which runs
|
|
326
|
+
* {@link masteringRepairDeclip} would fill by interpolation rather than with the solver.
|
|
327
|
+
*
|
|
328
|
+
* `flatRunCount`, `longestFlatRunSamples`, `flatSampleCount` and `flatLevel` answer a different
|
|
329
|
+
* question from the four fields above: those are read against `clipThreshold`, so they count the
|
|
330
|
+
* apex of any waveform that reaches it — a full-scale sine reports thousands of "clipped" samples
|
|
331
|
+
* having never been clipped — and they miss material clipped in one tool and attenuated in the
|
|
332
|
+
* next, which leaves nothing at the threshold. The flat-top fields instead count runs of at least
|
|
333
|
+
* 3 consecutive bit-identical samples whose level sits within 1 dB of the signal's peak, so they
|
|
334
|
+
* catch a clipped-then-attenuated waveform that `sampleCount` reports as clean.
|
|
335
|
+
*
|
|
336
|
+
* Two opposite errors follow from what a flat top actually is. A genuinely flat-topped waveform —
|
|
337
|
+
* a square or pulse train, a fully limited master — counts as clipped here too and cannot be told
|
|
338
|
+
* apart from clipping in the time domain: a false positive. In the other direction, anything that
|
|
339
|
+
* moves the two channels' samples independently before this runs erases a real flat top, so a
|
|
340
|
+
* zero reading is not proof the material was never clipped — a stereo downmix does this, and so
|
|
341
|
+
* do resampling and lossy coding, because the plateau stops being exactly level once each sample
|
|
342
|
+
* is nudged on its own. **Detect each channel of a stereo signal separately, before any downmix,
|
|
343
|
+
* never on the mixed-down result.**
|
|
344
|
+
*/
|
|
345
|
+
export function masteringRepairDetectClipping(
|
|
346
|
+
request: MasteringRepairDetectClippingRequest,
|
|
347
|
+
): ClipDetection;
|
|
348
|
+
export function masteringRepairDetectClipping(
|
|
349
|
+
samples: Float32Array,
|
|
350
|
+
sampleRate: number,
|
|
351
|
+
options?: DeclipOptions,
|
|
352
|
+
): ClipDetection;
|
|
353
|
+
export function masteringRepairDetectClipping(
|
|
354
|
+
samples: Float32Array | MasteringRepairDetectClippingRequest,
|
|
355
|
+
sampleRate?: number,
|
|
356
|
+
options: DeclipOptions = {},
|
|
357
|
+
): ClipDetection {
|
|
358
|
+
const request =
|
|
359
|
+
samples instanceof Float32Array
|
|
360
|
+
? { samples, sampleRate: sampleRate as number, ...options }
|
|
361
|
+
: samples;
|
|
362
|
+
return requireModule().masteringRepairDetectClipping(
|
|
363
|
+
request.samples,
|
|
364
|
+
request.sampleRate,
|
|
365
|
+
request,
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Measures crackle without repairing.
|
|
371
|
+
*
|
|
372
|
+
* Measured by the median criterion whatever `mode` is set to: wavelet shrinkage removes crackle
|
|
373
|
+
* without ever deciding that a sample is crackle, so these counts do not describe what a
|
|
374
|
+
* wavelet-mode repair would remove. A caller therefore gets the same answer before choosing a
|
|
375
|
+
* mode.
|
|
376
|
+
*/
|
|
377
|
+
export function masteringRepairDetectCrackle(
|
|
378
|
+
request: MasteringRepairDetectCrackleRequest,
|
|
379
|
+
): CrackleDetection;
|
|
380
|
+
export function masteringRepairDetectCrackle(
|
|
381
|
+
samples: Float32Array,
|
|
382
|
+
sampleRate: number,
|
|
383
|
+
options?: DecrackleOptions,
|
|
384
|
+
): CrackleDetection;
|
|
385
|
+
export function masteringRepairDetectCrackle(
|
|
386
|
+
samples: Float32Array | MasteringRepairDetectCrackleRequest,
|
|
387
|
+
sampleRate?: number,
|
|
388
|
+
options: DecrackleOptions = {},
|
|
389
|
+
): CrackleDetection {
|
|
390
|
+
const request =
|
|
391
|
+
samples instanceof Float32Array
|
|
392
|
+
? { samples, sampleRate: sampleRate as number, ...options }
|
|
393
|
+
: samples;
|
|
394
|
+
return requireModule().masteringRepairDetectCrackle(request.samples, request.sampleRate, request);
|
|
395
|
+
}
|