@libraz/libsonare 1.4.1 → 1.5.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.
Files changed (62) hide show
  1. package/README.md +50 -19
  2. package/dist/index.d.ts +5384 -1
  3. package/dist/index.js +867 -573
  4. package/dist/index.js.map +1 -1
  5. package/dist/sonare.js +1 -1
  6. package/dist/sonare.wasm +0 -0
  7. package/dist/worklet.d.ts +1083 -5227
  8. package/dist/worklet.js +2677 -2452
  9. package/dist/worklet.js.map +1 -1
  10. package/package.json +4 -9
  11. package/src/clip_page_streamer.ts +250 -0
  12. package/src/effects_mastering.ts +85 -1089
  13. package/src/effects_transform.ts +286 -0
  14. package/src/effects_voice_change.ts +118 -0
  15. package/src/feature_spectrogram.ts +42 -2
  16. package/src/features.ts +1 -0
  17. package/src/index.ts +11 -0
  18. package/src/mastering_chain.ts +200 -0
  19. package/src/mastering_core.ts +248 -0
  20. package/src/mastering_dynamics.ts +105 -0
  21. package/src/mastering_repair.ts +161 -0
  22. package/src/mixing_oneshot.ts +54 -0
  23. package/src/module_state.ts +1 -2
  24. package/src/project.ts +71 -1712
  25. package/src/project_class.ts +861 -0
  26. package/src/project_internal.ts +332 -0
  27. package/src/project_synth.ts +43 -0
  28. package/src/project_types.ts +570 -0
  29. package/src/public_types.ts +6 -1221
  30. package/src/public_types_acoustic.ts +115 -0
  31. package/src/public_types_mastering.ts +333 -0
  32. package/src/public_types_mixing.ts +97 -0
  33. package/src/public_types_music.ts +352 -0
  34. package/src/public_types_realtime.ts +163 -0
  35. package/src/public_types_spectral.ts +194 -0
  36. package/src/realtime_engine.ts +94 -0
  37. package/src/sonare.js.d.ts +72 -0
  38. package/src/worklet/engine-automation.ts +73 -0
  39. package/src/worklet/engine-capture-facade.ts +80 -0
  40. package/src/worklet/engine-clips.ts +71 -0
  41. package/src/worklet/engine-markers.ts +93 -0
  42. package/src/worklet/engine-mixer-facade.ts +186 -0
  43. package/src/worklet/engine-node.ts +451 -0
  44. package/src/worklet/engine-offline.ts +162 -0
  45. package/src/worklet/engine-options.ts +13 -0
  46. package/src/worklet/engine-parameter-facade.ts +172 -0
  47. package/src/worklet/engine-processor.ts +764 -0
  48. package/src/worklet/engine-register.ts +136 -0
  49. package/src/worklet/engine-strips.ts +315 -0
  50. package/src/worklet/engine-sync.ts +94 -0
  51. package/src/worklet/engine-tempo-facade.ts +141 -0
  52. package/src/worklet/engine.ts +998 -0
  53. package/src/worklet/guards.ts +14 -1
  54. package/src/worklet/messages.ts +60 -20
  55. package/src/worklet/mixer-processor.ts +368 -0
  56. package/src/worklet/protocol.ts +3 -0
  57. package/src/worklet/voice-changer-processor.ts +246 -0
  58. package/src/worklet.ts +20 -3549
  59. package/dist/sonare-rt-module.js +0 -2
  60. package/dist/sonare-rt.js +0 -2
  61. package/dist/sonare-rt.wasm +0 -0
  62. package/src/sonare-rt.d.ts +0 -93
package/dist/index.js CHANGED
@@ -165,6 +165,141 @@ function getSonareModule() {
165
165
  return wrappedModule;
166
166
  }
167
167
 
168
+ // src/validation.ts
169
+ function assertNonEmptySamples(fnName, samples, argName = "samples") {
170
+ if (samples.length === 0) {
171
+ throw new RangeError(`${fnName}: ${argName} must not be empty`);
172
+ }
173
+ }
174
+ function assertFiniteSamples(fnName, samples, validate, argName = "samples") {
175
+ if (!validate) {
176
+ return;
177
+ }
178
+ for (let i = 0; i < samples.length; i++) {
179
+ const v = samples[i];
180
+ if (!Number.isFinite(v)) {
181
+ throw new RangeError(`${fnName}: ${argName} contains NaN or Inf at index ${i}`);
182
+ }
183
+ }
184
+ }
185
+ function assertSamples(fnName, samples, validate, argName = "samples") {
186
+ assertNonEmptySamples(fnName, samples, argName);
187
+ assertFiniteSamples(fnName, samples, validate, argName);
188
+ }
189
+ function assertFiniteScalar(fnName, value, argName) {
190
+ if (!Number.isFinite(value)) {
191
+ throw new RangeError(`${fnName}: ${argName} must be a finite number`);
192
+ }
193
+ }
194
+ function assertSampleRate(fnName, sampleRate) {
195
+ if (!Number.isInteger(sampleRate) || sampleRate < 8e3 || sampleRate > 384e3) {
196
+ throw new RangeError(`${fnName}: sampleRate out of supported range [8000, 384000]`);
197
+ }
198
+ }
199
+ function assertNonNegativeInteger(fnName, value, argName) {
200
+ if (!Number.isInteger(value) || value < 0) {
201
+ throw new RangeError(`${fnName}: ${argName} must be a non-negative integer`);
202
+ }
203
+ }
204
+ function assertPositiveInteger(fnName, value, argName) {
205
+ if (!Number.isInteger(value) || value <= 0) {
206
+ throw new RangeError(`${fnName}: ${argName} must be a positive integer`);
207
+ }
208
+ }
209
+ function assertInterleavedSamples(fnName, samples, channels, validate) {
210
+ assertSamples(fnName, samples, validate);
211
+ assertPositiveInteger(fnName, channels, "channels");
212
+ if (samples.length % channels !== 0) {
213
+ throw new RangeError(`${fnName}: samples length must be a multiple of channels`);
214
+ }
215
+ }
216
+
217
+ // src/effects_transform.ts
218
+ function requireModule() {
219
+ return getSonareModule();
220
+ }
221
+ function hpss(samples, sampleRate = 22050, kernelHarmonic = 31, kernelPercussive = 31) {
222
+ return requireModule().hpss(samples, sampleRate, kernelHarmonic, kernelPercussive);
223
+ }
224
+ function harmonic(samples, sampleRate, options = {}) {
225
+ assertSamples("harmonic", samples, options.validate !== false);
226
+ return requireModule().harmonic(samples, sampleRate);
227
+ }
228
+ function percussive(samples, sampleRate, options = {}) {
229
+ assertSamples("percussive", samples, options.validate !== false);
230
+ return requireModule().percussive(samples, sampleRate);
231
+ }
232
+ function timeStretch(samples, sampleRate, rate, options = {}) {
233
+ assertSamples("timeStretch", samples, options.validate !== false);
234
+ return requireModule().timeStretch(samples, sampleRate, rate);
235
+ }
236
+ function pitchShift(samples, sampleRate, semitones, options = {}) {
237
+ assertSamples("pitchShift", samples, options.validate !== false);
238
+ return requireModule().pitchShift(samples, sampleRate, semitones);
239
+ }
240
+ function pitchCorrectToMidi(samples, sampleRate = 22050, currentMidi = 69, targetMidi = 69, options = {}) {
241
+ assertSamples("pitchCorrectToMidi", samples, options.validate !== false);
242
+ return requireModule().pitchCorrectToMidi(samples, sampleRate, currentMidi, targetMidi);
243
+ }
244
+ function pitchCorrectToMidiTimevarying(samples, f0Hz, targetMidi, sampleRate = 22050, hopLength = 512, voiced, voicedProb, options = {}) {
245
+ assertSamples("pitchCorrectToMidiTimevarying", samples, options.validate !== false);
246
+ if (voiced && voiced.length !== f0Hz.length) {
247
+ throw new RangeError("pitchCorrectToMidiTimevarying: voiced length must match f0Hz length");
248
+ }
249
+ if (voicedProb && voicedProb.length !== f0Hz.length) {
250
+ throw new RangeError("pitchCorrectToMidiTimevarying: voicedProb length must match f0Hz length");
251
+ }
252
+ const voicedF32 = voiced ? Float32Array.from(voiced) : void 0;
253
+ return requireModule().pitchCorrectToMidiTimevarying(
254
+ samples,
255
+ sampleRate,
256
+ f0Hz,
257
+ targetMidi,
258
+ hopLength,
259
+ voicedF32,
260
+ voicedProb
261
+ );
262
+ }
263
+ function pitchCorrectTimevarying(samples, f0Hz, sampleRate = 22050, hopLength = 512, options = {}) {
264
+ assertSamples("pitchCorrectTimevarying", samples, options.validate !== false);
265
+ if (options.voiced && options.voiced.length !== f0Hz.length) {
266
+ throw new RangeError("pitchCorrectTimevarying: voiced length must match f0Hz length");
267
+ }
268
+ if (options.voicedProb && options.voicedProb.length !== f0Hz.length) {
269
+ throw new RangeError("pitchCorrectTimevarying: voicedProb length must match f0Hz length");
270
+ }
271
+ const nativeOptions = {
272
+ ...options,
273
+ voiced: options.voiced ? Float32Array.from(options.voiced) : void 0
274
+ };
275
+ return requireModule().pitchCorrectTimevarying(
276
+ samples,
277
+ sampleRate,
278
+ f0Hz,
279
+ hopLength,
280
+ nativeOptions
281
+ );
282
+ }
283
+ function noteStretch(samples, sampleRate = 22050, options = {}) {
284
+ assertSamples("noteStretch", samples, options.validate !== false);
285
+ return requireModule().noteStretch(
286
+ samples,
287
+ sampleRate,
288
+ options.onsetSample ?? 0,
289
+ options.offsetSample ?? 0,
290
+ options.stretchRatio ?? 1
291
+ );
292
+ }
293
+ function normalize(samples, sampleRate, targetDb = 0, options = {}) {
294
+ assertSamples("normalize", samples, options.validate !== false);
295
+ return requireModule().normalize(samples, sampleRate, targetDb);
296
+ }
297
+ function spectralEdit(samples, sampleRate, ops = [], options = {}) {
298
+ assertSamples("spectralEdit", samples, options.validate !== false);
299
+ assertSampleRate("spectralEdit", sampleRate);
300
+ return requireModule().spectralEdit(samples, sampleRate, ops, options);
301
+ }
302
+
168
303
  // src/codes.ts
169
304
  function automationCurveCode(curve) {
170
305
  switch (curve) {
@@ -1016,114 +1151,13 @@ var StreamingRetune = class {
1016
1151
  }
1017
1152
  };
1018
1153
 
1019
- // src/validation.ts
1020
- function assertNonEmptySamples(fnName, samples, argName = "samples") {
1021
- if (samples.length === 0) {
1022
- throw new RangeError(`${fnName}: ${argName} must not be empty`);
1023
- }
1024
- }
1025
- function assertFiniteSamples(fnName, samples, validate, argName = "samples") {
1026
- if (!validate) {
1027
- return;
1028
- }
1029
- for (let i = 0; i < samples.length; i++) {
1030
- const v = samples[i];
1031
- if (!Number.isFinite(v)) {
1032
- throw new RangeError(`${fnName}: ${argName} contains NaN or Inf at index ${i}`);
1033
- }
1034
- }
1035
- }
1036
- function assertSamples(fnName, samples, validate, argName = "samples") {
1037
- assertNonEmptySamples(fnName, samples, argName);
1038
- assertFiniteSamples(fnName, samples, validate, argName);
1039
- }
1040
- function assertFiniteScalar(fnName, value, argName) {
1041
- if (!Number.isFinite(value)) {
1042
- throw new RangeError(`${fnName}: ${argName} must be a finite number`);
1043
- }
1044
- }
1045
- function assertSampleRate(fnName, sampleRate) {
1046
- if (!Number.isInteger(sampleRate) || sampleRate < 8e3 || sampleRate > 384e3) {
1047
- throw new RangeError(`${fnName}: sampleRate out of supported range [8000, 384000]`);
1048
- }
1049
- }
1050
- function assertNonNegativeInteger(fnName, value, argName) {
1051
- if (!Number.isInteger(value) || value < 0) {
1052
- throw new RangeError(`${fnName}: ${argName} must be a non-negative integer`);
1053
- }
1054
- }
1055
- function assertPositiveInteger(fnName, value, argName) {
1056
- if (!Number.isInteger(value) || value <= 0) {
1057
- throw new RangeError(`${fnName}: ${argName} must be a positive integer`);
1058
- }
1059
- }
1060
- function assertInterleavedSamples(fnName, samples, channels, validate) {
1061
- assertSamples(fnName, samples, validate);
1062
- assertPositiveInteger(fnName, channels, "channels");
1063
- if (samples.length % channels !== 0) {
1064
- throw new RangeError(`${fnName}: samples length must be a multiple of channels`);
1065
- }
1066
- }
1067
-
1068
- // src/effects_mastering.ts
1069
- function requireModule() {
1154
+ // src/effects_voice_change.ts
1155
+ function requireModule2() {
1070
1156
  return getSonareModule();
1071
1157
  }
1072
- function hpss(samples, sampleRate = 22050, kernelHarmonic = 31, kernelPercussive = 31) {
1073
- return requireModule().hpss(samples, sampleRate, kernelHarmonic, kernelPercussive);
1074
- }
1075
- function harmonic(samples, sampleRate, options = {}) {
1076
- assertSamples("harmonic", samples, options.validate !== false);
1077
- return requireModule().harmonic(samples, sampleRate);
1078
- }
1079
- function percussive(samples, sampleRate, options = {}) {
1080
- assertSamples("percussive", samples, options.validate !== false);
1081
- return requireModule().percussive(samples, sampleRate);
1082
- }
1083
- function timeStretch(samples, sampleRate, rate, options = {}) {
1084
- assertSamples("timeStretch", samples, options.validate !== false);
1085
- return requireModule().timeStretch(samples, sampleRate, rate);
1086
- }
1087
- function pitchShift(samples, sampleRate, semitones, options = {}) {
1088
- assertSamples("pitchShift", samples, options.validate !== false);
1089
- return requireModule().pitchShift(samples, sampleRate, semitones);
1090
- }
1091
- function pitchCorrectToMidi(samples, sampleRate = 22050, currentMidi = 69, targetMidi = 69, options = {}) {
1092
- assertSamples("pitchCorrectToMidi", samples, options.validate !== false);
1093
- return requireModule().pitchCorrectToMidi(samples, sampleRate, currentMidi, targetMidi);
1094
- }
1095
- function pitchCorrectToMidiTimevarying(samples, f0Hz, targetMidi, sampleRate = 22050, hopLength = 512, voiced, voicedProb, options = {}) {
1096
- assertSamples("pitchCorrectToMidiTimevarying", samples, options.validate !== false);
1097
- if (voiced && voiced.length !== f0Hz.length) {
1098
- throw new RangeError("pitchCorrectToMidiTimevarying: voiced length must match f0Hz length");
1099
- }
1100
- if (voicedProb && voicedProb.length !== f0Hz.length) {
1101
- throw new RangeError("pitchCorrectToMidiTimevarying: voicedProb length must match f0Hz length");
1102
- }
1103
- const voicedF32 = voiced ? Float32Array.from(voiced) : void 0;
1104
- return requireModule().pitchCorrectToMidiTimevarying(
1105
- samples,
1106
- sampleRate,
1107
- f0Hz,
1108
- targetMidi,
1109
- hopLength,
1110
- voicedF32,
1111
- voicedProb
1112
- );
1113
- }
1114
- function noteStretch(samples, sampleRate = 22050, options = {}) {
1115
- assertSamples("noteStretch", samples, options.validate !== false);
1116
- return requireModule().noteStretch(
1117
- samples,
1118
- sampleRate,
1119
- options.onsetSample ?? 0,
1120
- options.offsetSample ?? 0,
1121
- options.stretchRatio ?? 1
1122
- );
1123
- }
1124
1158
  function voiceChange(samples, sampleRate = 22050, options = {}) {
1125
1159
  assertSamples("voiceChange", samples, options.validate !== false);
1126
- return requireModule().voiceChange(
1160
+ return requireModule2().voiceChange(
1127
1161
  samples,
1128
1162
  sampleRate,
1129
1163
  options.pitchSemitones ?? 0,
@@ -1175,102 +1209,155 @@ function voiceChangeRealtime(samples, options = {}) {
1175
1209
  changer.delete();
1176
1210
  }
1177
1211
  }
1178
- function normalize(samples, sampleRate, targetDb = 0, options = {}) {
1179
- assertSamples("normalize", samples, options.validate !== false);
1180
- return requireModule().normalize(samples, sampleRate, targetDb);
1212
+
1213
+ // src/mastering_chain.ts
1214
+ function requireModule3() {
1215
+ return getSonareModule();
1181
1216
  }
1182
- function spectralEdit(samples, sampleRate, ops = [], options = {}) {
1183
- assertSamples("spectralEdit", samples, options.validate !== false);
1184
- assertSampleRate("spectralEdit", sampleRate);
1185
- return requireModule().spectralEdit(samples, sampleRate, ops, options);
1217
+ function masteringChain(samples, sampleRate = 22050, config) {
1218
+ return requireModule3().masteringChain(samples, sampleRate, config);
1186
1219
  }
1187
- function mastering(samples, sampleRate = 22050, options = {}) {
1188
- return requireModule().mastering(
1189
- samples,
1220
+ function masteringChainStereo(left, right, sampleRate = 22050, config) {
1221
+ if (left.length !== right.length) {
1222
+ throw new Error("Stereo channel lengths must match.");
1223
+ }
1224
+ return requireModule3().masteringChainStereo(
1225
+ left,
1226
+ right,
1190
1227
  sampleRate,
1191
- options.targetLufs ?? -14,
1192
- options.ceilingDb ?? -1,
1193
- options.truePeakOversample ?? 4,
1194
- options.releaseMs ?? 0,
1195
- // 0 => library default (50 ms)
1196
- options.applyGainAtInputRate ?? false
1228
+ config
1197
1229
  );
1198
1230
  }
1199
- function masteringProcessorNames() {
1200
- return Array.from(requireModule().masteringProcessorNames());
1201
- }
1202
- function masteringInsertNames() {
1203
- return requireModule().masteringInsertNames();
1204
- }
1231
+ function masteringChainWithProgress(samples, sampleRate = 22050, config, onProgress) {
1232
+ return requireModule3().masteringChainWithProgress(
1233
+ samples,
1234
+ sampleRate,
1235
+ config,
1236
+ onProgress
1237
+ );
1238
+ }
1239
+ function masteringChainStereoWithProgress(left, right, sampleRate = 22050, config, onProgress) {
1240
+ if (left.length !== right.length) {
1241
+ throw new Error("Stereo channel lengths must match.");
1242
+ }
1243
+ return requireModule3().masteringChainStereoWithProgress(
1244
+ left,
1245
+ right,
1246
+ sampleRate,
1247
+ config,
1248
+ onProgress
1249
+ );
1250
+ }
1251
+ function masteringPresetNames() {
1252
+ return Array.from(requireModule3().masteringPresetNames());
1253
+ }
1254
+ function masterAudio(samples, sampleRate = 22050, presetName = "pop", overrides = {}) {
1255
+ return requireModule3().masterAudio(presetName, samples, sampleRate, overrides);
1256
+ }
1257
+ function masterAudioStereo(left, right, sampleRate = 22050, presetName = "pop", overrides = {}) {
1258
+ if (left.length !== right.length) {
1259
+ throw new Error("Stereo channel lengths must match.");
1260
+ }
1261
+ return requireModule3().masterAudioStereo(presetName, left, right, sampleRate, overrides);
1262
+ }
1263
+ function masterAudioWithProgress(samples, sampleRate = 22050, presetName, onProgress, overrides = null) {
1264
+ return requireModule3().masterAudioWithProgress(
1265
+ presetName,
1266
+ samples,
1267
+ sampleRate,
1268
+ overrides,
1269
+ onProgress
1270
+ );
1271
+ }
1272
+ function masterAudioStereoWithProgress(left, right, sampleRate = 22050, presetName, onProgress, overrides = null) {
1273
+ if (left.length !== right.length) {
1274
+ throw new Error("Stereo channel lengths must match.");
1275
+ }
1276
+ return requireModule3().masterAudioStereoWithProgress(
1277
+ presetName,
1278
+ left,
1279
+ right,
1280
+ sampleRate,
1281
+ overrides,
1282
+ onProgress
1283
+ );
1284
+ }
1285
+
1286
+ // src/mastering_core.ts
1287
+ function requireModule4() {
1288
+ return getSonareModule();
1289
+ }
1290
+ function mastering(samples, sampleRate = 22050, options = {}) {
1291
+ return requireModule4().mastering(
1292
+ samples,
1293
+ sampleRate,
1294
+ options.targetLufs ?? -14,
1295
+ options.ceilingDb ?? -1,
1296
+ options.truePeakOversample ?? 4,
1297
+ options.releaseMs ?? 0,
1298
+ // 0 => library default (50 ms)
1299
+ options.applyGainAtInputRate ?? false
1300
+ );
1301
+ }
1302
+ function masteringProcessorNames() {
1303
+ return Array.from(requireModule4().masteringProcessorNames());
1304
+ }
1305
+ function masteringInsertNames() {
1306
+ return requireModule4().masteringInsertNames();
1307
+ }
1205
1308
  function masteringInsertParamNames(name) {
1206
1309
  return Array.from(
1207
- requireModule().masteringInsertParamNames(name)
1310
+ requireModule4().masteringInsertParamNames(name)
1208
1311
  );
1209
1312
  }
1210
1313
  function masteringInsertParamInfo(name) {
1211
- const json = requireModule().masteringInsertParamInfo(name);
1314
+ const json = requireModule4().masteringInsertParamInfo(name);
1212
1315
  return JSON.parse(json);
1213
1316
  }
1214
1317
  function masteringProcessorCatalog() {
1215
- const json = requireModule().masteringProcessorCatalog();
1318
+ const json = requireModule4().masteringProcessorCatalog();
1216
1319
  return JSON.parse(json);
1217
1320
  }
1218
1321
  function masteringPairProcessorNames() {
1219
- return Array.from(requireModule().masteringPairProcessorNames());
1322
+ return Array.from(requireModule4().masteringPairProcessorNames());
1220
1323
  }
1221
1324
  function masteringPairAnalysisNames() {
1222
- return Array.from(requireModule().masteringPairAnalysisNames());
1325
+ return Array.from(requireModule4().masteringPairAnalysisNames());
1223
1326
  }
1224
1327
  function masteringStereoAnalysisNames() {
1225
- return Array.from(requireModule().masteringStereoAnalysisNames());
1328
+ return Array.from(requireModule4().masteringStereoAnalysisNames());
1226
1329
  }
1227
1330
  function masteringProcess(processorName, samples, sampleRate = 22050, params = {}) {
1228
- return requireModule().masteringProcess(processorName, samples, sampleRate, params);
1331
+ return requireModule4().masteringProcess(processorName, samples, sampleRate, params);
1229
1332
  }
1230
1333
  function masteringProcessStereo(processorName, left, right, sampleRate = 22050, params = {}) {
1231
1334
  if (left.length !== right.length) {
1232
1335
  throw new Error("Stereo channel lengths must match.");
1233
1336
  }
1234
- return requireModule().masteringProcessStereo(processorName, left, right, sampleRate, params);
1337
+ return requireModule4().masteringProcessStereo(processorName, left, right, sampleRate, params);
1235
1338
  }
1236
1339
  function masteringPairProcess(processorName, source, reference, sampleRate = 22050, params = {}) {
1237
- return requireModule().masteringPairProcess(processorName, source, reference, sampleRate, params);
1340
+ return requireModule4().masteringPairProcess(processorName, source, reference, sampleRate, params);
1238
1341
  }
1239
1342
  function masteringPairAnalyze(analysisName, source, reference, sampleRate = 22050, params = {}) {
1240
- return requireModule().masteringPairAnalyze(analysisName, source, reference, sampleRate, params);
1343
+ return requireModule4().masteringPairAnalyze(analysisName, source, reference, sampleRate, params);
1241
1344
  }
1242
1345
  function masteringStereoAnalyze(analysisName, left, right, sampleRate = 22050, params = {}) {
1243
- return requireModule().masteringStereoAnalyze(analysisName, left, right, sampleRate, params);
1346
+ return requireModule4().masteringStereoAnalyze(analysisName, left, right, sampleRate, params);
1244
1347
  }
1245
1348
  function masteringAssistantSuggest(samples, sampleRate = 22050, params = {}) {
1246
- return requireModule().masteringAssistantSuggest(samples, sampleRate, params);
1349
+ return requireModule4().masteringAssistantSuggest(samples, sampleRate, params);
1247
1350
  }
1248
1351
  function masteringAudioProfile(samples, sampleRate = 22050, params = {}) {
1249
- return requireModule().masteringAudioProfile(samples, sampleRate, params);
1352
+ return requireModule4().masteringAudioProfile(samples, sampleRate, params);
1250
1353
  }
1251
1354
  function masteringStreamingPreview(samples, sampleRate = 22050, platforms = []) {
1252
- return requireModule().masteringStreamingPreview(samples, sampleRate, platforms);
1355
+ return requireModule4().masteringStreamingPreview(samples, sampleRate, platforms);
1253
1356
  }
1254
- function masteringRepairDeclick(samples, sampleRate, options = {}) {
1255
- return requireModule().masteringRepairDeclick(samples, sampleRate, options);
1256
- }
1257
- function masteringRepairDenoiseClassical(samples, sampleRate, options = {}) {
1258
- return requireModule().masteringRepairDenoiseClassical(samples, sampleRate, options);
1259
- }
1260
- function masteringRepairDeclip(samples, sampleRate, options = {}) {
1261
- return requireModule().masteringRepairDeclip(samples, sampleRate, options);
1262
- }
1263
- function masteringRepairDecrackle(samples, sampleRate, options = {}) {
1264
- return requireModule().masteringRepairDecrackle(samples, sampleRate, options);
1265
- }
1266
- function masteringRepairDehum(samples, sampleRate, options = {}) {
1267
- return requireModule().masteringRepairDehum(samples, sampleRate, options);
1268
- }
1269
- function masteringRepairDereverbClassical(samples, sampleRate, options = {}) {
1270
- return requireModule().masteringRepairDereverbClassical(samples, sampleRate, options);
1271
- }
1272
- function masteringRepairTrimSilence(samples, sampleRate, options = {}) {
1273
- return requireModule().masteringRepairTrimSilence(samples, sampleRate, options);
1357
+
1358
+ // src/mastering_dynamics.ts
1359
+ function requireModule5() {
1360
+ return getSonareModule();
1274
1361
  }
1275
1362
  var COMPRESSOR_DETECTOR_MAP = {
1276
1363
  peak: 0,
@@ -1284,95 +1371,58 @@ function masteringDynamicsCompressor(samples, sampleRate, options = {}) {
1284
1371
  if (detector !== void 0) {
1285
1372
  opts.detector = detector;
1286
1373
  }
1287
- return requireModule().masteringDynamicsCompressor(samples, sampleRate, opts);
1374
+ return requireModule5().masteringDynamicsCompressor(samples, sampleRate, opts);
1288
1375
  }
1289
1376
  function masteringDynamicsGate(samples, sampleRate, options = {}) {
1290
1377
  assertSamples("masteringDynamicsGate", samples, options.validate !== false);
1291
- return requireModule().masteringDynamicsGate(samples, sampleRate, options);
1378
+ return requireModule5().masteringDynamicsGate(samples, sampleRate, options);
1292
1379
  }
1293
1380
  function masteringDynamicsTransientShaper(samples, sampleRate, options = {}) {
1294
1381
  assertSamples("masteringDynamicsTransientShaper", samples, options.validate !== false);
1295
- return requireModule().masteringDynamicsTransientShaper(samples, sampleRate, options);
1382
+ return requireModule5().masteringDynamicsTransientShaper(samples, sampleRate, options);
1296
1383
  }
1297
- function masteringChain(samples, sampleRate = 22050, config) {
1298
- return requireModule().masteringChain(samples, sampleRate, config);
1384
+
1385
+ // src/mastering_repair.ts
1386
+ function requireModule6() {
1387
+ return getSonareModule();
1299
1388
  }
1300
- function masteringChainStereo(left, right, sampleRate = 22050, config) {
1301
- if (left.length !== right.length) {
1302
- throw new Error("Stereo channel lengths must match.");
1303
- }
1304
- return requireModule().masteringChainStereo(
1305
- left,
1306
- right,
1307
- sampleRate,
1308
- config
1309
- );
1389
+ function masteringRepairDeclick(samples, sampleRate, options = {}) {
1390
+ return requireModule6().masteringRepairDeclick(samples, sampleRate, options);
1310
1391
  }
1311
- function masteringChainWithProgress(samples, sampleRate = 22050, config, onProgress) {
1312
- return requireModule().masteringChainWithProgress(
1313
- samples,
1314
- sampleRate,
1315
- config,
1316
- onProgress
1317
- );
1392
+ function masteringRepairDenoiseClassical(samples, sampleRate, options = {}) {
1393
+ return requireModule6().masteringRepairDenoiseClassical(samples, sampleRate, options);
1318
1394
  }
1319
- function masteringChainStereoWithProgress(left, right, sampleRate = 22050, config, onProgress) {
1320
- if (left.length !== right.length) {
1321
- throw new Error("Stereo channel lengths must match.");
1322
- }
1323
- return requireModule().masteringChainStereoWithProgress(
1324
- left,
1325
- right,
1326
- sampleRate,
1327
- config,
1328
- onProgress
1329
- );
1395
+ function masteringRepairDeclip(samples, sampleRate, options = {}) {
1396
+ return requireModule6().masteringRepairDeclip(samples, sampleRate, options);
1330
1397
  }
1331
- function masteringPresetNames() {
1332
- return Array.from(requireModule().masteringPresetNames());
1398
+ function masteringRepairDecrackle(samples, sampleRate, options = {}) {
1399
+ return requireModule6().masteringRepairDecrackle(samples, sampleRate, options);
1333
1400
  }
1334
- function masterAudio(samples, sampleRate = 22050, presetName = "pop", overrides = {}) {
1335
- return requireModule().masterAudio(presetName, samples, sampleRate, overrides);
1401
+ function masteringRepairDehum(samples, sampleRate, options = {}) {
1402
+ return requireModule6().masteringRepairDehum(samples, sampleRate, options);
1336
1403
  }
1337
- function masterAudioStereo(left, right, sampleRate = 22050, presetName = "pop", overrides = {}) {
1338
- if (left.length !== right.length) {
1339
- throw new Error("Stereo channel lengths must match.");
1340
- }
1341
- return requireModule().masterAudioStereo(presetName, left, right, sampleRate, overrides);
1404
+ function masteringRepairDereverbClassical(samples, sampleRate, options = {}) {
1405
+ return requireModule6().masteringRepairDereverbClassical(samples, sampleRate, options);
1342
1406
  }
1343
- function masterAudioWithProgress(samples, sampleRate = 22050, presetName, onProgress, overrides = null) {
1344
- return requireModule().masterAudioWithProgress(
1345
- presetName,
1346
- samples,
1347
- sampleRate,
1348
- overrides,
1349
- onProgress
1350
- );
1407
+ function masteringRepairTrimSilence(samples, sampleRate, options = {}) {
1408
+ return requireModule6().masteringRepairTrimSilence(samples, sampleRate, options);
1351
1409
  }
1352
- function masterAudioStereoWithProgress(left, right, sampleRate = 22050, presetName, onProgress, overrides = null) {
1353
- if (left.length !== right.length) {
1354
- throw new Error("Stereo channel lengths must match.");
1355
- }
1356
- return requireModule().masterAudioStereoWithProgress(
1357
- presetName,
1358
- left,
1359
- right,
1360
- sampleRate,
1361
- overrides,
1362
- onProgress
1363
- );
1410
+
1411
+ // src/mixing_oneshot.ts
1412
+ function requireModule7() {
1413
+ return getSonareModule();
1364
1414
  }
1365
1415
  function mixingScenePresetNames() {
1366
- return Array.from(requireModule().mixingScenePresetNames());
1416
+ return Array.from(requireModule7().mixingScenePresetNames());
1367
1417
  }
1368
1418
  function mixingScenePresetJson(presetName) {
1369
- return requireModule().mixingScenePresetJson(presetName);
1419
+ return requireModule7().mixingScenePresetJson(presetName);
1370
1420
  }
1371
1421
  function mixStereo(leftChannels, rightChannels, sampleRate = 48e3, options = {}) {
1372
1422
  if (leftChannels.length === 0 || leftChannels.length !== rightChannels.length) {
1373
1423
  throw new Error("leftChannels and rightChannels must have the same non-zero length.");
1374
1424
  }
1375
- return requireModule().mixStereo(
1425
+ return requireModule7().mixStereo(
1376
1426
  leftChannels,
1377
1427
  rightChannels,
1378
1428
  sampleRate,
@@ -1381,92 +1431,92 @@ function mixStereo(leftChannels, rightChannels, sampleRate = 48e3, options = {})
1381
1431
  }
1382
1432
 
1383
1433
  // src/feature_core.ts
1384
- function requireModule2() {
1434
+ function requireModule8() {
1385
1435
  return getSonareModule();
1386
1436
  }
1387
1437
  function hzToMel(hz) {
1388
- return requireModule2().hzToMel(hz);
1438
+ return requireModule8().hzToMel(hz);
1389
1439
  }
1390
1440
  function melToHz(mel) {
1391
- return requireModule2().melToHz(mel);
1441
+ return requireModule8().melToHz(mel);
1392
1442
  }
1393
1443
  function hzToMidi(hz) {
1394
- return requireModule2().hzToMidi(hz);
1444
+ return requireModule8().hzToMidi(hz);
1395
1445
  }
1396
1446
  function midiToHz(midi) {
1397
- return requireModule2().midiToHz(midi);
1447
+ return requireModule8().midiToHz(midi);
1398
1448
  }
1399
1449
  function hzToNote(hz) {
1400
- return requireModule2().hzToNote(hz);
1450
+ return requireModule8().hzToNote(hz);
1401
1451
  }
1402
1452
  function noteToHz(note) {
1403
- return requireModule2().noteToHz(note);
1453
+ return requireModule8().noteToHz(note);
1404
1454
  }
1405
1455
  function framesToTime(frames, sr = 22050, hopLength = 512) {
1406
- return requireModule2().framesToTime(frames, sr, hopLength);
1456
+ return requireModule8().framesToTime(frames, sr, hopLength);
1407
1457
  }
1408
1458
  function timeToFrames(time, sr = 22050, hopLength = 512) {
1409
- return requireModule2().timeToFrames(time, sr, hopLength);
1459
+ return requireModule8().timeToFrames(time, sr, hopLength);
1410
1460
  }
1411
1461
  function framesToSamples(frames, hopLength = 512, nFft = 0) {
1412
- return requireModule2().framesToSamples(frames, hopLength, nFft);
1462
+ return requireModule8().framesToSamples(frames, hopLength, nFft);
1413
1463
  }
1414
1464
  function samplesToFrames(samples, hopLength = 512, nFft = 0) {
1415
- return requireModule2().samplesToFrames(samples, hopLength, nFft);
1465
+ return requireModule8().samplesToFrames(samples, hopLength, nFft);
1416
1466
  }
1417
1467
  function powerToDb(values, ref = 1, amin = 1e-10, topDb = 80) {
1418
- return requireModule2().powerToDb(values, ref, amin, topDb);
1468
+ return requireModule8().powerToDb(values, ref, amin, topDb);
1419
1469
  }
1420
1470
  function amplitudeToDb(values, ref = 1, amin = 1e-5, topDb = 80) {
1421
- return requireModule2().amplitudeToDb(values, ref, amin, topDb);
1471
+ return requireModule8().amplitudeToDb(values, ref, amin, topDb);
1422
1472
  }
1423
1473
  function dbToPower(values, ref = 1) {
1424
- return requireModule2().dbToPower(values, ref);
1474
+ return requireModule8().dbToPower(values, ref);
1425
1475
  }
1426
1476
  function dbToAmplitude(values, ref = 1) {
1427
- return requireModule2().dbToAmplitude(values, ref);
1477
+ return requireModule8().dbToAmplitude(values, ref);
1428
1478
  }
1429
1479
  function preemphasis(samples, coef = 0.97, zi) {
1430
- return requireModule2().preemphasis(samples, coef, zi ?? null);
1480
+ return requireModule8().preemphasis(samples, coef, zi ?? null);
1431
1481
  }
1432
1482
  function deemphasis(samples, coef = 0.97, zi) {
1433
- return requireModule2().deemphasis(samples, coef, zi ?? null);
1483
+ return requireModule8().deemphasis(samples, coef, zi ?? null);
1434
1484
  }
1435
1485
  function trimSilence(samples, topDb = 60, frameLength = 2048, hopLength = 512) {
1436
- return requireModule2().trimSilence(samples, topDb, frameLength, hopLength);
1486
+ return requireModule8().trimSilence(samples, topDb, frameLength, hopLength);
1437
1487
  }
1438
1488
  function splitSilence(samples, topDb = 60, frameLength = 2048, hopLength = 512) {
1439
- return requireModule2().splitSilence(samples, topDb, frameLength, hopLength);
1489
+ return requireModule8().splitSilence(samples, topDb, frameLength, hopLength);
1440
1490
  }
1441
1491
  function frameSignal(samples, frameLength, hopLength) {
1442
- return requireModule2().frameSignal(samples, frameLength, hopLength);
1492
+ return requireModule8().frameSignal(samples, frameLength, hopLength);
1443
1493
  }
1444
1494
  function padCenter(values, targetSize, padValue = 0) {
1445
- return requireModule2().padCenter(values, targetSize, padValue);
1495
+ return requireModule8().padCenter(values, targetSize, padValue);
1446
1496
  }
1447
1497
  function fixLength(values, targetSize, padValue = 0) {
1448
- return requireModule2().fixLength(values, targetSize, padValue);
1498
+ return requireModule8().fixLength(values, targetSize, padValue);
1449
1499
  }
1450
1500
  function fixFrames(frames, xMin = 0, xMax = -1, pad = true) {
1451
- return requireModule2().fixFrames(frames, xMin, xMax, pad);
1501
+ return requireModule8().fixFrames(frames, xMin, xMax, pad);
1452
1502
  }
1453
1503
  function peakPick(values, preMax, postMax, preAvg, postAvg, delta, wait) {
1454
- return requireModule2().peakPick(values, preMax, postMax, preAvg, postAvg, delta, wait);
1504
+ return requireModule8().peakPick(values, preMax, postMax, preAvg, postAvg, delta, wait);
1455
1505
  }
1456
1506
  function vectorNormalize(values, normType = 0, threshold = 0) {
1457
- return requireModule2().vectorNormalize(values, normType, threshold);
1507
+ return requireModule8().vectorNormalize(values, normType, threshold);
1458
1508
  }
1459
1509
  function pcen(values, nBins, nFrames, options = {}) {
1460
- return requireModule2().pcen(values, nBins, nFrames, options);
1510
+ return requireModule8().pcen(values, nBins, nFrames, options);
1461
1511
  }
1462
1512
  function tonnetz(chromagram, nChroma, nFrames) {
1463
- return requireModule2().tonnetz(chromagram, nChroma, nFrames);
1513
+ return requireModule8().tonnetz(chromagram, nChroma, nFrames);
1464
1514
  }
1465
1515
  function tempogram(onsetEnvelope2, sampleRate = 22050, hopLength = 512, winLength = 384, mode = "autocorrelation") {
1466
- return requireModule2().tempogram(onsetEnvelope2, sampleRate, hopLength, winLength, mode);
1516
+ return requireModule8().tempogram(onsetEnvelope2, sampleRate, hopLength, winLength, mode);
1467
1517
  }
1468
1518
  function cyclicTempogram(onsetEnvelope2, sampleRate = 22050, hopLength = 512, winLength = 384, bpmMin = 60, nBins = 60) {
1469
- return requireModule2().cyclicTempogram(
1519
+ return requireModule8().cyclicTempogram(
1470
1520
  onsetEnvelope2,
1471
1521
  sampleRate,
1472
1522
  hopLength,
@@ -1476,11 +1526,11 @@ function cyclicTempogram(onsetEnvelope2, sampleRate = 22050, hopLength = 512, wi
1476
1526
  );
1477
1527
  }
1478
1528
  function plp(onsetEnvelope2, sampleRate = 22050, hopLength = 512, tempoMin = 30, tempoMax = 300, winLength = 384) {
1479
- return requireModule2().plp(onsetEnvelope2, sampleRate, hopLength, tempoMin, tempoMax, winLength);
1529
+ return requireModule8().plp(onsetEnvelope2, sampleRate, hopLength, tempoMin, tempoMax, winLength);
1480
1530
  }
1481
1531
 
1482
1532
  // src/feature_music.ts
1483
- function requireModule3() {
1533
+ function requireModule9() {
1484
1534
  return getSonareModule();
1485
1535
  }
1486
1536
  function validateMusicSamples(fnName, samples, sampleRate, options = {}) {
@@ -1506,25 +1556,25 @@ function validateFrequencyBounds(fnName, fmin, fmax) {
1506
1556
  }
1507
1557
  function nnlsChroma(samples, sampleRate = 22050, options = {}) {
1508
1558
  validateMusicSamples("nnlsChroma", samples, sampleRate, options);
1509
- return requireModule3().nnlsChroma(samples, sampleRate);
1559
+ return requireModule9().nnlsChroma(samples, sampleRate);
1510
1560
  }
1511
1561
  function cqt(samples, sampleRate = 22050, hopLength = 512, fmin = 32.70319566257483, nBins = 84, binsPerOctave = 12, options = {}) {
1512
1562
  validateMusicSamples("cqt", samples, sampleRate, options);
1513
1563
  validatePositiveIntegers("cqt", { hopLength, nBins, binsPerOctave });
1514
1564
  validateFrequencyBounds("cqt", fmin);
1515
- return requireModule3().cqt(samples, sampleRate, hopLength, fmin, nBins, binsPerOctave);
1565
+ return requireModule9().cqt(samples, sampleRate, hopLength, fmin, nBins, binsPerOctave);
1516
1566
  }
1517
1567
  function pseudoCqt(samples, sampleRate = 22050, hopLength = 512, fmin = 32.70319566257483, nBins = 84, binsPerOctave = 12, options = {}) {
1518
1568
  validateMusicSamples("pseudoCqt", samples, sampleRate, options);
1519
1569
  validatePositiveIntegers("pseudoCqt", { hopLength, nBins, binsPerOctave });
1520
1570
  validateFrequencyBounds("pseudoCqt", fmin);
1521
- return requireModule3().pseudoCqt(samples, sampleRate, hopLength, fmin, nBins, binsPerOctave);
1571
+ return requireModule9().pseudoCqt(samples, sampleRate, hopLength, fmin, nBins, binsPerOctave);
1522
1572
  }
1523
1573
  function hybridCqt(samples, sampleRate = 22050, hopLength = 512, fmin = 32.70319566257483, nBins = 84, binsPerOctave = 12, options = {}) {
1524
1574
  validateMusicSamples("hybridCqt", samples, sampleRate, options);
1525
1575
  validatePositiveIntegers("hybridCqt", { hopLength, nBins, binsPerOctave });
1526
1576
  validateFrequencyBounds("hybridCqt", fmin);
1527
- return requireModule3().hybridCqt(samples, sampleRate, hopLength, fmin, nBins, binsPerOctave);
1577
+ return requireModule9().hybridCqt(samples, sampleRate, hopLength, fmin, nBins, binsPerOctave);
1528
1578
  }
1529
1579
  function vqt(samples, sampleRate = 22050, hopLength = 512, fmin = 32.70319566257483, nBins = 84, binsPerOctave = 12, gamma = 0, options = {}) {
1530
1580
  validateMusicSamples("vqt", samples, sampleRate, options);
@@ -1534,7 +1584,7 @@ function vqt(samples, sampleRate = 22050, hopLength = 512, fmin = 32.70319566257
1534
1584
  if (gamma < 0) {
1535
1585
  throw new RangeError("vqt: gamma must be non-negative");
1536
1586
  }
1537
- return requireModule3().vqt(samples, sampleRate, hopLength, fmin, nBins, binsPerOctave, gamma);
1587
+ return requireModule9().vqt(samples, sampleRate, hopLength, fmin, nBins, binsPerOctave, gamma);
1538
1588
  }
1539
1589
  function analyzeSections(samples, sampleRate = 22050, options = {}) {
1540
1590
  validateMusicSamples("analyzeSections", samples, sampleRate, options);
@@ -1546,7 +1596,7 @@ function analyzeSections(samples, sampleRate = 22050, options = {}) {
1546
1596
  if ((options.minSectionSec ?? 4) <= 0) {
1547
1597
  throw new RangeError("analyzeSections: minSectionSec must be positive");
1548
1598
  }
1549
- const sections = requireModule3().analyzeSections(
1599
+ const sections = requireModule9().analyzeSections(
1550
1600
  samples,
1551
1601
  sampleRate,
1552
1602
  options.nFft ?? 2048,
@@ -1572,7 +1622,7 @@ function analyzeMelody(samples, sampleRate = 22050, options = {}) {
1572
1622
  if (threshold <= 0) {
1573
1623
  throw new RangeError("analyzeMelody: threshold must be positive");
1574
1624
  }
1575
- return requireModule3().analyzeMelody(
1625
+ return requireModule9().analyzeMelody(
1576
1626
  samples,
1577
1627
  sampleRate,
1578
1628
  options.fmin ?? 65,
@@ -1587,47 +1637,47 @@ function analyzeMelody(samples, sampleRate = 22050, options = {}) {
1587
1637
  function onsetEnvelope(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, nMels = 128, options = {}) {
1588
1638
  validateMusicSamples("onsetEnvelope", samples, sampleRate, options);
1589
1639
  validatePositiveIntegers("onsetEnvelope", { nFft, hopLength, nMels });
1590
- return requireModule3().onsetEnvelope(samples, sampleRate, nFft, hopLength, nMels);
1640
+ return requireModule9().onsetEnvelope(samples, sampleRate, nFft, hopLength, nMels);
1591
1641
  }
1592
1642
  function onsetStrengthMulti(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, nMels = 128, nBands = 3, options = {}) {
1593
1643
  validateMusicSamples("onsetStrengthMulti", samples, sampleRate, options);
1594
1644
  validatePositiveIntegers("onsetStrengthMulti", { nFft, hopLength, nMels, nBands });
1595
- return requireModule3().onsetStrengthMulti(samples, sampleRate, nFft, hopLength, nMels, nBands);
1645
+ return requireModule9().onsetStrengthMulti(samples, sampleRate, nFft, hopLength, nMels, nBands);
1596
1646
  }
1597
1647
  function fourierTempogram(onsetEnvelope2, sampleRate = 22050, hopLength = 512, winLength = 384, options = {}) {
1598
1648
  assertSampleRate("fourierTempogram", sampleRate);
1599
1649
  assertSamples("fourierTempogram", onsetEnvelope2, options.validate !== false, "onsetEnvelope");
1600
1650
  validatePositiveIntegers("fourierTempogram", { hopLength, winLength });
1601
- return requireModule3().fourierTempogram(onsetEnvelope2, sampleRate, hopLength, winLength);
1651
+ return requireModule9().fourierTempogram(onsetEnvelope2, sampleRate, hopLength, winLength);
1602
1652
  }
1603
1653
  function tempogramRatio(tempogramData, winLength = 384, sampleRate = 22050, hopLength = 512, options = {}) {
1604
1654
  assertSampleRate("tempogramRatio", sampleRate);
1605
1655
  assertSamples("tempogramRatio", tempogramData, options.validate !== false, "tempogramData");
1606
1656
  validatePositiveIntegers("tempogramRatio", { winLength, hopLength });
1607
- return requireModule3().tempogramRatio(tempogramData, winLength, sampleRate, hopLength);
1657
+ return requireModule9().tempogramRatio(tempogramData, winLength, sampleRate, hopLength);
1608
1658
  }
1609
1659
  function lufs(samples, sampleRate = 22050, options = {}) {
1610
1660
  assertSampleRate("lufs", sampleRate);
1611
1661
  assertSamples("lufs", samples, options.validate !== false);
1612
- return requireModule3().lufs(samples, sampleRate);
1662
+ return requireModule9().lufs(samples, sampleRate);
1613
1663
  }
1614
1664
  function momentaryLufs(samples, sampleRate = 22050, options = {}) {
1615
1665
  assertSampleRate("momentaryLufs", sampleRate);
1616
1666
  assertSamples("momentaryLufs", samples, options.validate !== false);
1617
- return requireModule3().momentaryLufs(samples, sampleRate);
1667
+ return requireModule9().momentaryLufs(samples, sampleRate);
1618
1668
  }
1619
1669
  function shortTermLufs(samples, sampleRate = 22050, options = {}) {
1620
1670
  assertSampleRate("shortTermLufs", sampleRate);
1621
1671
  assertSamples("shortTermLufs", samples, options.validate !== false);
1622
- return requireModule3().shortTermLufs(samples, sampleRate);
1672
+ return requireModule9().shortTermLufs(samples, sampleRate);
1623
1673
  }
1624
1674
 
1625
1675
  // src/feature_pitch.ts
1626
- function requireModule4() {
1676
+ function requireModule10() {
1627
1677
  return getSonareModule();
1628
1678
  }
1629
1679
  function pitchYin(samples, sampleRate = 22050, frameLength = 2048, hopLength = 512, fmin = 65, fmax = 2093, threshold = 0.3, fillNa = false) {
1630
- return requireModule4().pitchYin(
1680
+ return requireModule10().pitchYin(
1631
1681
  samples,
1632
1682
  sampleRate,
1633
1683
  frameLength,
@@ -1639,7 +1689,7 @@ function pitchYin(samples, sampleRate = 22050, frameLength = 2048, hopLength = 5
1639
1689
  );
1640
1690
  }
1641
1691
  function pitchPyin(samples, sampleRate = 22050, frameLength = 2048, hopLength = 512, fmin = 65, fmax = 2093, threshold = 0.3, fillNa = false) {
1642
- return requireModule4().pitchPyin(
1692
+ return requireModule10().pitchPyin(
1643
1693
  samples,
1644
1694
  sampleRate,
1645
1695
  frameLength,
@@ -1652,22 +1702,22 @@ function pitchPyin(samples, sampleRate = 22050, frameLength = 2048, hopLength =
1652
1702
  }
1653
1703
 
1654
1704
  // src/feature_resample.ts
1655
- function requireModule5() {
1705
+ function requireModule11() {
1656
1706
  return getSonareModule();
1657
1707
  }
1658
1708
  function resample(samples, srcSr, targetSr) {
1659
- return requireModule5().resample(samples, srcSr, targetSr);
1709
+ return requireModule11().resample(samples, srcSr, targetSr);
1660
1710
  }
1661
1711
 
1662
1712
  // src/feature_spectral.ts
1663
- function requireModule6() {
1713
+ function requireModule12() {
1664
1714
  return getSonareModule();
1665
1715
  }
1666
1716
  function spectralCentroid(samples, sampleRate = 22050, nFft = 2048, hopLength = 512) {
1667
- return requireModule6().spectralCentroid(samples, sampleRate, nFft, hopLength);
1717
+ return requireModule12().spectralCentroid(samples, sampleRate, nFft, hopLength);
1668
1718
  }
1669
1719
  function spectralContrast(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, nBands = 6, fmin = 200, quantile = 0.02) {
1670
- return requireModule6().spectralContrast(
1720
+ return requireModule12().spectralContrast(
1671
1721
  samples,
1672
1722
  sampleRate,
1673
1723
  nFft,
@@ -1678,16 +1728,16 @@ function spectralContrast(samples, sampleRate = 22050, nFft = 2048, hopLength =
1678
1728
  );
1679
1729
  }
1680
1730
  function polyFeatures(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, order = 1) {
1681
- return requireModule6().polyFeatures(samples, sampleRate, nFft, hopLength, order);
1731
+ return requireModule12().polyFeatures(samples, sampleRate, nFft, hopLength, order);
1682
1732
  }
1683
1733
  function zeroCrossings(samples, threshold = 1e-10, refMagnitude = false, pad = true, zeroPos = true) {
1684
- return requireModule6().zeroCrossings(samples, threshold, refMagnitude, pad, zeroPos);
1734
+ return requireModule12().zeroCrossings(samples, threshold, refMagnitude, pad, zeroPos);
1685
1735
  }
1686
1736
  function pitchTuning(frequencies, resolution = 0.01, binsPerOctave = 12) {
1687
- return requireModule6().pitchTuning(frequencies, resolution, binsPerOctave);
1737
+ return requireModule12().pitchTuning(frequencies, resolution, binsPerOctave);
1688
1738
  }
1689
1739
  function estimateTuning(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, resolution = 0.01, binsPerOctave = 12) {
1690
- return requireModule6().estimateTuning(
1740
+ return requireModule12().estimateTuning(
1691
1741
  samples,
1692
1742
  sampleRate,
1693
1743
  nFft,
@@ -1697,50 +1747,50 @@ function estimateTuning(samples, sampleRate = 22050, nFft = 2048, hopLength = 51
1697
1747
  );
1698
1748
  }
1699
1749
  function decompose(s, nFeatures, nFrames, nComponents, nIter = 50, beta = 2) {
1700
- return requireModule6().decompose(s, nFeatures, nFrames, nComponents, nIter, beta);
1750
+ return requireModule12().decompose(s, nFeatures, nFrames, nComponents, nIter, beta);
1701
1751
  }
1702
1752
  function decomposeWithInit(s, nFeatures, nFrames, nComponents, nIter = 50, beta = 2, init2 = "random") {
1703
- return requireModule6().decomposeWithInit(s, nFeatures, nFrames, nComponents, nIter, beta, init2);
1753
+ return requireModule12().decomposeWithInit(s, nFeatures, nFrames, nComponents, nIter, beta, init2);
1704
1754
  }
1705
1755
  function nnFilter(s, nFeatures, nFrames, aggregate = "mean", k = 7, width = 1) {
1706
- return requireModule6().nnFilter(s, nFeatures, nFrames, aggregate, k, width);
1756
+ return requireModule12().nnFilter(s, nFeatures, nFrames, aggregate, k, width);
1707
1757
  }
1708
1758
  function remix(samples, intervals, sampleRate = 22050, alignZeros = false) {
1709
1759
  const intervalsI32 = intervals instanceof Int32Array ? intervals : Int32Array.from(intervals, (v) => Math.trunc(v));
1710
- return requireModule6().remix(samples, intervalsI32, sampleRate, alignZeros);
1760
+ return requireModule12().remix(samples, intervalsI32, sampleRate, alignZeros);
1711
1761
  }
1712
1762
  function phaseVocoder(samples, rate, sampleRate = 22050, nFft = 2048, hopLength = 512) {
1713
- return requireModule6().phaseVocoder(samples, sampleRate, rate, nFft, hopLength);
1763
+ return requireModule12().phaseVocoder(samples, sampleRate, rate, nFft, hopLength);
1714
1764
  }
1715
1765
  function hpssWithResidual(samples, sampleRate = 22050, kernelHarmonic = 31, kernelPercussive = 31) {
1716
- return requireModule6().hpssWithResidual(samples, sampleRate, kernelHarmonic, kernelPercussive);
1766
+ return requireModule12().hpssWithResidual(samples, sampleRate, kernelHarmonic, kernelPercussive);
1717
1767
  }
1718
1768
  function lufsInterleaved(samples, channels, sampleRate = 22050, options = {}) {
1719
1769
  assertSampleRate("lufsInterleaved", sampleRate);
1720
1770
  assertInterleavedSamples("lufsInterleaved", samples, channels, options.validate !== false);
1721
- return requireModule6().lufsInterleaved(samples, channels, sampleRate);
1771
+ return requireModule12().lufsInterleaved(samples, channels, sampleRate);
1722
1772
  }
1723
1773
  function ebur128LoudnessRange(samples, sampleRate = 22050) {
1724
- return requireModule6().ebur128LoudnessRange(samples, sampleRate);
1774
+ return requireModule12().ebur128LoudnessRange(samples, sampleRate);
1725
1775
  }
1726
1776
  function spectralBandwidth(samples, sampleRate = 22050, nFft = 2048, hopLength = 512) {
1727
- return requireModule6().spectralBandwidth(samples, sampleRate, nFft, hopLength);
1777
+ return requireModule12().spectralBandwidth(samples, sampleRate, nFft, hopLength);
1728
1778
  }
1729
1779
  function spectralRolloff(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, rollPercent = 0.85) {
1730
- return requireModule6().spectralRolloff(samples, sampleRate, nFft, hopLength, rollPercent);
1780
+ return requireModule12().spectralRolloff(samples, sampleRate, nFft, hopLength, rollPercent);
1731
1781
  }
1732
1782
  function spectralFlatness(samples, sampleRate = 22050, nFft = 2048, hopLength = 512) {
1733
- return requireModule6().spectralFlatness(samples, sampleRate, nFft, hopLength);
1783
+ return requireModule12().spectralFlatness(samples, sampleRate, nFft, hopLength);
1734
1784
  }
1735
1785
  function zeroCrossingRate(samples, sampleRate = 22050, frameLength = 2048, hopLength = 512) {
1736
- return requireModule6().zeroCrossingRate(samples, sampleRate, frameLength, hopLength);
1786
+ return requireModule12().zeroCrossingRate(samples, sampleRate, frameLength, hopLength);
1737
1787
  }
1738
1788
  function rmsEnergy(samples, sampleRate = 22050, frameLength = 2048, hopLength = 512) {
1739
- return requireModule6().rmsEnergy(samples, sampleRate, frameLength, hopLength);
1789
+ return requireModule12().rmsEnergy(samples, sampleRate, frameLength, hopLength);
1740
1790
  }
1741
1791
 
1742
1792
  // src/feature_spectrogram.ts
1743
- function requireModule7() {
1793
+ function requireModule13() {
1744
1794
  return getSonareModule();
1745
1795
  }
1746
1796
  function validateSpectrogramSamples(fnName, samples, sampleRate, options = {}) {
@@ -1777,33 +1827,38 @@ function validateMatrix(fnName, data, rows, frames, dataName, rowName, options =
1777
1827
  function trim(samples, sampleRate, thresholdDb = -60, options = {}) {
1778
1828
  validateSpectrogramSamples("trim", samples, sampleRate, options);
1779
1829
  assertFiniteScalar("trim", thresholdDb, "thresholdDb");
1780
- return requireModule7().trim(samples, sampleRate, thresholdDb);
1830
+ return requireModule13().trim(samples, sampleRate, thresholdDb);
1781
1831
  }
1782
1832
  function stft(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, options = {}) {
1783
1833
  validateSpectrogramSamples("stft", samples, sampleRate, options);
1784
1834
  validatePositiveIntegers2("stft", { nFft, hopLength });
1785
- return requireModule7().stft(samples, sampleRate, nFft, hopLength);
1835
+ return requireModule13().stft(samples, sampleRate, nFft, hopLength);
1786
1836
  }
1787
1837
  function stftDb(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, options = {}) {
1788
1838
  validateSpectrogramSamples("stftDb", samples, sampleRate, options);
1789
1839
  validatePositiveIntegers2("stftDb", { nFft, hopLength });
1790
- return requireModule7().stftDb(samples, sampleRate, nFft, hopLength);
1840
+ return requireModule13().stftDb(samples, sampleRate, nFft, hopLength);
1791
1841
  }
1792
1842
  function chromaCens(samples, sampleRate = 22050, hopLength = 512, nChroma = 12, options = {}) {
1793
1843
  validateSpectrogramSamples("chromaCens", samples, sampleRate, options);
1794
1844
  validatePositiveIntegers2("chromaCens", { hopLength, nChroma });
1795
- return requireModule7().chromaCens(samples, sampleRate, hopLength, nChroma);
1845
+ return requireModule13().chromaCens(samples, sampleRate, hopLength, nChroma);
1846
+ }
1847
+ function chromaCqt(samples, sampleRate = 22050, hopLength = 512, nChroma = 12, options = {}) {
1848
+ validateSpectrogramSamples("chromaCqt", samples, sampleRate, options);
1849
+ validatePositiveIntegers2("chromaCqt", { hopLength, nChroma });
1850
+ return requireModule13().chromaCqt(samples, sampleRate, hopLength, nChroma);
1796
1851
  }
1797
1852
  function bassChroma(samples, sampleRate = 22050, hopLength = 512, nChroma = 12, options = {}) {
1798
1853
  validateSpectrogramSamples("bassChroma", samples, sampleRate, options);
1799
1854
  validatePositiveIntegers2("bassChroma", { hopLength, nChroma });
1800
- return requireModule7().bassChroma(samples, sampleRate, hopLength, nChroma);
1855
+ return requireModule13().bassChroma(samples, sampleRate, hopLength, nChroma);
1801
1856
  }
1802
1857
  function melSpectrogram(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, nMels = 128, fmin = 0, fmax = 0, htk = false, options = {}) {
1803
1858
  validateSpectrogramSamples("melSpectrogram", samples, sampleRate, options);
1804
1859
  validatePositiveIntegers2("melSpectrogram", { nFft, hopLength, nMels });
1805
1860
  validateMelFrequencyRange("melSpectrogram", fmin, fmax, sampleRate);
1806
- return requireModule7().melSpectrogram(
1861
+ return requireModule13().melSpectrogram(
1807
1862
  samples,
1808
1863
  sampleRate,
1809
1864
  nFft,
@@ -1814,25 +1869,36 @@ function melSpectrogram(samples, sampleRate = 22050, nFft = 2048, hopLength = 51
1814
1869
  htk
1815
1870
  );
1816
1871
  }
1817
- function mfcc(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, nMels = 128, nMfcc = 20, fmin = 0, fmax = 0, htk = false, options = {}) {
1872
+ function mfcc(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, nMels = 128, nMfcc = 20, fmin = 0, fmax = 0, htk = false, lifter = 0, options = {}) {
1818
1873
  validateSpectrogramSamples("mfcc", samples, sampleRate, options);
1819
1874
  validatePositiveIntegers2("mfcc", { nFft, hopLength, nMels, nMfcc });
1820
1875
  validateMelFrequencyRange("mfcc", fmin, fmax, sampleRate);
1821
- return requireModule7().mfcc(samples, sampleRate, nFft, hopLength, nMels, nMfcc, fmin, fmax, htk);
1876
+ return requireModule13().mfcc(
1877
+ samples,
1878
+ sampleRate,
1879
+ nFft,
1880
+ hopLength,
1881
+ nMels,
1882
+ nMfcc,
1883
+ fmin,
1884
+ fmax,
1885
+ htk,
1886
+ lifter
1887
+ );
1822
1888
  }
1823
1889
  function melToStft(melPower, nMels, nFrames, sampleRate = 22050, nFft = 2048, fmin = 0, fmax = 0, htk = false, options = {}) {
1824
1890
  assertSampleRate("melToStft", sampleRate);
1825
1891
  validateMatrix("melToStft", melPower, nMels, nFrames, "melPower", "nMels", options);
1826
1892
  validatePositiveIntegers2("melToStft", { nFft });
1827
1893
  validateMelFrequencyRange("melToStft", fmin, fmax, sampleRate);
1828
- return requireModule7().melToStft(melPower, nMels, nFrames, sampleRate, nFft, fmin, fmax, htk);
1894
+ return requireModule13().melToStft(melPower, nMels, nFrames, sampleRate, nFft, fmin, fmax, htk);
1829
1895
  }
1830
1896
  function melToAudio(melPower, nMels, nFrames, sampleRate = 22050, nFft = 2048, hopLength = 512, fmin = 0, fmax = 0, nIter = 32, htk = false, options = {}) {
1831
1897
  assertSampleRate("melToAudio", sampleRate);
1832
1898
  validateMatrix("melToAudio", melPower, nMels, nFrames, "melPower", "nMels", options);
1833
1899
  validatePositiveIntegers2("melToAudio", { nFft, hopLength, nIter });
1834
1900
  validateMelFrequencyRange("melToAudio", fmin, fmax, sampleRate);
1835
- return requireModule7().melToAudio(
1901
+ return requireModule13().melToAudio(
1836
1902
  melPower,
1837
1903
  nMels,
1838
1904
  nFrames,
@@ -1856,7 +1922,7 @@ function mfccToMel(mfccCoefficients, nMfcc, nFrames, nMels = 128, options = {})
1856
1922
  options
1857
1923
  );
1858
1924
  validatePositiveIntegers2("mfccToMel", { nMels });
1859
- return requireModule7().mfccToMel(mfccCoefficients, nMfcc, nFrames, nMels);
1925
+ return requireModule13().mfccToMel(mfccCoefficients, nMfcc, nFrames, nMels);
1860
1926
  }
1861
1927
  function mfccToAudio(mfccCoefficients, nMfcc, nFrames, nMels = 128, sampleRate = 22050, nFft = 2048, hopLength = 512, fmin = 0, fmax = 0, nIter = 32, htk = false, options = {}) {
1862
1928
  assertSampleRate("mfccToAudio", sampleRate);
@@ -1871,7 +1937,7 @@ function mfccToAudio(mfccCoefficients, nMfcc, nFrames, nMels = 128, sampleRate =
1871
1937
  );
1872
1938
  validatePositiveIntegers2("mfccToAudio", { nMels, nFft, hopLength, nIter });
1873
1939
  validateMelFrequencyRange("mfccToAudio", fmin, fmax, sampleRate);
1874
- return requireModule7().mfccToAudio(
1940
+ return requireModule13().mfccToAudio(
1875
1941
  mfccCoefficients,
1876
1942
  nMfcc,
1877
1943
  nFrames,
@@ -1888,10 +1954,10 @@ function mfccToAudio(mfccCoefficients, nMfcc, nFrames, nMels = 128, sampleRate =
1888
1954
  function chroma(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, options = {}) {
1889
1955
  validateSpectrogramSamples("chroma", samples, sampleRate, options);
1890
1956
  validatePositiveIntegers2("chroma", { nFft, hopLength });
1891
- return requireModule7().chroma(samples, sampleRate, nFft, hopLength);
1957
+ return requireModule13().chroma(samples, sampleRate, nFft, hopLength);
1892
1958
  }
1893
1959
 
1894
- // src/public_types.ts
1960
+ // src/public_types_music.ts
1895
1961
  var PitchClass = {
1896
1962
  C: 0,
1897
1963
  Cs: 1,
@@ -2086,7 +2152,7 @@ function convertAnalysisResult(wasm) {
2086
2152
  }
2087
2153
 
2088
2154
  // src/quick_analysis.ts
2089
- function requireModule8() {
2155
+ function requireModule14() {
2090
2156
  return getSonareModule();
2091
2157
  }
2092
2158
  function validateAnalysisInput(fnName, samples, sampleRate, options = {}) {
@@ -2095,11 +2161,11 @@ function validateAnalysisInput(fnName, samples, sampleRate, options = {}) {
2095
2161
  }
2096
2162
  function detectBpm(samples, sampleRate = 22050, options = {}) {
2097
2163
  validateAnalysisInput("detectBpm", samples, sampleRate, options);
2098
- return requireModule8().detectBpm(samples, sampleRate);
2164
+ return requireModule14().detectBpm(samples, sampleRate);
2099
2165
  }
2100
2166
  function detectKey(samples, sampleRate = 22050, options = {}) {
2101
2167
  validateAnalysisInput("detectKey", samples, sampleRate, options);
2102
- const result = requireModule8()._detectKeyWithOptions(
2168
+ const result = requireModule14()._detectKeyWithOptions(
2103
2169
  samples,
2104
2170
  sampleRate,
2105
2171
  options.nFft ?? 4096,
@@ -2121,7 +2187,7 @@ function detectKey(samples, sampleRate = 22050, options = {}) {
2121
2187
  }
2122
2188
  function detectKeyCandidates(samples, sampleRate = 22050, options = {}) {
2123
2189
  validateAnalysisInput("detectKeyCandidates", samples, sampleRate, options);
2124
- const candidates = requireModule8()._detectKeyCandidates(
2190
+ const candidates = requireModule14()._detectKeyCandidates(
2125
2191
  samples,
2126
2192
  sampleRate,
2127
2193
  options.nFft ?? 4096,
@@ -2137,19 +2203,19 @@ function detectKeyCandidates(samples, sampleRate = 22050, options = {}) {
2137
2203
  }
2138
2204
  function detectOnsets(samples, sampleRate = 22050, options = {}) {
2139
2205
  validateAnalysisInput("detectOnsets", samples, sampleRate, options);
2140
- return requireModule8().detectOnsets(samples, sampleRate);
2206
+ return requireModule14().detectOnsets(samples, sampleRate);
2141
2207
  }
2142
2208
  function detectBeats(samples, sampleRate = 22050, options = {}) {
2143
2209
  validateAnalysisInput("detectBeats", samples, sampleRate, options);
2144
- return requireModule8().detectBeats(samples, sampleRate);
2210
+ return requireModule14().detectBeats(samples, sampleRate);
2145
2211
  }
2146
2212
  function detectDownbeats(samples, sampleRate = 22050, options = {}) {
2147
2213
  validateAnalysisInput("detectDownbeats", samples, sampleRate, options);
2148
- return requireModule8().detectDownbeats(samples, sampleRate);
2214
+ return requireModule14().detectDownbeats(samples, sampleRate);
2149
2215
  }
2150
2216
  function detectChords(samples, sampleRate = 22050, options = {}) {
2151
2217
  validateAnalysisInput("detectChords", samples, sampleRate, options);
2152
- const result = requireModule8().detectChords(
2218
+ const result = requireModule14().detectChords(
2153
2219
  samples,
2154
2220
  sampleRate,
2155
2221
  options.minDuration ?? 0.3,
@@ -2171,7 +2237,7 @@ function detectChords(samples, sampleRate = 22050, options = {}) {
2171
2237
  }
2172
2238
  function chordFunctionalAnalysis(samples, keyRoot, keyMode, sampleRate = 22050, options = {}) {
2173
2239
  validateAnalysisInput("chordFunctionalAnalysis", samples, sampleRate, options);
2174
- return requireModule8().chordFunctionalAnalysis(
2240
+ return requireModule14().chordFunctionalAnalysis(
2175
2241
  samples,
2176
2242
  keyRoot,
2177
2243
  keyMode,
@@ -2192,12 +2258,12 @@ function chordFunctionalAnalysis(samples, keyRoot, keyMode, sampleRate = 22050,
2192
2258
  }
2193
2259
  function analyze(samples, sampleRate = 22050, options = {}) {
2194
2260
  validateAnalysisInput("analyze", samples, sampleRate, options);
2195
- const result = requireModule8().analyze(samples, sampleRate);
2261
+ const result = requireModule14().analyze(samples, sampleRate);
2196
2262
  return convertAnalysisResult(result);
2197
2263
  }
2198
2264
  function analyzeImpulseResponse(samples, sampleRate = 48e3, nOctaveBands = 6) {
2199
2265
  validateAnalysisInput("analyzeImpulseResponse", samples, sampleRate);
2200
- const result = requireModule8().analyzeImpulseResponse(
2266
+ const result = requireModule14().analyzeImpulseResponse(
2201
2267
  samples,
2202
2268
  sampleRate,
2203
2269
  nOctaveBands
@@ -2206,7 +2272,7 @@ function analyzeImpulseResponse(samples, sampleRate = 48e3, nOctaveBands = 6) {
2206
2272
  }
2207
2273
  function detectAcoustic(samples, sampleRate = 48e3, options = {}) {
2208
2274
  validateAnalysisInput("detectAcoustic", samples, sampleRate);
2209
- const result = requireModule8().detectAcoustic(
2275
+ const result = requireModule14().detectAcoustic(
2210
2276
  samples,
2211
2277
  sampleRate,
2212
2278
  options.nOctaveBands ?? 6,
@@ -2217,14 +2283,14 @@ function detectAcoustic(samples, sampleRate = 48e3, options = {}) {
2217
2283
  return result;
2218
2284
  }
2219
2285
  function synthesizeRir(options = {}) {
2220
- const module2 = requireModule8();
2286
+ const module2 = requireModule14();
2221
2287
  if (typeof module2.synthesizeRir !== "function") {
2222
2288
  throw new Error("libsonare was built without acoustic-simulation support");
2223
2289
  }
2224
2290
  return module2.synthesizeRir(options);
2225
2291
  }
2226
2292
  function estimateRoom(samples, sampleRate = 48e3, options = {}) {
2227
- const module2 = requireModule8();
2293
+ const module2 = requireModule14();
2228
2294
  if (typeof module2.estimateRoom !== "function") {
2229
2295
  throw new Error("libsonare was built without acoustic-simulation support");
2230
2296
  }
@@ -2232,7 +2298,7 @@ function estimateRoom(samples, sampleRate = 48e3, options = {}) {
2232
2298
  return module2.estimateRoom(samples, sampleRate, options);
2233
2299
  }
2234
2300
  function roomMorph(samples, sampleRate, options = {}) {
2235
- const module2 = requireModule8();
2301
+ const module2 = requireModule14();
2236
2302
  if (typeof module2.roomMorph !== "function") {
2237
2303
  throw new Error("libsonare was built without acoustic-simulation support");
2238
2304
  }
@@ -2241,13 +2307,13 @@ function roomMorph(samples, sampleRate, options = {}) {
2241
2307
  }
2242
2308
  function analyzeWithProgress(samples, sampleRate = 22050, onProgress) {
2243
2309
  validateAnalysisInput("analyzeWithProgress", samples, sampleRate);
2244
- const result = requireModule8().analyzeWithProgress(samples, sampleRate, onProgress);
2310
+ const result = requireModule14().analyzeWithProgress(samples, sampleRate, onProgress);
2245
2311
  return convertAnalysisResult(result);
2246
2312
  }
2247
2313
  function analyzeBpm(samples, sampleRate = 22050, options = {}) {
2248
2314
  validateAnalysisInput("analyzeBpm", samples, sampleRate, options);
2249
2315
  assertNonNegativeInteger("analyzeBpm", options.maxCandidates ?? 5, "maxCandidates");
2250
- return requireModule8().analyzeBpm(
2316
+ return requireModule14().analyzeBpm(
2251
2317
  samples,
2252
2318
  sampleRate,
2253
2319
  options.bpmMin ?? 30,
@@ -2260,7 +2326,7 @@ function analyzeBpm(samples, sampleRate = 22050, options = {}) {
2260
2326
  }
2261
2327
  function analyzeRhythm(samples, sampleRate = 22050, options = {}) {
2262
2328
  validateAnalysisInput("analyzeRhythm", samples, sampleRate, options);
2263
- return requireModule8().analyzeRhythm(
2329
+ return requireModule14().analyzeRhythm(
2264
2330
  samples,
2265
2331
  sampleRate,
2266
2332
  options.bpmMin ?? 60,
@@ -2272,7 +2338,7 @@ function analyzeRhythm(samples, sampleRate = 22050, options = {}) {
2272
2338
  }
2273
2339
  function analyzeDynamics(samples, sampleRate = 22050, options = {}) {
2274
2340
  validateAnalysisInput("analyzeDynamics", samples, sampleRate, options);
2275
- return requireModule8().analyzeDynamics(
2341
+ return requireModule14().analyzeDynamics(
2276
2342
  samples,
2277
2343
  sampleRate,
2278
2344
  options.windowSec ?? 0.4,
@@ -2282,7 +2348,7 @@ function analyzeDynamics(samples, sampleRate = 22050, options = {}) {
2282
2348
  }
2283
2349
  function analyzeTimbre(samples, sampleRate = 22050, options = {}) {
2284
2350
  validateAnalysisInput("analyzeTimbre", samples, sampleRate, options);
2285
- return requireModule8().analyzeTimbre(
2351
+ return requireModule14().analyzeTimbre(
2286
2352
  samples,
2287
2353
  sampleRate,
2288
2354
  options.nFft ?? 2048,
@@ -2293,7 +2359,7 @@ function analyzeTimbre(samples, sampleRate = 22050, options = {}) {
2293
2359
  );
2294
2360
  }
2295
2361
  function hasFfmpegSupport() {
2296
- return requireModule8().hasFfmpegSupport();
2362
+ return requireModule14().hasFfmpegSupport();
2297
2363
  }
2298
2364
 
2299
2365
  // src/audio.ts
@@ -2557,155 +2623,6 @@ var Audio = class _Audio {
2557
2623
  }
2558
2624
  };
2559
2625
 
2560
- // src/live_audio.ts
2561
- async function bindMicrophoneInput(context, engine, options = {}) {
2562
- const { stream: providedStream, stopTracksOnClose = true, ...constraints } = options;
2563
- const stream = providedStream ?? await navigator.mediaDevices.getUserMedia({
2564
- ...constraints,
2565
- audio: constraints.audio ?? true,
2566
- video: constraints.video ?? false
2567
- });
2568
- const source = context.createMediaStreamSource(stream);
2569
- const node = "node" in engine ? engine.node : engine;
2570
- source.connect(node);
2571
- let closed = false;
2572
- return {
2573
- stream,
2574
- source,
2575
- close() {
2576
- if (closed) {
2577
- return;
2578
- }
2579
- closed = true;
2580
- source.disconnect();
2581
- if (stopTracksOnClose) {
2582
- for (const track of stream.getAudioTracks()) {
2583
- track.stop();
2584
- }
2585
- }
2586
- }
2587
- };
2588
- }
2589
-
2590
- // src/metering.ts
2591
- function requireModule9() {
2592
- return getSonareModule();
2593
- }
2594
- function meteringPeakDb(samples, sampleRate = 22050, options = {}) {
2595
- assertSamples("meteringPeakDb", samples, options.validate !== false);
2596
- return requireModule9().meteringPeakDb(samples, sampleRate);
2597
- }
2598
- function meteringRmsDb(samples, sampleRate = 22050, options = {}) {
2599
- assertSamples("meteringRmsDb", samples, options.validate !== false);
2600
- return requireModule9().meteringRmsDb(samples, sampleRate);
2601
- }
2602
- function meteringCrestFactorDb(samples, sampleRate = 22050, options = {}) {
2603
- assertSamples("meteringCrestFactorDb", samples, options.validate !== false);
2604
- return requireModule9().meteringCrestFactorDb(samples, sampleRate);
2605
- }
2606
- function meteringDcOffset(samples, sampleRate = 22050, options = {}) {
2607
- assertSamples("meteringDcOffset", samples, options.validate !== false);
2608
- return requireModule9().meteringDcOffset(samples, sampleRate);
2609
- }
2610
- function meteringTruePeakDb(samples, sampleRate = 22050, oversampleFactor = 4, options = {}) {
2611
- assertSamples("meteringTruePeakDb", samples, options.validate !== false);
2612
- const factor = oversampleFactor === 0 ? 4 : oversampleFactor;
2613
- if (factor < 1 || factor > 16 || (factor & factor - 1) !== 0) {
2614
- throw new RangeError(
2615
- "meteringTruePeakDb: oversampleFactor must be 0 or a power of two from 1 to 16"
2616
- );
2617
- }
2618
- return requireModule9().meteringTruePeakDb(samples, sampleRate, oversampleFactor);
2619
- }
2620
- function meteringDetectClipping(samples, sampleRate = 22050, options = {}) {
2621
- assertSamples("meteringDetectClipping", samples, options.validate !== false);
2622
- return requireModule9().meteringDetectClipping(
2623
- samples,
2624
- sampleRate,
2625
- options.threshold ?? 0.999,
2626
- options.minRegionSamples ?? 1
2627
- );
2628
- }
2629
- function meteringDynamicRange(samples, sampleRate = 22050, options = {}) {
2630
- assertSamples("meteringDynamicRange", samples, options.validate !== false);
2631
- return requireModule9().meteringDynamicRange(
2632
- samples,
2633
- sampleRate,
2634
- options.windowSec ?? 0,
2635
- options.hopSec ?? 0,
2636
- options.lowPercentile ?? -1,
2637
- options.highPercentile ?? -1
2638
- );
2639
- }
2640
- function meteringStereoCorrelation(left, right, sampleRate = 22050, options = {}) {
2641
- const validate = options.validate !== false;
2642
- assertSamples("meteringStereoCorrelation", left, validate, "left");
2643
- assertSamples("meteringStereoCorrelation", right, validate, "right");
2644
- return requireModule9().meteringStereoCorrelation(left, right, sampleRate);
2645
- }
2646
- function meteringStereoWidth(left, right, sampleRate = 22050, options = {}) {
2647
- const validate = options.validate !== false;
2648
- assertSamples("meteringStereoWidth", left, validate, "left");
2649
- assertSamples("meteringStereoWidth", right, validate, "right");
2650
- return requireModule9().meteringStereoWidth(left, right, sampleRate);
2651
- }
2652
- function meteringVectorscope(left, right, sampleRate = 22050, options = {}) {
2653
- const validate = options.validate !== false;
2654
- assertSamples("meteringVectorscope", left, validate, "left");
2655
- assertSamples("meteringVectorscope", right, validate, "right");
2656
- return requireModule9().meteringVectorscope(left, right, sampleRate);
2657
- }
2658
- function meteringVectorscopeDecimated(left, right, sampleRate = 22050, maxPoints = 0, options = {}) {
2659
- const validate = options.validate !== false;
2660
- assertSamples("meteringVectorscopeDecimated", left, validate, "left");
2661
- assertSamples("meteringVectorscopeDecimated", right, validate, "right");
2662
- return requireModule9().meteringVectorscopeDecimated(left, right, sampleRate, maxPoints);
2663
- }
2664
- function meteringPhaseScope(left, right, sampleRate = 22050, options = {}) {
2665
- const validate = options.validate !== false;
2666
- assertSamples("meteringPhaseScope", left, validate, "left");
2667
- assertSamples("meteringPhaseScope", right, validate, "right");
2668
- return requireModule9().meteringPhaseScope(left, right, sampleRate);
2669
- }
2670
- function meteringPhaseScopeDecimated(left, right, sampleRate = 22050, maxPoints = 0, options = {}) {
2671
- const validate = options.validate !== false;
2672
- assertSamples("meteringPhaseScopeDecimated", left, validate, "left");
2673
- assertSamples("meteringPhaseScopeDecimated", right, validate, "right");
2674
- return requireModule9().meteringPhaseScopeDecimated(left, right, sampleRate, maxPoints);
2675
- }
2676
- function meteringSpectrum(samples, sampleRate = 22050, options) {
2677
- const validate = options?.validate !== false;
2678
- assertSamples("meteringSpectrum", samples, validate);
2679
- return requireModule9().meteringSpectrum(samples, sampleRate, options ?? {});
2680
- }
2681
- function meteringSpectrumFrame(samples, sampleRate = 22050, frameOffset = 0, options) {
2682
- const validate = options?.validate !== false;
2683
- assertSamples("meteringSpectrumFrame", samples, validate);
2684
- return requireModule9().meteringSpectrumFrame(samples, sampleRate, frameOffset, options ?? {});
2685
- }
2686
- function waveformPeaks(samples, channels, options = {}) {
2687
- assertSamples("waveformPeaks", samples, options.validate !== false);
2688
- if (channels <= 0 || samples.length % channels !== 0) {
2689
- throw new RangeError("waveformPeaks: samples length must be a multiple of channels");
2690
- }
2691
- const samplesPerBucket = options.samplesPerBucket ?? 512;
2692
- if (samplesPerBucket <= 0) {
2693
- throw new RangeError("waveformPeaks: samplesPerBucket must be > 0");
2694
- }
2695
- return requireModule9().waveformPeaks(samples, channels, samplesPerBucket);
2696
- }
2697
- function waveformPeakPyramid(samples, channels, options = {}) {
2698
- assertSamples("waveformPeakPyramid", samples, options.validate !== false);
2699
- if (channels <= 0 || samples.length % channels !== 0) {
2700
- throw new RangeError("waveformPeakPyramid: samples length must be a multiple of channels");
2701
- }
2702
- const levels = options.samplesPerBucketLevels ?? [512, 1024, 2048, 4096];
2703
- if (levels.length === 0 || levels.some((level) => level <= 0)) {
2704
- throw new RangeError("waveformPeakPyramid: samplesPerBucketLevels must be non-empty and > 0");
2705
- }
2706
- return requireModule9().waveformPeakPyramid(samples, channels, levels);
2707
- }
2708
-
2709
2626
  // src/opfs_clip_pages.ts
2710
2627
  var opfsClipPageWorkerSource = `
2711
2628
  const sonareClipPageReadQueues = new Map();
@@ -2899,60 +2816,288 @@ function createOpfsClipPageProvider(engine, options) {
2899
2816
  };
2900
2817
  }
2901
2818
 
2902
- // src/project.ts
2903
- var EXPECTED_PROJECT_ABI_VERSION = 1;
2904
- var MarkerKind = {
2905
- marker: 0,
2906
- text: 1,
2907
- lyric: 2,
2908
- cuePoint: 3,
2909
- keySignature: 4
2910
- };
2911
- var SYNTH_ENGINE_MODES = [
2912
- "default",
2913
- "subtractive",
2914
- "fm",
2915
- "karplus-strong",
2916
- "modal",
2917
- "additive",
2918
- "percussion",
2919
- "piano"
2920
- ];
2921
- var SYNTH_OSC_WAVEFORMS = [
2922
- "default",
2923
- "sine",
2924
- "saw",
2925
- "square",
2926
- "triangle",
2927
- "noise"
2928
- ];
2929
- var SYNTH_FILTER_MODELS = [
2930
- "default",
2931
- "svf",
2932
- "moog-ladder",
2933
- "diode-ladder",
2934
- "sallen-key"
2935
- ];
2936
- var SYNTH_FILTER_OUTPUTS = ["default", "lowpass", "bandpass", "highpass"];
2937
- var SYNTH_BODY_TYPES = ["default", "none", "guitar", "violin", "wood-tube"];
2938
- var SYNTH_MOD_SOURCES = [
2939
- "none",
2940
- "amp-env",
2941
- "filter-env",
2942
- "lfo1",
2943
- "lfo2",
2944
- "velocity",
2945
- "key-track",
2946
- "mod-wheel",
2947
- "random"
2948
- ];
2949
- var SYNTH_MOD_DESTINATIONS = [
2950
- "none",
2951
- "pitch-cents",
2952
- "cutoff-cents",
2953
- "amp-gain",
2954
- "pan-units"
2955
- ];
2819
+ // src/clip_page_streamer.ts
2820
+ var ClipPageStreamer = class {
2821
+ constructor(engine, options = {}) {
2822
+ this.sources = /* @__PURE__ */ new Map();
2823
+ this.closed = false;
2824
+ this.engine = engine;
2825
+ this.readAheadPages = Math.max(0, Math.floor(options.readAheadPages ?? 2));
2826
+ this.retainBehindPages = Math.max(0, Math.floor(options.retainBehindPages ?? 1));
2827
+ this.maxRequestsPerPump = Math.max(1, Math.floor(options.maxRequestsPerPump ?? 256));
2828
+ }
2829
+ /**
2830
+ * Register a paged clip. Pages already supplied to the provider before
2831
+ * registration (for example a primed first page) should be passed in
2832
+ * `initialResidentPages` so they participate in eviction.
2833
+ */
2834
+ addSource(source, initialResidentPages = []) {
2835
+ if (source.pageFrames <= 0 || source.numSamples <= 0) {
2836
+ throw new Error("pageFrames and numSamples must be positive");
2837
+ }
2838
+ const lastPage = Math.ceil(source.numSamples / source.pageFrames) - 1;
2839
+ this.sources.set(source.clipId, {
2840
+ source,
2841
+ lastPage,
2842
+ resident: new Set(initialResidentPages)
2843
+ });
2844
+ }
2845
+ /** Stop tracking a clip. Does not close its binding (the caller owns that). */
2846
+ removeSource(clipId) {
2847
+ this.sources.delete(clipId);
2848
+ }
2849
+ /**
2850
+ * Drain pending page-miss requests, fetch the missing pages plus their
2851
+ * read-ahead window, and evict out-of-window pages. Resolves once this round's
2852
+ * fetches settle. Concurrent fetches are serialized inside each binding.
2853
+ */
2854
+ async pump() {
2855
+ if (this.closed) {
2856
+ return;
2857
+ }
2858
+ const frontiers = /* @__PURE__ */ new Map();
2859
+ for (let drained = 0; drained < this.maxRequestsPerPump; ++drained) {
2860
+ const request = this.engine.popClipPageRequest();
2861
+ if (!request) {
2862
+ break;
2863
+ }
2864
+ const state = this.sources.get(request.clipId);
2865
+ if (!state) {
2866
+ continue;
2867
+ }
2868
+ const page = Math.floor(request.sample / state.source.pageFrames);
2869
+ const previous = frontiers.get(request.clipId);
2870
+ if (previous === void 0 || page > previous) {
2871
+ frontiers.set(request.clipId, page);
2872
+ }
2873
+ }
2874
+ const fetches = [];
2875
+ for (const [clipId, frontier] of frontiers) {
2876
+ const state = this.sources.get(clipId);
2877
+ if (!state) {
2878
+ continue;
2879
+ }
2880
+ fetches.push(...this.serviceFrontier(state, frontier));
2881
+ }
2882
+ await Promise.all(fetches);
2883
+ }
2884
+ /** Close every registered clip's binding and stop tracking. */
2885
+ close() {
2886
+ if (this.closed) {
2887
+ return;
2888
+ }
2889
+ this.closed = true;
2890
+ for (const state of this.sources.values()) {
2891
+ state.source.binding.close();
2892
+ }
2893
+ this.sources.clear();
2894
+ }
2895
+ serviceFrontier(state, frontier) {
2896
+ const low = Math.max(0, frontier - this.retainBehindPages);
2897
+ const high = Math.min(state.lastPage, frontier + this.readAheadPages);
2898
+ for (const page of state.resident) {
2899
+ if (page < low || page > high) {
2900
+ state.source.binding.provider.clear(page);
2901
+ state.resident.delete(page);
2902
+ }
2903
+ }
2904
+ const fetches = [];
2905
+ for (let page = low; page <= high; ++page) {
2906
+ if (state.resident.has(page)) {
2907
+ continue;
2908
+ }
2909
+ state.resident.add(page);
2910
+ const pageIndex = page;
2911
+ fetches.push(
2912
+ state.source.binding.supplyPage(pageIndex).then(
2913
+ (ok) => {
2914
+ if (!ok) {
2915
+ state.resident.delete(pageIndex);
2916
+ }
2917
+ return ok;
2918
+ },
2919
+ (error) => {
2920
+ state.resident.delete(pageIndex);
2921
+ throw error;
2922
+ }
2923
+ )
2924
+ );
2925
+ }
2926
+ return fetches;
2927
+ }
2928
+ };
2929
+ async function attachOpfsClipStream(streamer, engine, options) {
2930
+ const { clipId, primePages = 1, ...providerOptions } = options;
2931
+ const binding = createOpfsClipPageProvider(engine, providerOptions);
2932
+ const lastPage = Math.ceil(providerOptions.numSamples / providerOptions.pageFrames) - 1;
2933
+ const primed = [];
2934
+ for (let page = 0; page < primePages && page <= lastPage; ++page) {
2935
+ if (await binding.supplyPage(page)) {
2936
+ primed.push(page);
2937
+ }
2938
+ }
2939
+ streamer.addSource(
2940
+ {
2941
+ clipId,
2942
+ binding,
2943
+ pageFrames: providerOptions.pageFrames,
2944
+ numSamples: providerOptions.numSamples
2945
+ },
2946
+ primed
2947
+ );
2948
+ return { binding, provider: binding.provider };
2949
+ }
2950
+
2951
+ // src/live_audio.ts
2952
+ async function bindMicrophoneInput(context, engine, options = {}) {
2953
+ const { stream: providedStream, stopTracksOnClose = true, ...constraints } = options;
2954
+ const stream = providedStream ?? await navigator.mediaDevices.getUserMedia({
2955
+ ...constraints,
2956
+ audio: constraints.audio ?? true,
2957
+ video: constraints.video ?? false
2958
+ });
2959
+ const source = context.createMediaStreamSource(stream);
2960
+ const node = "node" in engine ? engine.node : engine;
2961
+ source.connect(node);
2962
+ let closed = false;
2963
+ return {
2964
+ stream,
2965
+ source,
2966
+ close() {
2967
+ if (closed) {
2968
+ return;
2969
+ }
2970
+ closed = true;
2971
+ source.disconnect();
2972
+ if (stopTracksOnClose) {
2973
+ for (const track of stream.getAudioTracks()) {
2974
+ track.stop();
2975
+ }
2976
+ }
2977
+ }
2978
+ };
2979
+ }
2980
+
2981
+ // src/metering.ts
2982
+ function requireModule15() {
2983
+ return getSonareModule();
2984
+ }
2985
+ function meteringPeakDb(samples, sampleRate = 22050, options = {}) {
2986
+ assertSamples("meteringPeakDb", samples, options.validate !== false);
2987
+ return requireModule15().meteringPeakDb(samples, sampleRate);
2988
+ }
2989
+ function meteringRmsDb(samples, sampleRate = 22050, options = {}) {
2990
+ assertSamples("meteringRmsDb", samples, options.validate !== false);
2991
+ return requireModule15().meteringRmsDb(samples, sampleRate);
2992
+ }
2993
+ function meteringCrestFactorDb(samples, sampleRate = 22050, options = {}) {
2994
+ assertSamples("meteringCrestFactorDb", samples, options.validate !== false);
2995
+ return requireModule15().meteringCrestFactorDb(samples, sampleRate);
2996
+ }
2997
+ function meteringDcOffset(samples, sampleRate = 22050, options = {}) {
2998
+ assertSamples("meteringDcOffset", samples, options.validate !== false);
2999
+ return requireModule15().meteringDcOffset(samples, sampleRate);
3000
+ }
3001
+ function meteringTruePeakDb(samples, sampleRate = 22050, oversampleFactor = 4, options = {}) {
3002
+ assertSamples("meteringTruePeakDb", samples, options.validate !== false);
3003
+ const factor = oversampleFactor === 0 ? 4 : oversampleFactor;
3004
+ if (factor < 1 || factor > 16 || (factor & factor - 1) !== 0) {
3005
+ throw new RangeError(
3006
+ "meteringTruePeakDb: oversampleFactor must be 0 or a power of two from 1 to 16"
3007
+ );
3008
+ }
3009
+ return requireModule15().meteringTruePeakDb(samples, sampleRate, oversampleFactor);
3010
+ }
3011
+ function meteringDetectClipping(samples, sampleRate = 22050, options = {}) {
3012
+ assertSamples("meteringDetectClipping", samples, options.validate !== false);
3013
+ return requireModule15().meteringDetectClipping(
3014
+ samples,
3015
+ sampleRate,
3016
+ options.threshold ?? 0.999,
3017
+ options.minRegionSamples ?? 1
3018
+ );
3019
+ }
3020
+ function meteringDynamicRange(samples, sampleRate = 22050, options = {}) {
3021
+ assertSamples("meteringDynamicRange", samples, options.validate !== false);
3022
+ return requireModule15().meteringDynamicRange(
3023
+ samples,
3024
+ sampleRate,
3025
+ options.windowSec ?? 0,
3026
+ options.hopSec ?? 0,
3027
+ options.lowPercentile ?? -1,
3028
+ options.highPercentile ?? -1
3029
+ );
3030
+ }
3031
+ function meteringStereoCorrelation(left, right, sampleRate = 22050, options = {}) {
3032
+ const validate = options.validate !== false;
3033
+ assertSamples("meteringStereoCorrelation", left, validate, "left");
3034
+ assertSamples("meteringStereoCorrelation", right, validate, "right");
3035
+ return requireModule15().meteringStereoCorrelation(left, right, sampleRate);
3036
+ }
3037
+ function meteringStereoWidth(left, right, sampleRate = 22050, options = {}) {
3038
+ const validate = options.validate !== false;
3039
+ assertSamples("meteringStereoWidth", left, validate, "left");
3040
+ assertSamples("meteringStereoWidth", right, validate, "right");
3041
+ return requireModule15().meteringStereoWidth(left, right, sampleRate);
3042
+ }
3043
+ function meteringVectorscope(left, right, sampleRate = 22050, options = {}) {
3044
+ const validate = options.validate !== false;
3045
+ assertSamples("meteringVectorscope", left, validate, "left");
3046
+ assertSamples("meteringVectorscope", right, validate, "right");
3047
+ return requireModule15().meteringVectorscope(left, right, sampleRate);
3048
+ }
3049
+ function meteringVectorscopeDecimated(left, right, sampleRate = 22050, maxPoints = 0, options = {}) {
3050
+ const validate = options.validate !== false;
3051
+ assertSamples("meteringVectorscopeDecimated", left, validate, "left");
3052
+ assertSamples("meteringVectorscopeDecimated", right, validate, "right");
3053
+ return requireModule15().meteringVectorscopeDecimated(left, right, sampleRate, maxPoints);
3054
+ }
3055
+ function meteringPhaseScope(left, right, sampleRate = 22050, options = {}) {
3056
+ const validate = options.validate !== false;
3057
+ assertSamples("meteringPhaseScope", left, validate, "left");
3058
+ assertSamples("meteringPhaseScope", right, validate, "right");
3059
+ return requireModule15().meteringPhaseScope(left, right, sampleRate);
3060
+ }
3061
+ function meteringPhaseScopeDecimated(left, right, sampleRate = 22050, maxPoints = 0, options = {}) {
3062
+ const validate = options.validate !== false;
3063
+ assertSamples("meteringPhaseScopeDecimated", left, validate, "left");
3064
+ assertSamples("meteringPhaseScopeDecimated", right, validate, "right");
3065
+ return requireModule15().meteringPhaseScopeDecimated(left, right, sampleRate, maxPoints);
3066
+ }
3067
+ function meteringSpectrum(samples, sampleRate = 22050, options) {
3068
+ const validate = options?.validate !== false;
3069
+ assertSamples("meteringSpectrum", samples, validate);
3070
+ return requireModule15().meteringSpectrum(samples, sampleRate, options ?? {});
3071
+ }
3072
+ function meteringSpectrumFrame(samples, sampleRate = 22050, frameOffset = 0, options) {
3073
+ const validate = options?.validate !== false;
3074
+ assertSamples("meteringSpectrumFrame", samples, validate);
3075
+ return requireModule15().meteringSpectrumFrame(samples, sampleRate, frameOffset, options ?? {});
3076
+ }
3077
+ function waveformPeaks(samples, channels, options = {}) {
3078
+ assertSamples("waveformPeaks", samples, options.validate !== false);
3079
+ if (channels <= 0 || samples.length % channels !== 0) {
3080
+ throw new RangeError("waveformPeaks: samples length must be a multiple of channels");
3081
+ }
3082
+ const samplesPerBucket = options.samplesPerBucket ?? 512;
3083
+ if (samplesPerBucket <= 0) {
3084
+ throw new RangeError("waveformPeaks: samplesPerBucket must be > 0");
3085
+ }
3086
+ return requireModule15().waveformPeaks(samples, channels, samplesPerBucket);
3087
+ }
3088
+ function waveformPeakPyramid(samples, channels, options = {}) {
3089
+ assertSamples("waveformPeakPyramid", samples, options.validate !== false);
3090
+ if (channels <= 0 || samples.length % channels !== 0) {
3091
+ throw new RangeError("waveformPeakPyramid: samples length must be a multiple of channels");
3092
+ }
3093
+ const levels = options.samplesPerBucketLevels ?? [512, 1024, 2048, 4096];
3094
+ if (levels.length === 0 || levels.some((level) => level <= 0)) {
3095
+ throw new RangeError("waveformPeakPyramid: samplesPerBucketLevels must be non-empty and > 0");
3096
+ }
3097
+ return requireModule15().waveformPeakPyramid(samples, channels, levels);
3098
+ }
3099
+
3100
+ // src/project_internal.ts
2956
3101
  function projectModule() {
2957
3102
  const candidate = getSonareModule();
2958
3103
  if (typeof candidate.projectAbiVersion !== "function" || candidate.Project === void 0) {
@@ -3017,18 +3162,41 @@ function assertProjectMidiEvents(fnName, events) {
3017
3162
  }
3018
3163
  });
3019
3164
  }
3020
- function projectAbiVersion() {
3021
- return projectModule().projectAbiVersion();
3022
- }
3023
- function synthPresetNames() {
3024
- return Array.from(projectModule().synthPresetNames());
3165
+ function projectTrackKindValue(kind) {
3166
+ if (kind === void 0 || kind === "audio") {
3167
+ return 0;
3168
+ }
3169
+ if (kind === "midi") {
3170
+ return 1;
3171
+ }
3172
+ if (kind === "aux") {
3173
+ return 2;
3174
+ }
3175
+ return kind;
3025
3176
  }
3026
- function synthPresetPatch(name) {
3027
- return { ...projectModule().synthPresetPatch(name) };
3177
+ function projectWarpModeValue(mode) {
3178
+ if (mode === void 0 || mode === "off") {
3179
+ return 0;
3180
+ }
3181
+ if (mode === "repitch") {
3182
+ return 1;
3183
+ }
3184
+ if (mode === "tempo-sync") {
3185
+ return 2;
3186
+ }
3187
+ return mode;
3028
3188
  }
3029
- function synthEnumTables() {
3030
- return projectModule()._synthEnumTables();
3189
+ function projectLoopModeValue(mode) {
3190
+ if (mode === void 0 || mode === "off") {
3191
+ return 0;
3192
+ }
3193
+ if (mode === "loop") {
3194
+ return 1;
3195
+ }
3196
+ return mode;
3031
3197
  }
3198
+
3199
+ // src/project_class.ts
3032
3200
  var Project = class _Project {
3033
3201
  constructor() {
3034
3202
  this.native = new (projectModule()).Project();
@@ -3618,40 +3786,92 @@ var Project = class _Project {
3618
3786
  this.delete();
3619
3787
  }
3620
3788
  };
3621
- function projectTrackKindValue(kind) {
3622
- if (kind === void 0 || kind === "audio") {
3623
- return 0;
3624
- }
3625
- if (kind === "midi") {
3626
- return 1;
3627
- }
3628
- if (kind === "aux") {
3629
- return 2;
3630
- }
3631
- return kind;
3789
+
3790
+ // src/project_synth.ts
3791
+ function projectAbiVersion() {
3792
+ return projectModule().projectAbiVersion();
3632
3793
  }
3633
- function projectWarpModeValue(mode) {
3634
- if (mode === void 0 || mode === "off") {
3635
- return 0;
3636
- }
3637
- if (mode === "repitch") {
3638
- return 1;
3639
- }
3640
- if (mode === "tempo-sync") {
3641
- return 2;
3642
- }
3643
- return mode;
3794
+ function synthPresetNames() {
3795
+ return Array.from(projectModule().synthPresetNames());
3644
3796
  }
3645
- function projectLoopModeValue(mode) {
3646
- if (mode === void 0 || mode === "off") {
3647
- return 0;
3648
- }
3649
- if (mode === "loop") {
3650
- return 1;
3651
- }
3652
- return mode;
3797
+ function synthPresetPatch(name) {
3798
+ return { ...projectModule().synthPresetPatch(name) };
3799
+ }
3800
+ function synthEnumTables() {
3801
+ return projectModule()._synthEnumTables();
3653
3802
  }
3654
3803
 
3804
+ // src/project_types.ts
3805
+ var EXPECTED_PROJECT_ABI_VERSION = 1;
3806
+ var MarkerKind = {
3807
+ marker: 0,
3808
+ text: 1,
3809
+ lyric: 2,
3810
+ cuePoint: 3,
3811
+ keySignature: 4
3812
+ };
3813
+ var SYNTH_ENGINE_MODES = [
3814
+ "default",
3815
+ "subtractive",
3816
+ "fm",
3817
+ "karplus-strong",
3818
+ "modal",
3819
+ "additive",
3820
+ "percussion",
3821
+ "piano",
3822
+ "pipe-organ",
3823
+ "bowed-string",
3824
+ "reed",
3825
+ "brass",
3826
+ "flute",
3827
+ "plucked-string",
3828
+ "vocal",
3829
+ "free-reed"
3830
+ ];
3831
+ var SYNTH_OSC_WAVEFORMS = [
3832
+ "default",
3833
+ "sine",
3834
+ "saw",
3835
+ "square",
3836
+ "triangle",
3837
+ "noise"
3838
+ ];
3839
+ var SYNTH_FILTER_MODELS = [
3840
+ "default",
3841
+ "svf",
3842
+ "moog-ladder",
3843
+ "diode-ladder",
3844
+ "sallen-key"
3845
+ ];
3846
+ var SYNTH_FILTER_OUTPUTS = ["default", "lowpass", "bandpass", "highpass"];
3847
+ var SYNTH_BODY_TYPES = [
3848
+ "default",
3849
+ "none",
3850
+ "guitar",
3851
+ "violin",
3852
+ "wood-tube",
3853
+ "brass-bell",
3854
+ "vocal"
3855
+ ];
3856
+ var SYNTH_MOD_SOURCES = [
3857
+ "none",
3858
+ "amp-env",
3859
+ "filter-env",
3860
+ "lfo1",
3861
+ "lfo2",
3862
+ "velocity",
3863
+ "key-track",
3864
+ "mod-wheel",
3865
+ "random"
3866
+ ];
3867
+ var SYNTH_MOD_DESTINATIONS = [
3868
+ "none",
3869
+ "pitch-cents",
3870
+ "cutoff-cents",
3871
+ "amp-gain",
3872
+ "pan-units"
3873
+ ];
3874
+
3655
3875
  // src/realtime_engine.ts
3656
3876
  var EXPECTED_ENGINE_ABI_VERSION = 3;
3657
3877
  function engineCapabilities() {
@@ -3696,6 +3916,14 @@ var RealtimeEngine = class {
3696
3916
  setParameterSmoothed(paramId, value, renderFrame = -1) {
3697
3917
  this.native.setParameterSmoothed(paramId, value, renderFrame);
3698
3918
  }
3919
+ /**
3920
+ * Set the default ramp time (ms) for engine-level smoothed parameters —
3921
+ * fader/pan glides, insert-parameter automation, and MIDI-CC mappings. The
3922
+ * default is 20 ms; pass `0` for instant (un-ramped) changes.
3923
+ */
3924
+ setParamSmoothingMs(smoothingMs) {
3925
+ this.native.setParamSmoothingMs(smoothingMs);
3926
+ }
3699
3927
  setSoloMute(laneIndex, solo, mute, renderFrame = -1) {
3700
3928
  this.native.setSoloMute(laneIndex, solo, mute, renderFrame);
3701
3929
  }
@@ -3781,6 +4009,35 @@ var RealtimeEngine = class {
3781
4009
  midiInputPendingCount() {
3782
4010
  return this.native.midiInputPendingCount();
3783
4011
  }
4012
+ /**
4013
+ * Route a destination's (track lane's) MIDI to the external output queue
4014
+ * instead of the internal instrument rack, so the track plays an external
4015
+ * device. Clearing it restores internal-synth playback.
4016
+ */
4017
+ setMidiDestinationExternal(destinationId, external) {
4018
+ this.native.setMidiDestinationExternal(destinationId, external);
4019
+ }
4020
+ /**
4021
+ * Enable/disable forwarding MIDI clock + transport (start/continue/stop) to
4022
+ * the external output queue so external gear tracks the transport tempo.
4023
+ */
4024
+ setExternalMidiClockEnabled(enabled) {
4025
+ this.native.setExternalMidiClockEnabled(enabled);
4026
+ }
4027
+ /** Count of external-MIDI events dropped because the output queue was full. */
4028
+ externalMidiDroppedCount() {
4029
+ return this.native.externalMidiDroppedCount();
4030
+ }
4031
+ /**
4032
+ * Drain queued external-MIDI events, already lowered to MIDI 1.0 byte
4033
+ * messages ready to write to a Web MIDI output port. Call once per audio
4034
+ * block / animation frame. `maxRecords` caps the number of output events
4035
+ * returned — the shared unit across every surface. Events past the cap stay
4036
+ * queued for the next call (lossless); call again to drain the rest.
4037
+ */
4038
+ drainExternalMidi(maxRecords = 1024) {
4039
+ return this.native.drainExternalMidi(maxRecords);
4040
+ }
3784
4041
  pushMidiInputNoteOn(group, channel, note, velocity, portTimeSamples = 0) {
3785
4042
  this.native.pushMidiInputNoteOn(group, channel, note, velocity, portTimeSamples);
3786
4043
  }
@@ -3805,6 +4062,15 @@ var RealtimeEngine = class {
3805
4062
  pushMidiCc(destinationId, group, channel, controller, value, renderFrame = -1) {
3806
4063
  this.native.pushMidiCc(destinationId, group, channel, controller, value, renderFrame);
3807
4064
  }
4065
+ /**
4066
+ * Queue an immediate (live) MIDI SysEx frame to a MIDI destination. `data` is
4067
+ * the full message including the leading 0xF0 and trailing 0xF7 (1..512
4068
+ * bytes). `renderFrame` is the frame to fire at, or -1 for immediate. Mirrors
4069
+ * the Node/Python/C-ABI `pushMidiSysex`.
4070
+ */
4071
+ pushMidiSysex(destinationId, data, renderFrame = -1) {
4072
+ this.native.pushMidiSysex(destinationId, data, renderFrame);
4073
+ }
3808
4074
  /**
3809
4075
  * Queue a MIDI panic (all-notes-off) releasing every sounding note at
3810
4076
  * `renderFrame` (-1 = immediate). Mirrors the C-ABI `pushMidiPanic`.
@@ -4023,6 +4289,30 @@ var RealtimeEngine = class {
4023
4289
  setMasterStripInsertParamByName(insertIndex, paramName, value) {
4024
4290
  this.native.setMasterStripInsertParamByName(insertIndex, paramName, value);
4025
4291
  }
4292
+ /** Bus-strip counterpart of {@link setTrackStripInsertParamByName}. */
4293
+ setBusStripInsertParamByName(busId, insertIndex, paramName, value) {
4294
+ this.native.setBusStripInsertParamByName(busId, insertIndex, paramName, value);
4295
+ }
4296
+ /** Bus-strip counterpart of {@link setTrackStripInsertBypassed}. */
4297
+ setBusStripInsertBypassed(busId, insertIndex, bypassed, resetOnBypass = false) {
4298
+ this.native.setBusStripInsertBypassed(busId, insertIndex, bypassed, resetOnBypass);
4299
+ }
4300
+ /**
4301
+ * Resolves a track-lane insert parameter (by its JSON-key name) to the
4302
+ * reserved automation id usable with `setAutomationLane` / `setParameter`.
4303
+ * Returns `-1` when the track, insert, or name is unknown. (The Python binding
4304
+ * raises a `SonareError` for an unknown id where Node/WASM return the `-1`
4305
+ * sentinel.)
4306
+ */
4307
+ resolveTrackInsertAutomationId(trackId, insertIndex, paramName) {
4308
+ return this.native.resolveTrackInsertAutomationId(trackId, insertIndex, paramName);
4309
+ }
4310
+ resolveMasterInsertAutomationId(insertIndex, paramName) {
4311
+ return this.native.resolveMasterInsertAutomationId(insertIndex, paramName);
4312
+ }
4313
+ resolveBusInsertAutomationId(busId, insertIndex, paramName) {
4314
+ return this.native.resolveBusInsertAutomationId(busId, insertIndex, paramName);
4315
+ }
4026
4316
  /** Sets a track lane strip's pan position in realtime (glitch-free). */
4027
4317
  setTrackStripPan(trackId, pan) {
4028
4318
  this.native.setTrackStripPan(trackId, pan);
@@ -4727,6 +5017,7 @@ function realtimeVoiceChangerPresetConfig(preset) {
4727
5017
  export {
4728
5018
  Audio,
4729
5019
  ChordQuality,
5020
+ ClipPageStreamer,
4730
5021
  EXPECTED_ENGINE_ABI_VERSION,
4731
5022
  EXPECTED_PROJECT_ABI_VERSION,
4732
5023
  ErrorCode,
@@ -4762,12 +5053,14 @@ export {
4762
5053
  analyzeSections,
4763
5054
  analyzeTimbre,
4764
5055
  analyzeWithProgress,
5056
+ attachOpfsClipStream,
4765
5057
  bassChroma,
4766
5058
  bindMicrophoneInput,
4767
5059
  bindWebMidi,
4768
5060
  chordFunctionalAnalysis,
4769
5061
  chroma,
4770
5062
  chromaCens,
5063
+ chromaCqt,
4771
5064
  cqt,
4772
5065
  createOpfsClipPageProvider,
4773
5066
  createOpfsClipPageWorker,
@@ -4886,6 +5179,7 @@ export {
4886
5179
  peakPick,
4887
5180
  percussive,
4888
5181
  phaseVocoder,
5182
+ pitchCorrectTimevarying,
4889
5183
  pitchCorrectToMidi,
4890
5184
  pitchCorrectToMidiTimevarying,
4891
5185
  pitchPyin,