@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.
Files changed (303) hide show
  1. package/NOTICE +178 -0
  2. package/README.md +26 -203
  3. package/dist/_chain_config.d.ts +14 -0
  4. package/dist/_chain_config.d.ts.map +1 -0
  5. package/dist/_effects_common.d.ts +7 -0
  6. package/dist/_effects_common.d.ts.map +1 -0
  7. package/dist/_feature_validation.d.ts +8 -0
  8. package/dist/_feature_validation.d.ts.map +1 -0
  9. package/dist/_fft_options.d.ts +24 -0
  10. package/dist/_fft_options.d.ts.map +1 -0
  11. package/dist/align_take.d.ts +50 -0
  12. package/dist/align_take.d.ts.map +1 -0
  13. package/dist/analysis.d.ts +29 -5840
  14. package/dist/analysis.d.ts.map +1 -0
  15. package/dist/analysis.js +874 -722
  16. package/dist/analysis.js.map +1 -1
  17. package/dist/analysis_helpers.d.ts +9 -0
  18. package/dist/analysis_helpers.d.ts.map +1 -0
  19. package/dist/audio.d.ts +163 -0
  20. package/dist/audio.d.ts.map +1 -0
  21. package/dist/clip_page_streamer.d.ts +133 -0
  22. package/dist/clip_page_streamer.d.ts.map +1 -0
  23. package/dist/codes.d.ts +44 -0
  24. package/dist/codes.d.ts.map +1 -0
  25. package/dist/effects_mastering.d.ts +23 -0
  26. package/dist/effects_mastering.d.ts.map +1 -0
  27. package/dist/effects_note_ops.d.ts +502 -0
  28. package/dist/effects_note_ops.d.ts.map +1 -0
  29. package/dist/effects_percussive.d.ts +185 -0
  30. package/dist/effects_percussive.d.ts.map +1 -0
  31. package/dist/effects_separation.d.ts +65 -0
  32. package/dist/effects_separation.d.ts.map +1 -0
  33. package/dist/effects_spectral.d.ts +28 -0
  34. package/dist/effects_spectral.d.ts.map +1 -0
  35. package/dist/effects_timepitch.d.ts +134 -0
  36. package/dist/effects_timepitch.d.ts.map +1 -0
  37. package/dist/effects_voice_change.d.ts +53 -0
  38. package/dist/effects_voice_change.d.ts.map +1 -0
  39. package/dist/errors.d.ts +51 -0
  40. package/dist/errors.d.ts.map +1 -0
  41. package/dist/feature_core.d.ts +341 -0
  42. package/dist/feature_core.d.ts.map +1 -0
  43. package/dist/feature_decompose.d.ts +278 -0
  44. package/dist/feature_decompose.d.ts.map +1 -0
  45. package/dist/feature_inverse.d.ts +128 -0
  46. package/dist/feature_inverse.d.ts.map +1 -0
  47. package/dist/feature_loudness.d.ts +66 -0
  48. package/dist/feature_loudness.d.ts.map +1 -0
  49. package/dist/feature_music.d.ts +307 -0
  50. package/dist/feature_music.d.ts.map +1 -0
  51. package/dist/feature_pitch.d.ts +108 -0
  52. package/dist/feature_pitch.d.ts.map +1 -0
  53. package/dist/feature_resample.d.ts +16 -0
  54. package/dist/feature_resample.d.ts.map +1 -0
  55. package/dist/feature_spectral.d.ts +137 -0
  56. package/dist/feature_spectral.d.ts.map +1 -0
  57. package/dist/feature_spectrogram.d.ts +198 -0
  58. package/dist/feature_spectrogram.d.ts.map +1 -0
  59. package/dist/features.d.ts +10 -0
  60. package/dist/features.d.ts.map +1 -0
  61. package/dist/hrtf/default.shrf +0 -0
  62. package/dist/index.d.ts +74 -7431
  63. package/dist/index.d.ts.map +1 -0
  64. package/dist/index.js +4173 -1621
  65. package/dist/index.js.map +1 -1
  66. package/dist/instrument_types.d.ts +517 -0
  67. package/dist/instrument_types.d.ts.map +1 -0
  68. package/dist/live_audio.d.ts +35 -0
  69. package/dist/live_audio.d.ts.map +1 -0
  70. package/dist/mastering_chain.d.ts +213 -0
  71. package/dist/mastering_chain.d.ts.map +1 -0
  72. package/dist/mastering_core.d.ts +483 -0
  73. package/dist/mastering_core.d.ts.map +1 -0
  74. package/dist/mastering_dynamics.d.ts +80 -0
  75. package/dist/mastering_dynamics.d.ts.map +1 -0
  76. package/dist/metering.d.ts +287 -0
  77. package/dist/metering.d.ts.map +1 -0
  78. package/dist/mixer.d.ts +464 -0
  79. package/dist/mixer.d.ts.map +1 -0
  80. package/dist/mixing_assistant.d.ts +62 -0
  81. package/dist/mixing_assistant.d.ts.map +1 -0
  82. package/dist/mixing_oneshot.d.ts +40 -0
  83. package/dist/mixing_oneshot.d.ts.map +1 -0
  84. package/dist/module_state.d.ts +15 -0
  85. package/dist/module_state.d.ts.map +1 -0
  86. package/dist/opfs_clip_pages.d.ts +28 -0
  87. package/dist/opfs_clip_pages.d.ts.map +1 -0
  88. package/dist/playback_renderer.d.ts +128 -0
  89. package/dist/playback_renderer.d.ts.map +1 -0
  90. package/dist/polyphony.d.ts +202 -0
  91. package/dist/polyphony.d.ts.map +1 -0
  92. package/dist/project.d.ts +8 -0
  93. package/dist/project.d.ts.map +1 -0
  94. package/dist/project_class.d.ts +562 -0
  95. package/dist/project_class.d.ts.map +1 -0
  96. package/dist/project_internal.d.ts +194 -0
  97. package/dist/project_internal.d.ts.map +1 -0
  98. package/dist/project_synth.d.ts +74 -0
  99. package/dist/project_synth.d.ts.map +1 -0
  100. package/dist/project_types.d.ts +654 -0
  101. package/dist/project_types.d.ts.map +1 -0
  102. package/dist/public_types.d.ts +185 -0
  103. package/dist/public_types.d.ts.map +1 -0
  104. package/dist/public_types_acoustic.d.ts +215 -0
  105. package/dist/public_types_acoustic.d.ts.map +1 -0
  106. package/dist/public_types_mastering.d.ts +528 -0
  107. package/dist/public_types_mastering.d.ts.map +1 -0
  108. package/dist/public_types_mixing.d.ts +436 -0
  109. package/dist/public_types_mixing.d.ts.map +1 -0
  110. package/dist/public_types_music.d.ts +619 -0
  111. package/dist/public_types_music.d.ts.map +1 -0
  112. package/dist/public_types_playback.d.ts +165 -0
  113. package/dist/public_types_playback.d.ts.map +1 -0
  114. package/dist/public_types_realtime.d.ts +174 -0
  115. package/dist/public_types_realtime.d.ts.map +1 -0
  116. package/dist/public_types_repair.d.ts +424 -0
  117. package/dist/public_types_repair.d.ts.map +1 -0
  118. package/dist/public_types_spectral.d.ts +697 -0
  119. package/dist/public_types_spectral.d.ts.map +1 -0
  120. package/dist/quick_analysis.d.ts +445 -0
  121. package/dist/quick_analysis.d.ts.map +1 -0
  122. package/dist/realtime_engine.d.ts +893 -0
  123. package/dist/realtime_engine.d.ts.map +1 -0
  124. package/dist/realtime_voice_changer.d.ts +158 -0
  125. package/dist/realtime_voice_changer.d.ts.map +1 -0
  126. package/dist/repair_dereverb.d.ts +187 -0
  127. package/dist/repair_dereverb.d.ts.map +1 -0
  128. package/dist/repair_impulsive.d.ts +186 -0
  129. package/dist/repair_impulsive.d.ts.map +1 -0
  130. package/dist/repair_noise.d.ts +239 -0
  131. package/dist/repair_noise.d.ts.map +1 -0
  132. package/dist/repair_trim.d.ts +123 -0
  133. package/dist/repair_trim.d.ts.map +1 -0
  134. package/dist/sample_bank.d.ts +84 -0
  135. package/dist/sample_bank.d.ts.map +1 -0
  136. package/dist/scale.d.ts +10 -0
  137. package/dist/scale.d.ts.map +1 -0
  138. package/dist/schemas/mixer-scene.schema.json +393 -0
  139. package/dist/schemas/playback-renderer-config.schema.json +392 -0
  140. package/dist/sonare-analysis.d.ts +8 -0
  141. package/dist/sonare-analysis.js +2 -2
  142. package/dist/sonare-analysis.wasm +0 -0
  143. package/dist/sonare.d.ts +3945 -0
  144. package/dist/sonare.js +2 -2
  145. package/dist/sonare.wasm +0 -0
  146. package/dist/stream_analyzer.d.ts +163 -0
  147. package/dist/stream_analyzer.d.ts.map +1 -0
  148. package/dist/stream_types.d.ts +214 -0
  149. package/dist/stream_types.d.ts.map +1 -0
  150. package/dist/streaming_mixing.d.ts +6 -0
  151. package/dist/streaming_mixing.d.ts.map +1 -0
  152. package/dist/streaming_processors.d.ts +340 -0
  153. package/dist/streaming_processors.d.ts.map +1 -0
  154. package/dist/transcribe.d.ts +77 -0
  155. package/dist/transcribe.d.ts.map +1 -0
  156. package/dist/validation.d.ts +140 -0
  157. package/dist/validation.d.ts.map +1 -0
  158. package/dist/web_midi.d.ts +77 -0
  159. package/dist/web_midi.d.ts.map +1 -0
  160. package/dist/worker.d.ts +5 -48
  161. package/dist/worker.d.ts.map +1 -0
  162. package/dist/worker.js +94 -41
  163. package/dist/worker.js.map +1 -1
  164. package/dist/worker_client.d.ts +96 -0
  165. package/dist/worker_client.d.ts.map +1 -0
  166. package/dist/worker_protocol.d.ts +43 -0
  167. package/dist/worker_protocol.d.ts.map +1 -0
  168. package/dist/worklet/audio_types.d.ts +21 -0
  169. package/dist/worklet/audio_types.d.ts.map +1 -0
  170. package/dist/worklet/engine-automation.d.ts +29 -0
  171. package/dist/worklet/engine-automation.d.ts.map +1 -0
  172. package/dist/worklet/engine-capture-facade.d.ts +35 -0
  173. package/dist/worklet/engine-capture-facade.d.ts.map +1 -0
  174. package/dist/worklet/engine-clips.d.ts +23 -0
  175. package/dist/worklet/engine-clips.d.ts.map +1 -0
  176. package/dist/worklet/engine-markers.d.ts +40 -0
  177. package/dist/worklet/engine-markers.d.ts.map +1 -0
  178. package/dist/worklet/engine-mixer-facade.d.ts +164 -0
  179. package/dist/worklet/engine-mixer-facade.d.ts.map +1 -0
  180. package/dist/worklet/engine-node.d.ts +83 -0
  181. package/dist/worklet/engine-node.d.ts.map +1 -0
  182. package/dist/worklet/engine-offline.d.ts +81 -0
  183. package/dist/worklet/engine-offline.d.ts.map +1 -0
  184. package/dist/worklet/engine-options.d.ts +12 -0
  185. package/dist/worklet/engine-options.d.ts.map +1 -0
  186. package/dist/worklet/engine-parameter-facade.d.ts +106 -0
  187. package/dist/worklet/engine-parameter-facade.d.ts.map +1 -0
  188. package/dist/worklet/engine-processor.d.ts +72 -0
  189. package/dist/worklet/engine-processor.d.ts.map +1 -0
  190. package/dist/worklet/engine-register.d.ts +2 -0
  191. package/dist/worklet/engine-register.d.ts.map +1 -0
  192. package/dist/worklet/engine-strips.d.ts +75 -0
  193. package/dist/worklet/engine-strips.d.ts.map +1 -0
  194. package/dist/worklet/engine-sync.d.ts +39 -0
  195. package/dist/worklet/engine-sync.d.ts.map +1 -0
  196. package/dist/worklet/engine-tempo-facade.d.ts +48 -0
  197. package/dist/worklet/engine-tempo-facade.d.ts.map +1 -0
  198. package/dist/worklet/engine.d.ts +418 -0
  199. package/dist/worklet/engine.d.ts.map +1 -0
  200. package/dist/worklet/guards.d.ts +53 -0
  201. package/dist/worklet/guards.d.ts.map +1 -0
  202. package/dist/worklet/messages.d.ts +710 -0
  203. package/dist/worklet/messages.d.ts.map +1 -0
  204. package/dist/worklet/mixer-processor.d.ts +46 -0
  205. package/dist/worklet/mixer-processor.d.ts.map +1 -0
  206. package/dist/worklet/playback-processor.d.ts +62 -0
  207. package/dist/worklet/playback-processor.d.ts.map +1 -0
  208. package/dist/worklet/protocol.d.ts +331 -0
  209. package/dist/worklet/protocol.d.ts.map +1 -0
  210. package/dist/worklet/voice-changer-processor.d.ts +41 -0
  211. package/dist/worklet/voice-changer-processor.d.ts.map +1 -0
  212. package/dist/worklet.d.ts +16 -2515
  213. package/dist/worklet.d.ts.map +1 -0
  214. package/dist/worklet.js +3200 -541
  215. package/dist/worklet.js.map +1 -1
  216. package/package.json +23 -12
  217. package/src/_effects_common.ts +47 -0
  218. package/src/_feature_validation.ts +34 -0
  219. package/src/_fft_options.ts +39 -0
  220. package/src/align_take.ts +64 -0
  221. package/src/analysis.ts +56 -3
  222. package/src/analysis_helpers.ts +7 -0
  223. package/src/audio.ts +106 -3
  224. package/src/codes.ts +39 -2
  225. package/src/effects_mastering.ts +101 -22
  226. package/src/effects_note_ops.ts +683 -0
  227. package/src/effects_percussive.ts +217 -0
  228. package/src/effects_separation.ts +150 -0
  229. package/src/effects_spectral.ts +60 -0
  230. package/src/effects_timepitch.ts +388 -0
  231. package/src/errors.ts +23 -1
  232. package/src/feature_core.ts +127 -2
  233. package/src/feature_decompose.ts +633 -0
  234. package/src/feature_inverse.ts +454 -0
  235. package/src/feature_loudness.ts +125 -0
  236. package/src/feature_music.ts +107 -14
  237. package/src/feature_pitch.ts +96 -1
  238. package/src/feature_spectral.ts +16 -611
  239. package/src/feature_spectrogram.ts +63 -450
  240. package/src/features.ts +36 -22
  241. package/src/index.ts +288 -30
  242. package/src/instrument_types.ts +645 -0
  243. package/src/live_audio.ts +27 -1
  244. package/src/mastering_chain.ts +184 -0
  245. package/src/mastering_core.ts +441 -32
  246. package/src/mastering_dynamics.ts +22 -11
  247. package/src/metering.ts +67 -24
  248. package/src/mixer.ts +251 -22
  249. package/src/mixing_assistant.ts +138 -0
  250. package/src/mixing_oneshot.ts +10 -5
  251. package/src/module_state.ts +24 -2
  252. package/src/playback_renderer.ts +252 -0
  253. package/src/polyphony.ts +279 -0
  254. package/src/project.ts +61 -24
  255. package/src/project_class.ts +450 -27
  256. package/src/project_internal.ts +149 -42
  257. package/src/project_synth.ts +67 -1
  258. package/src/project_types.ts +271 -271
  259. package/src/public_types.ts +122 -3
  260. package/src/public_types_acoustic.ts +112 -3
  261. package/src/public_types_mastering.ts +275 -73
  262. package/src/public_types_mixing.ts +363 -1
  263. package/src/public_types_music.ts +312 -2
  264. package/src/public_types_playback.ts +196 -0
  265. package/src/public_types_realtime.ts +39 -7
  266. package/src/public_types_repair.ts +446 -0
  267. package/src/public_types_spectral.ts +491 -5
  268. package/src/quick_analysis.ts +203 -26
  269. package/src/realtime_engine.ts +773 -34
  270. package/src/realtime_voice_changer.ts +55 -1
  271. package/src/repair_dereverb.ts +299 -0
  272. package/src/repair_impulsive.ts +395 -0
  273. package/src/repair_noise.ts +425 -0
  274. package/src/repair_trim.ts +226 -0
  275. package/src/sample_bank.ts +113 -0
  276. package/src/sonare.js.d.ts +1158 -30
  277. package/src/stream_analyzer.ts +36 -4
  278. package/src/stream_types.ts +37 -0
  279. package/src/streaming_mixing.ts +1 -1
  280. package/src/streaming_processors.ts +202 -10
  281. package/src/transcribe.ts +89 -0
  282. package/src/validation.ts +285 -11
  283. package/src/web_midi.ts +1 -6
  284. package/src/worker.ts +18 -2
  285. package/src/worklet/audio_types.ts +37 -0
  286. package/src/worklet/engine-mixer-facade.ts +800 -32
  287. package/src/worklet/engine-node.ts +99 -29
  288. package/src/worklet/engine-offline.ts +14 -8
  289. package/src/worklet/engine-parameter-facade.ts +21 -0
  290. package/src/worklet/engine-processor.ts +332 -93
  291. package/src/worklet/engine-register.ts +32 -18
  292. package/src/worklet/engine-strips.ts +275 -9
  293. package/src/worklet/engine-sync.ts +20 -7
  294. package/src/worklet/engine.ts +394 -48
  295. package/src/worklet/guards.ts +195 -44
  296. package/src/worklet/messages.ts +229 -2
  297. package/src/worklet/mixer-processor.ts +117 -48
  298. package/src/worklet/playback-processor.ts +300 -0
  299. package/src/worklet/protocol.ts +82 -11
  300. package/src/worklet/voice-changer-processor.ts +17 -11
  301. package/src/worklet.ts +17 -0
  302. package/src/effects_transform.ts +0 -718
  303. package/src/mastering_repair.ts +0 -273
@@ -1,5 +1,11 @@
1
+ import { ErrorCode, SonareError } from './errors';
1
2
  import { getSonareModule } from './module_state';
2
3
  import type {
4
+ LoudnessMatchResult,
5
+ LoudnessMatchStereoResult,
6
+ MasteringAssistantParams,
7
+ MasteringInsertParamChoice,
8
+ MasteringInsertSlot,
3
9
  MasteringOptions,
4
10
  MasteringProcessorParams,
5
11
  MasteringResult,
@@ -8,9 +14,12 @@ import type {
8
14
  PairProcessor,
9
15
  SoloProcessor,
10
16
  StereoAnalysis,
17
+ StereoPairProcessor,
11
18
  StreamingPlatform,
12
19
  } from './public_types';
13
20
 
21
+ export type { MasteringInsertParamChoice, MasteringInsertSlot };
22
+
14
23
  function requireModule() {
15
24
  return getSonareModule();
16
25
  }
@@ -45,6 +54,35 @@ export interface MasteringPairProcessRequest {
45
54
  params?: MasteringProcessorParams;
46
55
  }
47
56
 
57
+ /** Canonical request form for a stereo two-input match processor. */
58
+ export interface MasteringPairProcessStereoRequest {
59
+ processorName: StereoPairProcessor;
60
+ sourceLeft: Float32Array;
61
+ sourceRight: Float32Array;
62
+ referenceLeft: Float32Array;
63
+ referenceRight: Float32Array;
64
+ sampleRate?: number;
65
+ params?: MasteringProcessorParams;
66
+ }
67
+
68
+ /** Canonical request form for {@link masteringAbMatchLoudness}. */
69
+ export interface MasteringAbMatchLoudnessRequest {
70
+ /** The take to gain-match. */
71
+ source: Float32Array;
72
+ /** The take whose loudness `source` is matched to; returned untouched. */
73
+ reference: Float32Array;
74
+ sampleRate?: number;
75
+ }
76
+
77
+ /** Canonical request form for stereo AB loudness matching. */
78
+ export interface MasteringAbMatchLoudnessStereoRequest {
79
+ sourceLeft: Float32Array;
80
+ sourceRight: Float32Array;
81
+ referenceLeft: Float32Array;
82
+ referenceRight: Float32Array;
83
+ sampleRate?: number;
84
+ }
85
+
48
86
  /** Canonical request form for a two-input match analysis. */
49
87
  export interface MasteringPairAnalyzeRequest {
50
88
  analysisName: PairAnalysis;
@@ -70,6 +108,13 @@ export interface MasteringSamplesParamsRequest {
70
108
  params?: MasteringProcessorParams;
71
109
  }
72
110
 
111
+ /** Canonical request form for the assistant, whose params carry a target platform. */
112
+ export interface MasteringAssistantParamsRequest {
113
+ samples: Float32Array;
114
+ sampleRate?: number;
115
+ params?: MasteringAssistantParams;
116
+ }
117
+
73
118
  /** Canonical request form for streaming-platform preview. */
74
119
  export interface MasteringStreamingPreviewRequest {
75
120
  samples: Float32Array;
@@ -85,6 +130,14 @@ export interface MasteringStereoParamsRequest {
85
130
  params?: MasteringProcessorParams;
86
131
  }
87
132
 
133
+ /** Stereo counterpart of {@link MasteringAssistantParamsRequest}. */
134
+ export interface MasteringAssistantStereoParamsRequest {
135
+ left: Float32Array;
136
+ right: Float32Array;
137
+ sampleRate?: number;
138
+ params?: MasteringAssistantParams;
139
+ }
140
+
88
141
  /** Canonical request form for the stereo streaming-platform preview. */
89
142
  export interface MasteringStreamingPreviewStereoRequest {
90
143
  left: Float32Array;
@@ -137,9 +190,7 @@ export function masteringProcessorNames(): SoloProcessor[] {
137
190
  * `sonare_mastering_insert_names` (which joins this list) as a `string[]`.
138
191
  */
139
192
  export function masteringInsertNames(): string[] {
140
- return (
141
- requireModule() as unknown as { masteringInsertNames: () => string[] }
142
- ).masteringInsertNames();
193
+ return requireModule().masteringInsertNames();
143
194
  }
144
195
 
145
196
  /**
@@ -153,43 +204,165 @@ export function masteringInsertNames(): string[] {
153
204
  * @param name - Insert processor name (see {@link masteringInsertNames}).
154
205
  */
155
206
  export function masteringInsertParamNames(name: string): string[] {
156
- return Array.from(
157
- (
158
- requireModule() as unknown as { masteringInsertParamNames: (name: string) => string[] }
159
- ).masteringInsertParamNames(name),
160
- );
207
+ return Array.from(requireModule().masteringInsertParamNames(name));
161
208
  }
162
209
 
163
- /** One realtime-automatable parameter of an insert processor. */
210
+ /**
211
+ * One parameter an insert processor's construction reads, whether or not it
212
+ * is realtime-automatable.
213
+ */
164
214
  export interface MasteringInsertParamInfo {
165
215
  /** JSON-key parameter name, as used in scene insert params. */
166
216
  name: string;
167
- /** Integer param id for realtime automation lanes / MIDI-CC binding. */
168
- id: number;
169
- /** Whether the param can be changed live from the audio thread. */
217
+ /**
218
+ * Integer param id for realtime automation lanes / MIDI-CC binding, or null
219
+ * for a construction-only key with no automation target.
220
+ */
221
+ id: number | null;
222
+ /** Whether the param can be changed live from the audio thread; false when `id` is null. */
170
223
  rtSafe: boolean;
171
- /** Physical unit when the parameter is not unitless. */
172
- unit?: string;
224
+ /**
225
+ * The C++ type the processor's config builder reads the key as. `"enum"` is
226
+ * sent as the number in its `choices` entry; `"string"` / `"array"` (an
227
+ * embedded impulse response, a per-band list) is construction-only and
228
+ * reports null for `min`, `max`, `default` and `choices`.
229
+ */
230
+ type: 'boolean' | 'number' | 'enum' | 'string' | 'array';
231
+ /**
232
+ * Smallest value construction accepts, or null when the catalog states no
233
+ * limit or `choices` is non-null. Measured, so it is a hard constraint
234
+ * rather than a UI range; see {@link CapabilityCatalogParameter} for what a
235
+ * measured bound does and does not promise.
236
+ */
237
+ min: number | null;
238
+ /** Largest value construction accepts, or null when the catalog states no limit or `choices` is non-null. */
239
+ max: number | null;
240
+ /**
241
+ * Value the processor uses when the key is absent — the config struct's own
242
+ * field initializer, an enum as its number. Null for a param id with no
243
+ * construction key, a `"string"` / `"array"` key, or a construction key with
244
+ * no fallback.
245
+ */
246
+ default: boolean | number | null;
247
+ /** Physical unit, or null when the parameter is unitless. */
248
+ unit: string | null;
249
+ /**
250
+ * The closed set of values construction accepts, in value order, or null
251
+ * when the accepted values are not a closed set. Non-null only for `"enum"`
252
+ * (every declared enumerator construction accepts) or a `"number"` key
253
+ * whose accepted integers have holes; `min` / `max` are then both null.
254
+ */
255
+ choices: MasteringInsertParamChoice[] | null;
256
+ /**
257
+ * The {@link MasteringInsertSlot} this key belongs to, or null for a key that
258
+ * always exists.
259
+ */
260
+ slot: string | null;
173
261
  }
174
262
 
175
263
  /**
176
- * Returns the realtime-automatable parameter descriptors for an insert / FX
177
- * processor: each entry maps a JSON-key parameter name to the integer id used by
178
- * realtime automation and reports whether it is realtime-safe. Unlike
179
- * {@link masteringInsertParamNames} (every construction key), this lists only the
180
- * realtime-controllable subset — the keys accepted by
181
- * {@link RealtimeEngine.setTrackStripInsertParamByName}. Returns an empty array
182
- * for an unknown name or a processor with no automatable parameters.
264
+ * Returns every parameter an insert / FX processor's construction reads,
265
+ * including construction-time-only keys with no realtime automation target.
266
+ * Entries come in two runs: first the processor's realtime automation
267
+ * targets in id order (the keys accepted by
268
+ * {@link RealtimeEngine.setTrackStripInsertParamByName}, `id` non-null); then,
269
+ * sorted by name, every other construction key with `id` null and `rtSafe`
270
+ * false. The name set matches {@link masteringInsertParamNames} plus any
271
+ * automation target construction does not read. Returns an empty array for an
272
+ * unknown name.
183
273
  *
184
274
  * @param name - Insert processor name (see {@link masteringInsertNames}).
185
275
  */
186
276
  export function masteringInsertParamInfo(name: string): MasteringInsertParamInfo[] {
187
- const json = (
188
- requireModule() as unknown as { masteringInsertParamInfo: (name: string) => string }
189
- ).masteringInsertParamInfo(name);
277
+ const json = requireModule().masteringInsertParamInfo(name);
190
278
  return JSON.parse(json) as MasteringInsertParamInfo[];
191
279
  }
192
280
 
281
+ /** Latency and tail of one insert instance, in samples. */
282
+ export interface MasteringInsertTiming {
283
+ /** Latency in samples at the queried sample rate. */
284
+ latencySamples: number;
285
+ /** Audible decay tail in samples at the queried sample rate. */
286
+ tailSamples: number;
287
+ }
288
+
289
+ /** One built-in amp-sim rig with its resolved starting configuration. */
290
+ export interface MasteringAmpPresetCatalogEntry {
291
+ /** Stable index used by the amp-sim `presetIndex` parameter. */
292
+ index: number;
293
+ /** Canonical preset identifier accepted by the amp-sim insert. */
294
+ name: string;
295
+ /** Effective values from the core preset, before sparse user overrides. */
296
+ params: Record<string, number | boolean>;
297
+ }
298
+
299
+ /**
300
+ * Returns the built-in amp-sim rigs and their resolved control values.
301
+ *
302
+ * The catalog is read-only metadata for hosts such as Studio. Persist only the
303
+ * preset index and explicit overrides in a project so future core updates can
304
+ * continue to define the canonical DSP configuration.
305
+ */
306
+ export function masteringAmpPresetCatalog(): MasteringAmpPresetCatalogEntry[] {
307
+ const json = requireModule().masteringAmpPresetCatalog();
308
+ return JSON.parse(json) as MasteringAmpPresetCatalogEntry[];
309
+ }
310
+
311
+ /**
312
+ * Reject a `params` value {@link masteringInsertTiming} cannot serialize:
313
+ * anything other than a finite number or a boolean, naming the offending key.
314
+ * Booleans serialize as JSON booleans, not 0/1, since the C++ reader accepts
315
+ * `is_bool` alongside a number.
316
+ */
317
+ function insertTimingParamsToJson(fnName: string, params: Record<string, number | boolean>) {
318
+ const out: Record<string, number | boolean> = {};
319
+ for (const [key, value] of Object.entries(params)) {
320
+ if (typeof value === 'boolean') {
321
+ out[key] = value;
322
+ continue;
323
+ }
324
+ if (typeof value !== 'number' || !Number.isFinite(value)) {
325
+ throw new SonareError(
326
+ ErrorCode.InvalidParameter,
327
+ 'InvalidParameter',
328
+ `${fnName}: params.${key} must be a finite number or boolean`,
329
+ );
330
+ }
331
+ out[key] = value;
332
+ }
333
+ return JSON.stringify(out);
334
+ }
335
+
336
+ /**
337
+ * Latency and tail of insert `name` built from `params` and prepared at
338
+ * `sampleRate` (`mastering::api::insert_timing`). Answers for the exact
339
+ * instance a scene or strip would build — an oversampled saturation path, a
340
+ * linear-phase crossover, a lookahead all change the reported latency. The
341
+ * capability catalog's `latencySamples` / `tailSamples` are this query at
342
+ * default parameters and 48 kHz. `effects.reverb.convolution` answers for its
343
+ * configuration without an impulse response: its latency is its fixed
344
+ * partition size and does not depend on one.
345
+ *
346
+ * A key `name`'s construction does not read is refused rather than ignored,
347
+ * because an ignored key would answer for a configuration the caller did not
348
+ * ask for.
349
+ *
350
+ * @param name - Insert processor name (see {@link masteringInsertNames}).
351
+ * @param params - Flat parameter values, keyed as in {@link masteringInsertParamInfo}.
352
+ * @param sampleRate - Rate the insert is prepared at.
353
+ * @throws For an unknown `name`, a key the insert does not read, a value its
354
+ * construction or `prepare` refuses, or a `params` value that is not a
355
+ * finite number or boolean.
356
+ */
357
+ export function masteringInsertTiming(
358
+ name: string,
359
+ params: Record<string, number | boolean>,
360
+ sampleRate: number,
361
+ ): MasteringInsertTiming {
362
+ const json = insertTimingParamsToJson('masteringInsertTiming', params);
363
+ return requireModule().masteringInsertTiming(name, json, sampleRate);
364
+ }
365
+
193
366
  /**
194
367
  * How a processor handles a buffer with more than two channels (a surround
195
368
  * bed). "multichannel" processes every plane in one call; "stereoPairOnly"
@@ -205,6 +378,25 @@ export type MasteringChannelPolicy =
205
378
  /** Coarse algorithmic work estimate for a realtime insert; not a benchmark. */
206
379
  export type MasteringRealtimeCost = 'low' | 'moderate' | 'high';
207
380
 
381
+ /**
382
+ * Catalog grouping for a processor picker, derived from the id's prefix
383
+ * ("eq.*" -> "eq", "match.*" -> "reference"); anything unprefixed is "other".
384
+ */
385
+ export type MasteringProcessorCategory =
386
+ | 'dynamics'
387
+ | 'effects'
388
+ | 'eq'
389
+ | 'final'
390
+ | 'maximizer'
391
+ | 'multiband'
392
+ | 'other'
393
+ | 'reference'
394
+ | 'repair'
395
+ | 'saturation'
396
+ | 'spectral'
397
+ | 'stereo'
398
+ | 'utility';
399
+
208
400
  /** One processor's realtime/offline/pair classification in the catalog. */
209
401
  export interface MasteringProcessorCatalogEntry {
210
402
  /** Processor id (the name used for scene inserts / named processors). */
@@ -237,6 +429,19 @@ export interface MasteringProcessorCatalogEntry {
237
429
  * surround planes passed through dry).
238
430
  */
239
431
  channelPolicy: MasteringChannelPolicy;
432
+ /** Grouping for a processor picker; see {@link MasteringProcessorCategory}. */
433
+ category: MasteringProcessorCategory;
434
+ /**
435
+ * The processor's construction parameters, the same list
436
+ * {@link masteringInsertParamInfo} returns. Empty for entries that are not
437
+ * realtime-insertable.
438
+ */
439
+ params: MasteringInsertParamInfo[];
440
+ /**
441
+ * The insert's conditional key groups in declaration order, named by each
442
+ * parameter's `slot`. Empty for entries that are not realtime-insertable.
443
+ */
444
+ slots: MasteringInsertSlot[];
240
445
  }
241
446
 
242
447
  /**
@@ -246,9 +451,7 @@ export interface MasteringProcessorCatalogEntry {
246
451
  * instead of offering ids the realtime strip would reject.
247
452
  */
248
453
  export function masteringProcessorCatalog(): MasteringProcessorCatalogEntry[] {
249
- const json = (
250
- requireModule() as unknown as { masteringProcessorCatalog: () => string }
251
- ).masteringProcessorCatalog();
454
+ const json = requireModule().masteringProcessorCatalog();
252
455
  return JSON.parse(json) as MasteringProcessorCatalogEntry[];
253
456
  }
254
457
 
@@ -367,6 +570,60 @@ export function masteringPairProcess(
367
570
  );
368
571
  }
369
572
 
573
+ /**
574
+ * Apply the stereo `match.abCrossfade` processor. Source and reference stereo
575
+ * pairs may have independent lengths, but each pair must have equal channels.
576
+ */
577
+ export function masteringPairProcessStereo(
578
+ request: MasteringPairProcessStereoRequest,
579
+ ): MasteringStereoResult;
580
+ export function masteringPairProcessStereo(
581
+ processorName: StereoPairProcessor,
582
+ sourceLeft: Float32Array,
583
+ sourceRight: Float32Array,
584
+ referenceLeft: Float32Array,
585
+ referenceRight: Float32Array,
586
+ sampleRate?: number,
587
+ params?: MasteringProcessorParams,
588
+ ): MasteringStereoResult;
589
+ export function masteringPairProcessStereo(
590
+ processorName: StereoPairProcessor | MasteringPairProcessStereoRequest,
591
+ sourceLeft?: Float32Array,
592
+ sourceRight?: Float32Array,
593
+ referenceLeft?: Float32Array,
594
+ referenceRight?: Float32Array,
595
+ sampleRate = 22050,
596
+ params: MasteringProcessorParams = {},
597
+ ): MasteringStereoResult {
598
+ const request =
599
+ typeof processorName === 'string'
600
+ ? {
601
+ processorName,
602
+ sourceLeft: sourceLeft as Float32Array,
603
+ sourceRight: sourceRight as Float32Array,
604
+ referenceLeft: referenceLeft as Float32Array,
605
+ referenceRight: referenceRight as Float32Array,
606
+ sampleRate,
607
+ params,
608
+ }
609
+ : processorName;
610
+ if (request.sourceLeft.length !== request.sourceRight.length) {
611
+ throw new Error('Source left and right channel lengths must match.');
612
+ }
613
+ if (request.referenceLeft.length !== request.referenceRight.length) {
614
+ throw new Error('Reference left and right channel lengths must match.');
615
+ }
616
+ return requireModule().masteringPairProcessStereo(
617
+ request.processorName,
618
+ request.sourceLeft,
619
+ request.sourceRight,
620
+ request.referenceLeft,
621
+ request.referenceRight,
622
+ request.sampleRate ?? 22050,
623
+ request.params ?? {},
624
+ );
625
+ }
626
+
370
627
  /**
371
628
  * Analyze a `source` against a `reference` with a two-input analysis. The two
372
629
  * buffers may have independent lengths.
@@ -405,6 +662,55 @@ export function masteringPairAnalyze(
405
662
  );
406
663
  }
407
664
 
665
+ /**
666
+ * Gain-match `source` to `reference`'s integrated loudness, so an A/B between
667
+ * the two is not decided by level. `source` and `reference` may have
668
+ * independent lengths.
669
+ *
670
+ * The gain is applied with no upper bound and `matchedTruePeakDbtp` reports
671
+ * where that left the peak, rather than the call capping it: a headroom clamp
672
+ * would return `source` at its own loudness whenever it started near full
673
+ * scale. Both loudness values are non-finite for a silent or below-gate take,
674
+ * and `appliedGainDb` is then 0.
675
+ *
676
+ * @example
677
+ * ```ts
678
+ * const { samples, appliedGainDb, matchedTruePeakDbtp } = masteringAbMatchLoudness({
679
+ * source: take,
680
+ * reference: master,
681
+ * sampleRate: 48000,
682
+ * });
683
+ * ```
684
+ */
685
+ export function masteringAbMatchLoudness(
686
+ request: MasteringAbMatchLoudnessRequest,
687
+ ): LoudnessMatchResult {
688
+ return requireModule().masteringAbMatchLoudness(
689
+ request.source,
690
+ request.reference,
691
+ request.sampleRate ?? 22050,
692
+ );
693
+ }
694
+
695
+ /** Gain-match a stereo source to a stereo reference with one shared gain. */
696
+ export function masteringAbMatchLoudnessStereo(
697
+ request: MasteringAbMatchLoudnessStereoRequest,
698
+ ): LoudnessMatchStereoResult {
699
+ if (request.sourceLeft.length !== request.sourceRight.length) {
700
+ throw new Error('Source left and right channel lengths must match.');
701
+ }
702
+ if (request.referenceLeft.length !== request.referenceRight.length) {
703
+ throw new Error('Reference left and right channel lengths must match.');
704
+ }
705
+ return requireModule().masteringAbMatchLoudnessStereo(
706
+ request.sourceLeft,
707
+ request.sourceRight,
708
+ request.referenceLeft,
709
+ request.referenceRight,
710
+ request.sampleRate ?? 22050,
711
+ );
712
+ }
713
+
408
714
  export function masteringStereoAnalyze(request: MasteringStereoAnalyzeRequest): string;
409
715
  export function masteringStereoAnalyze(
410
716
  analysisName: StereoAnalysis,
@@ -439,16 +745,16 @@ export function masteringStereoAnalyze(
439
745
  );
440
746
  }
441
747
 
442
- export function masteringAssistantSuggest(request: MasteringSamplesParamsRequest): string;
748
+ export function masteringAssistantSuggest(request: MasteringAssistantParamsRequest): string;
443
749
  export function masteringAssistantSuggest(
444
750
  samples: Float32Array,
445
751
  sampleRate?: number,
446
- params?: MasteringProcessorParams,
752
+ params?: MasteringAssistantParams,
447
753
  ): string;
448
754
  export function masteringAssistantSuggest(
449
- samples: Float32Array | MasteringSamplesParamsRequest,
755
+ samples: Float32Array | MasteringAssistantParamsRequest,
450
756
  sampleRate = 22050,
451
- params: MasteringProcessorParams = {},
757
+ params: MasteringAssistantParams = {},
452
758
  ): string {
453
759
  const request = samples instanceof Float32Array ? { samples, sampleRate, params } : samples;
454
760
  return requireModule().masteringAssistantSuggest(
@@ -458,6 +764,91 @@ export function masteringAssistantSuggest(
458
764
  );
459
765
  }
460
766
 
767
+ /**
768
+ * Suggest a mastering chain, as the flat `{key: number|boolean}` params map
769
+ * {@link masteringAssistantSuggest}'s `chainConfig` carries, without needing to
770
+ * pull it out of the full assistant document. The returned map can be passed
771
+ * straight through as `overrides` to {@link mastering} / {@link masterAudio}.
772
+ */
773
+ export function masteringAssistantSuggestChain(
774
+ request: MasteringAssistantParamsRequest,
775
+ ): Record<string, number | boolean> {
776
+ return requireModule().masteringAssistantSuggestChain(
777
+ request.samples,
778
+ request.sampleRate ?? 22050,
779
+ request.params ?? {},
780
+ );
781
+ }
782
+
783
+ /**
784
+ * The shape {@link masteringAudioProfile}'s JSON parses to.
785
+ *
786
+ * The profile crosses as a string, so nothing type-checks it on arrival; this
787
+ * declaration is what a conformance check compares against the paths the C++
788
+ * writer publishes, so a field added on one side and not the other fails there
789
+ * rather than reaching a caller as `undefined`.
790
+ */
791
+ export interface MasteringAudioProfile {
792
+ durationSec: number;
793
+ bpm: number;
794
+ bpmConfidence: number;
795
+ loudness: {
796
+ integratedLufs: number;
797
+ lraLu: number;
798
+ truePeakDb: number;
799
+ crestFactorDb: number;
800
+ };
801
+ spectral: {
802
+ subRmsDb: number;
803
+ lowRmsDb: number;
804
+ lowMidRmsDb: number;
805
+ midRmsDb: number;
806
+ highMidRmsDb: number;
807
+ highRmsDb: number;
808
+ airRmsDb: number;
809
+ centroidHz: number;
810
+ flatness: number;
811
+ rolloffHz: number;
812
+ };
813
+ dynamics: {
814
+ shortTermLufsStd: number;
815
+ attackDensity: number;
816
+ sustainRatio: number;
817
+ };
818
+ /**
819
+ * What the repair detectors measured. `measured` is false when nothing ran —
820
+ * either `detectDefects` was not asked for or the input was too short — and
821
+ * every other field is then at its default rather than a reading.
822
+ */
823
+ defects: {
824
+ measured: boolean;
825
+ clickCount: number;
826
+ clickRejected: number;
827
+ clickLongestRunSamples: number;
828
+ clickPerSecond: number;
829
+ crackleSampleCount: number;
830
+ crackleSampleFraction: number;
831
+ cracklePerSecond: number;
832
+ clipSampleCount: number;
833
+ clipRunCount: number;
834
+ clipLongestRunSamples: number;
835
+ clipSampleFraction: number;
836
+ clipFlatRunCount: number;
837
+ clipFlatSampleCount: number;
838
+ clipLongestFlatRunSamples: number;
839
+ clipFlatLevel: number;
840
+ noiseFloorDbfs: number;
841
+ noiseBandPeakDbfs: number;
842
+ noiseBandPeakIndex: number;
843
+ humFundamentalHz: number;
844
+ humFundamentalProminence: number;
845
+ humHarmonics: number;
846
+ humFundamentalDbfs: number;
847
+ humPeakHarmonicDbfs: number;
848
+ lateDecayRatioDb: number;
849
+ };
850
+ }
851
+
461
852
  export function masteringAudioProfile(request: MasteringSamplesParamsRequest): string;
462
853
  export function masteringAudioProfile(
463
854
  samples: Float32Array,
@@ -503,7 +894,9 @@ export function masteringStreamingPreview(
503
894
  * of the suggestion is built on the channel-summed program rather than a
504
895
  * downmix that reads roughly 6 dB low.
505
896
  */
506
- export function masteringAssistantSuggestStereo(request: MasteringStereoParamsRequest): string {
897
+ export function masteringAssistantSuggestStereo(
898
+ request: MasteringAssistantStereoParamsRequest,
899
+ ): string {
507
900
  return requireModule().masteringAssistantSuggestStereo(
508
901
  request.left,
509
902
  request.right,
@@ -512,6 +905,22 @@ export function masteringAssistantSuggestStereo(request: MasteringStereoParamsRe
512
905
  );
513
906
  }
514
907
 
908
+ /**
909
+ * Stereo counterpart of {@link masteringAssistantSuggestChain}: the flat
910
+ * `{key: number|boolean}` params map without the surrounding assistant
911
+ * document, ready to pass through as `overrides` to {@link masterAudioStereo}.
912
+ */
913
+ export function masteringAssistantSuggestChainStereo(
914
+ request: MasteringAssistantStereoParamsRequest,
915
+ ): Record<string, number | boolean> {
916
+ return requireModule().masteringAssistantSuggestChainStereo(
917
+ request.left,
918
+ request.right,
919
+ request.sampleRate ?? 22050,
920
+ request.params ?? {},
921
+ );
922
+ }
923
+
515
924
  /**
516
925
  * Mastering assistant profile of a stereo pair, as shared JSON.
517
926
  *
@@ -72,8 +72,17 @@ export interface MasteringDynamicsTransientShaperRequest extends TransientShaper
72
72
  sampleRate: number;
73
73
  }
74
74
 
75
- /** Result envelope returned by offline mastering dynamics processors. */
76
- export interface DynamicsResult {
75
+ /**
76
+ * Result envelope returned by offline mastering dynamics processors.
77
+ *
78
+ * Named for what it is rather than for the module it lives in. {@link
79
+ * DynamicsResult} is the *analysis* shape on every binding, so having that one
80
+ * identifier mean two disjoint field lists across the Node and WASM packages
81
+ * made a shared TypeScript module type-check against one and fail against the
82
+ * other — with the identifier resolving either way, so only the member list
83
+ * gave it away.
84
+ */
85
+ export interface DynamicsProcessorResult {
77
86
  samples: Float32Array;
78
87
  latencySamples: number;
79
88
  }
@@ -87,17 +96,17 @@ const COMPRESSOR_DETECTOR_MAP: Record<CompressorDetector, number> = {
87
96
  /** Offline feed-forward compressor (soft knee, optional auto-makeup / sidechain HPF). */
88
97
  export function masteringDynamicsCompressor(
89
98
  request: MasteringDynamicsCompressorRequest,
90
- ): DynamicsResult;
99
+ ): DynamicsProcessorResult;
91
100
  export function masteringDynamicsCompressor(
92
101
  samples: Float32Array,
93
102
  sampleRate: number,
94
103
  options?: CompressorOptions,
95
- ): DynamicsResult;
104
+ ): DynamicsProcessorResult;
96
105
  export function masteringDynamicsCompressor(
97
106
  samples: Float32Array | MasteringDynamicsCompressorRequest,
98
107
  sampleRate?: number,
99
108
  options: CompressorOptions = {},
100
- ): DynamicsResult {
109
+ ): DynamicsProcessorResult {
101
110
  const request =
102
111
  samples instanceof Float32Array
103
112
  ? { samples, sampleRate: sampleRate as number, ...options }
@@ -121,17 +130,19 @@ export function masteringDynamicsCompressor(
121
130
  }
122
131
 
123
132
  /** Offline noise gate (hysteresis, hold, optional key HPF). */
124
- export function masteringDynamicsGate(request: MasteringDynamicsGateRequest): DynamicsResult;
133
+ export function masteringDynamicsGate(
134
+ request: MasteringDynamicsGateRequest,
135
+ ): DynamicsProcessorResult;
125
136
  export function masteringDynamicsGate(
126
137
  samples: Float32Array,
127
138
  sampleRate: number,
128
139
  options?: GateOptions,
129
- ): DynamicsResult;
140
+ ): DynamicsProcessorResult;
130
141
  export function masteringDynamicsGate(
131
142
  samples: Float32Array | MasteringDynamicsGateRequest,
132
143
  sampleRate?: number,
133
144
  options: GateOptions = {},
134
- ): DynamicsResult {
145
+ ): DynamicsProcessorResult {
135
146
  const request =
136
147
  samples instanceof Float32Array
137
148
  ? { samples, sampleRate: sampleRate as number, ...options }
@@ -143,17 +154,17 @@ export function masteringDynamicsGate(
143
154
  /** Offline transient shaper (envelope-difference attack/sustain control). */
144
155
  export function masteringDynamicsTransientShaper(
145
156
  request: MasteringDynamicsTransientShaperRequest,
146
- ): DynamicsResult;
157
+ ): DynamicsProcessorResult;
147
158
  export function masteringDynamicsTransientShaper(
148
159
  samples: Float32Array,
149
160
  sampleRate: number,
150
161
  options?: TransientShaperOptions,
151
- ): DynamicsResult;
162
+ ): DynamicsProcessorResult;
152
163
  export function masteringDynamicsTransientShaper(
153
164
  samples: Float32Array | MasteringDynamicsTransientShaperRequest,
154
165
  sampleRate?: number,
155
166
  options: TransientShaperOptions = {},
156
- ): DynamicsResult {
167
+ ): DynamicsProcessorResult {
157
168
  const request =
158
169
  samples instanceof Float32Array
159
170
  ? { samples, sampleRate: sampleRate as number, ...options }