@libraz/libsonare 1.4.1 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +51 -20
  2. package/dist/index.d.ts +5416 -1
  3. package/dist/index.js +938 -583
  4. package/dist/index.js.map +1 -1
  5. package/dist/sonare.js +2 -2
  6. package/dist/sonare.wasm +0 -0
  7. package/dist/worklet.d.ts +1083 -5227
  8. package/dist/worklet.js +2683 -2451
  9. package/dist/worklet.js.map +1 -1
  10. package/package.json +4 -9
  11. package/src/clip_page_streamer.ts +298 -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_music.ts +5 -2
  16. package/src/feature_spectrogram.ts +42 -2
  17. package/src/features.ts +1 -0
  18. package/src/index.ts +23 -0
  19. package/src/mastering_chain.ts +200 -0
  20. package/src/mastering_core.ts +248 -0
  21. package/src/mastering_dynamics.ts +105 -0
  22. package/src/mastering_repair.ts +161 -0
  23. package/src/mixer.ts +8 -0
  24. package/src/mixing_oneshot.ts +54 -0
  25. package/src/module_state.ts +1 -2
  26. package/src/project.ts +71 -1712
  27. package/src/project_class.ts +871 -0
  28. package/src/project_internal.ts +333 -0
  29. package/src/project_synth.ts +43 -0
  30. package/src/project_types.ts +570 -0
  31. package/src/public_types.ts +6 -1221
  32. package/src/public_types_acoustic.ts +115 -0
  33. package/src/public_types_mastering.ts +333 -0
  34. package/src/public_types_mixing.ts +97 -0
  35. package/src/public_types_music.ts +352 -0
  36. package/src/public_types_realtime.ts +163 -0
  37. package/src/public_types_spectral.ts +194 -0
  38. package/src/realtime_engine.ts +94 -0
  39. package/src/sonare.js.d.ts +117 -38
  40. package/src/stream_analyzer.ts +3 -0
  41. package/src/stream_types.ts +4 -0
  42. package/src/worklet/engine-automation.ts +73 -0
  43. package/src/worklet/engine-capture-facade.ts +80 -0
  44. package/src/worklet/engine-clips.ts +71 -0
  45. package/src/worklet/engine-markers.ts +93 -0
  46. package/src/worklet/engine-mixer-facade.ts +186 -0
  47. package/src/worklet/engine-node.ts +451 -0
  48. package/src/worklet/engine-offline.ts +162 -0
  49. package/src/worklet/engine-options.ts +13 -0
  50. package/src/worklet/engine-parameter-facade.ts +172 -0
  51. package/src/worklet/engine-processor.ts +764 -0
  52. package/src/worklet/engine-register.ts +136 -0
  53. package/src/worklet/engine-strips.ts +315 -0
  54. package/src/worklet/engine-sync.ts +94 -0
  55. package/src/worklet/engine-tempo-facade.ts +141 -0
  56. package/src/worklet/engine.ts +998 -0
  57. package/src/worklet/guards.ts +14 -1
  58. package/src/worklet/messages.ts +60 -20
  59. package/src/worklet/mixer-processor.ts +368 -0
  60. package/src/worklet/protocol.ts +3 -0
  61. package/src/worklet/voice-changer-processor.ts +246 -0
  62. package/src/worklet.ts +20 -3549
  63. package/dist/sonare-rt-module.js +0 -2
  64. package/dist/sonare-rt.js +0 -2
  65. package/dist/sonare-rt.wasm +0 -0
  66. 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) {
@@ -603,6 +738,13 @@ var Mixer = class _Mixer {
603
738
  tailSamples() {
604
739
  return this.mixer.tailSamples();
605
740
  }
741
+ /**
742
+ * Reported latency (samples) of the compiled mixer graph, for aligning
743
+ * dry/wet material. Lazily compiles the routing graph if the topology is dirty.
744
+ */
745
+ latencySamples() {
746
+ return this.mixer.latencySamples();
747
+ }
606
748
  /**
607
749
  * Drain delayed / tail audio by processing a zero-input block of `numSamples`
608
750
  * frames after the host stops feeding strip inputs. Returns the mixed stereo
@@ -1016,114 +1158,13 @@ var StreamingRetune = class {
1016
1158
  }
1017
1159
  };
1018
1160
 
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() {
1161
+ // src/effects_voice_change.ts
1162
+ function requireModule2() {
1070
1163
  return getSonareModule();
1071
1164
  }
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
1165
  function voiceChange(samples, sampleRate = 22050, options = {}) {
1125
1166
  assertSamples("voiceChange", samples, options.validate !== false);
1126
- return requireModule().voiceChange(
1167
+ return requireModule2().voiceChange(
1127
1168
  samples,
1128
1169
  sampleRate,
1129
1170
  options.pitchSemitones ?? 0,
@@ -1156,7 +1197,7 @@ function latencyCompensatedVoiceChange(changer, samples, channels, blockFrames)
1156
1197
  const start = latencyFrames * 2;
1157
1198
  return processed.slice(start, start + samples.length);
1158
1199
  }
1159
- function voiceChangeRealtime(samples, options = {}) {
1200
+ function voiceChangeRealtime(samples, sampleRate = 48e3, preset = "neutral-monitor", options = {}) {
1160
1201
  assertSamples("voiceChangeRealtime", samples, options.validate !== false);
1161
1202
  const channels = options.channels ?? 1;
1162
1203
  if (channels !== 1 && channels !== 2) {
@@ -1165,9 +1206,8 @@ function voiceChangeRealtime(samples, options = {}) {
1165
1206
  if (channels === 2 && samples.length % 2 !== 0) {
1166
1207
  throw new Error("voiceChangeRealtime: stereo input length must be a multiple of 2.");
1167
1208
  }
1168
- const sampleRate = options.sampleRate ?? 48e3;
1169
1209
  const blockSize = Math.max(1, Math.floor(options.blockSize ?? 512));
1170
- const changer = new RealtimeVoiceChanger(options.preset ?? "neutral-monitor");
1210
+ const changer = new RealtimeVoiceChanger(preset);
1171
1211
  try {
1172
1212
  changer.prepare(sampleRate, blockSize, channels);
1173
1213
  return latencyCompensatedVoiceChange(changer, samples, channels, blockSize);
@@ -1175,102 +1215,155 @@ function voiceChangeRealtime(samples, options = {}) {
1175
1215
  changer.delete();
1176
1216
  }
1177
1217
  }
1178
- function normalize(samples, sampleRate, targetDb = 0, options = {}) {
1179
- assertSamples("normalize", samples, options.validate !== false);
1180
- return requireModule().normalize(samples, sampleRate, targetDb);
1218
+
1219
+ // src/mastering_chain.ts
1220
+ function requireModule3() {
1221
+ return getSonareModule();
1181
1222
  }
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);
1223
+ function masteringChain(samples, sampleRate = 22050, config) {
1224
+ return requireModule3().masteringChain(samples, sampleRate, config);
1186
1225
  }
1187
- function mastering(samples, sampleRate = 22050, options = {}) {
1188
- return requireModule().mastering(
1189
- samples,
1226
+ function masteringChainStereo(left, right, sampleRate = 22050, config) {
1227
+ if (left.length !== right.length) {
1228
+ throw new Error("Stereo channel lengths must match.");
1229
+ }
1230
+ return requireModule3().masteringChainStereo(
1231
+ left,
1232
+ right,
1190
1233
  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
1234
+ config
1235
+ );
1236
+ }
1237
+ function masteringChainWithProgress(samples, sampleRate = 22050, config, onProgress) {
1238
+ return requireModule3().masteringChainWithProgress(
1239
+ samples,
1240
+ sampleRate,
1241
+ config,
1242
+ onProgress
1243
+ );
1244
+ }
1245
+ function masteringChainStereoWithProgress(left, right, sampleRate = 22050, config, onProgress) {
1246
+ if (left.length !== right.length) {
1247
+ throw new Error("Stereo channel lengths must match.");
1248
+ }
1249
+ return requireModule3().masteringChainStereoWithProgress(
1250
+ left,
1251
+ right,
1252
+ sampleRate,
1253
+ config,
1254
+ onProgress
1255
+ );
1256
+ }
1257
+ function masteringPresetNames() {
1258
+ return Array.from(requireModule3().masteringPresetNames());
1259
+ }
1260
+ function masterAudio(samples, sampleRate = 22050, presetName = "pop", overrides = {}) {
1261
+ return requireModule3().masterAudio(presetName, samples, sampleRate, overrides);
1262
+ }
1263
+ function masterAudioStereo(left, right, sampleRate = 22050, presetName = "pop", overrides = {}) {
1264
+ if (left.length !== right.length) {
1265
+ throw new Error("Stereo channel lengths must match.");
1266
+ }
1267
+ return requireModule3().masterAudioStereo(presetName, left, right, sampleRate, overrides);
1268
+ }
1269
+ function masterAudioWithProgress(samples, sampleRate = 22050, presetName, onProgress, overrides = null) {
1270
+ return requireModule3().masterAudioWithProgress(
1271
+ presetName,
1272
+ samples,
1273
+ sampleRate,
1274
+ overrides,
1275
+ onProgress
1276
+ );
1277
+ }
1278
+ function masterAudioStereoWithProgress(left, right, sampleRate = 22050, presetName, onProgress, overrides = null) {
1279
+ if (left.length !== right.length) {
1280
+ throw new Error("Stereo channel lengths must match.");
1281
+ }
1282
+ return requireModule3().masterAudioStereoWithProgress(
1283
+ presetName,
1284
+ left,
1285
+ right,
1286
+ sampleRate,
1287
+ overrides,
1288
+ onProgress
1289
+ );
1290
+ }
1291
+
1292
+ // src/mastering_core.ts
1293
+ function requireModule4() {
1294
+ return getSonareModule();
1295
+ }
1296
+ function mastering(samples, sampleRate = 22050, options = {}) {
1297
+ return requireModule4().mastering(
1298
+ samples,
1299
+ sampleRate,
1300
+ options.targetLufs ?? -14,
1301
+ options.ceilingDb ?? -1,
1302
+ options.truePeakOversample ?? 4,
1303
+ options.releaseMs ?? 0,
1304
+ // 0 => library default (50 ms)
1305
+ options.applyGainAtInputRate ?? false
1197
1306
  );
1198
1307
  }
1199
1308
  function masteringProcessorNames() {
1200
- return Array.from(requireModule().masteringProcessorNames());
1309
+ return Array.from(requireModule4().masteringProcessorNames());
1201
1310
  }
1202
1311
  function masteringInsertNames() {
1203
- return requireModule().masteringInsertNames();
1312
+ return requireModule4().masteringInsertNames();
1204
1313
  }
1205
1314
  function masteringInsertParamNames(name) {
1206
1315
  return Array.from(
1207
- requireModule().masteringInsertParamNames(name)
1316
+ requireModule4().masteringInsertParamNames(name)
1208
1317
  );
1209
1318
  }
1210
1319
  function masteringInsertParamInfo(name) {
1211
- const json = requireModule().masteringInsertParamInfo(name);
1320
+ const json = requireModule4().masteringInsertParamInfo(name);
1212
1321
  return JSON.parse(json);
1213
1322
  }
1214
1323
  function masteringProcessorCatalog() {
1215
- const json = requireModule().masteringProcessorCatalog();
1324
+ const json = requireModule4().masteringProcessorCatalog();
1216
1325
  return JSON.parse(json);
1217
1326
  }
1218
1327
  function masteringPairProcessorNames() {
1219
- return Array.from(requireModule().masteringPairProcessorNames());
1328
+ return Array.from(requireModule4().masteringPairProcessorNames());
1220
1329
  }
1221
1330
  function masteringPairAnalysisNames() {
1222
- return Array.from(requireModule().masteringPairAnalysisNames());
1331
+ return Array.from(requireModule4().masteringPairAnalysisNames());
1223
1332
  }
1224
1333
  function masteringStereoAnalysisNames() {
1225
- return Array.from(requireModule().masteringStereoAnalysisNames());
1334
+ return Array.from(requireModule4().masteringStereoAnalysisNames());
1226
1335
  }
1227
1336
  function masteringProcess(processorName, samples, sampleRate = 22050, params = {}) {
1228
- return requireModule().masteringProcess(processorName, samples, sampleRate, params);
1337
+ return requireModule4().masteringProcess(processorName, samples, sampleRate, params);
1229
1338
  }
1230
1339
  function masteringProcessStereo(processorName, left, right, sampleRate = 22050, params = {}) {
1231
1340
  if (left.length !== right.length) {
1232
1341
  throw new Error("Stereo channel lengths must match.");
1233
1342
  }
1234
- return requireModule().masteringProcessStereo(processorName, left, right, sampleRate, params);
1343
+ return requireModule4().masteringProcessStereo(processorName, left, right, sampleRate, params);
1235
1344
  }
1236
1345
  function masteringPairProcess(processorName, source, reference, sampleRate = 22050, params = {}) {
1237
- return requireModule().masteringPairProcess(processorName, source, reference, sampleRate, params);
1346
+ return requireModule4().masteringPairProcess(processorName, source, reference, sampleRate, params);
1238
1347
  }
1239
1348
  function masteringPairAnalyze(analysisName, source, reference, sampleRate = 22050, params = {}) {
1240
- return requireModule().masteringPairAnalyze(analysisName, source, reference, sampleRate, params);
1349
+ return requireModule4().masteringPairAnalyze(analysisName, source, reference, sampleRate, params);
1241
1350
  }
1242
1351
  function masteringStereoAnalyze(analysisName, left, right, sampleRate = 22050, params = {}) {
1243
- return requireModule().masteringStereoAnalyze(analysisName, left, right, sampleRate, params);
1352
+ return requireModule4().masteringStereoAnalyze(analysisName, left, right, sampleRate, params);
1244
1353
  }
1245
1354
  function masteringAssistantSuggest(samples, sampleRate = 22050, params = {}) {
1246
- return requireModule().masteringAssistantSuggest(samples, sampleRate, params);
1355
+ return requireModule4().masteringAssistantSuggest(samples, sampleRate, params);
1247
1356
  }
1248
1357
  function masteringAudioProfile(samples, sampleRate = 22050, params = {}) {
1249
- return requireModule().masteringAudioProfile(samples, sampleRate, params);
1358
+ return requireModule4().masteringAudioProfile(samples, sampleRate, params);
1250
1359
  }
1251
1360
  function masteringStreamingPreview(samples, sampleRate = 22050, platforms = []) {
1252
- return requireModule().masteringStreamingPreview(samples, sampleRate, platforms);
1253
- }
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);
1361
+ return requireModule4().masteringStreamingPreview(samples, sampleRate, platforms);
1262
1362
  }
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);
1363
+
1364
+ // src/mastering_dynamics.ts
1365
+ function requireModule5() {
1366
+ return getSonareModule();
1274
1367
  }
1275
1368
  var COMPRESSOR_DETECTOR_MAP = {
1276
1369
  peak: 0,
@@ -1284,95 +1377,58 @@ function masteringDynamicsCompressor(samples, sampleRate, options = {}) {
1284
1377
  if (detector !== void 0) {
1285
1378
  opts.detector = detector;
1286
1379
  }
1287
- return requireModule().masteringDynamicsCompressor(samples, sampleRate, opts);
1380
+ return requireModule5().masteringDynamicsCompressor(samples, sampleRate, opts);
1288
1381
  }
1289
1382
  function masteringDynamicsGate(samples, sampleRate, options = {}) {
1290
1383
  assertSamples("masteringDynamicsGate", samples, options.validate !== false);
1291
- return requireModule().masteringDynamicsGate(samples, sampleRate, options);
1384
+ return requireModule5().masteringDynamicsGate(samples, sampleRate, options);
1292
1385
  }
1293
1386
  function masteringDynamicsTransientShaper(samples, sampleRate, options = {}) {
1294
1387
  assertSamples("masteringDynamicsTransientShaper", samples, options.validate !== false);
1295
- return requireModule().masteringDynamicsTransientShaper(samples, sampleRate, options);
1388
+ return requireModule5().masteringDynamicsTransientShaper(samples, sampleRate, options);
1296
1389
  }
1297
- function masteringChain(samples, sampleRate = 22050, config) {
1298
- return requireModule().masteringChain(samples, sampleRate, config);
1390
+
1391
+ // src/mastering_repair.ts
1392
+ function requireModule6() {
1393
+ return getSonareModule();
1299
1394
  }
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
- );
1395
+ function masteringRepairDeclick(samples, sampleRate, options = {}) {
1396
+ return requireModule6().masteringRepairDeclick(samples, sampleRate, options);
1310
1397
  }
1311
- function masteringChainWithProgress(samples, sampleRate = 22050, config, onProgress) {
1312
- return requireModule().masteringChainWithProgress(
1313
- samples,
1314
- sampleRate,
1315
- config,
1316
- onProgress
1317
- );
1398
+ function masteringRepairDenoiseClassical(samples, sampleRate, options = {}) {
1399
+ return requireModule6().masteringRepairDenoiseClassical(samples, sampleRate, options);
1318
1400
  }
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
- );
1401
+ function masteringRepairDeclip(samples, sampleRate, options = {}) {
1402
+ return requireModule6().masteringRepairDeclip(samples, sampleRate, options);
1330
1403
  }
1331
- function masteringPresetNames() {
1332
- return Array.from(requireModule().masteringPresetNames());
1404
+ function masteringRepairDecrackle(samples, sampleRate, options = {}) {
1405
+ return requireModule6().masteringRepairDecrackle(samples, sampleRate, options);
1333
1406
  }
1334
- function masterAudio(samples, sampleRate = 22050, presetName = "pop", overrides = {}) {
1335
- return requireModule().masterAudio(presetName, samples, sampleRate, overrides);
1407
+ function masteringRepairDehum(samples, sampleRate, options = {}) {
1408
+ return requireModule6().masteringRepairDehum(samples, sampleRate, options);
1336
1409
  }
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);
1410
+ function masteringRepairDereverbClassical(samples, sampleRate, options = {}) {
1411
+ return requireModule6().masteringRepairDereverbClassical(samples, sampleRate, options);
1342
1412
  }
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
- );
1413
+ function masteringRepairTrimSilence(samples, sampleRate, options = {}) {
1414
+ return requireModule6().masteringRepairTrimSilence(samples, sampleRate, options);
1351
1415
  }
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
- );
1416
+
1417
+ // src/mixing_oneshot.ts
1418
+ function requireModule7() {
1419
+ return getSonareModule();
1364
1420
  }
1365
1421
  function mixingScenePresetNames() {
1366
- return Array.from(requireModule().mixingScenePresetNames());
1422
+ return Array.from(requireModule7().mixingScenePresetNames());
1367
1423
  }
1368
1424
  function mixingScenePresetJson(presetName) {
1369
- return requireModule().mixingScenePresetJson(presetName);
1425
+ return requireModule7().mixingScenePresetJson(presetName);
1370
1426
  }
1371
1427
  function mixStereo(leftChannels, rightChannels, sampleRate = 48e3, options = {}) {
1372
1428
  if (leftChannels.length === 0 || leftChannels.length !== rightChannels.length) {
1373
1429
  throw new Error("leftChannels and rightChannels must have the same non-zero length.");
1374
1430
  }
1375
- return requireModule().mixStereo(
1431
+ return requireModule7().mixStereo(
1376
1432
  leftChannels,
1377
1433
  rightChannels,
1378
1434
  sampleRate,
@@ -1381,92 +1437,92 @@ function mixStereo(leftChannels, rightChannels, sampleRate = 48e3, options = {})
1381
1437
  }
1382
1438
 
1383
1439
  // src/feature_core.ts
1384
- function requireModule2() {
1440
+ function requireModule8() {
1385
1441
  return getSonareModule();
1386
1442
  }
1387
1443
  function hzToMel(hz) {
1388
- return requireModule2().hzToMel(hz);
1444
+ return requireModule8().hzToMel(hz);
1389
1445
  }
1390
1446
  function melToHz(mel) {
1391
- return requireModule2().melToHz(mel);
1447
+ return requireModule8().melToHz(mel);
1392
1448
  }
1393
1449
  function hzToMidi(hz) {
1394
- return requireModule2().hzToMidi(hz);
1450
+ return requireModule8().hzToMidi(hz);
1395
1451
  }
1396
1452
  function midiToHz(midi) {
1397
- return requireModule2().midiToHz(midi);
1453
+ return requireModule8().midiToHz(midi);
1398
1454
  }
1399
1455
  function hzToNote(hz) {
1400
- return requireModule2().hzToNote(hz);
1456
+ return requireModule8().hzToNote(hz);
1401
1457
  }
1402
1458
  function noteToHz(note) {
1403
- return requireModule2().noteToHz(note);
1459
+ return requireModule8().noteToHz(note);
1404
1460
  }
1405
1461
  function framesToTime(frames, sr = 22050, hopLength = 512) {
1406
- return requireModule2().framesToTime(frames, sr, hopLength);
1462
+ return requireModule8().framesToTime(frames, sr, hopLength);
1407
1463
  }
1408
1464
  function timeToFrames(time, sr = 22050, hopLength = 512) {
1409
- return requireModule2().timeToFrames(time, sr, hopLength);
1465
+ return requireModule8().timeToFrames(time, sr, hopLength);
1410
1466
  }
1411
1467
  function framesToSamples(frames, hopLength = 512, nFft = 0) {
1412
- return requireModule2().framesToSamples(frames, hopLength, nFft);
1468
+ return requireModule8().framesToSamples(frames, hopLength, nFft);
1413
1469
  }
1414
1470
  function samplesToFrames(samples, hopLength = 512, nFft = 0) {
1415
- return requireModule2().samplesToFrames(samples, hopLength, nFft);
1471
+ return requireModule8().samplesToFrames(samples, hopLength, nFft);
1416
1472
  }
1417
1473
  function powerToDb(values, ref = 1, amin = 1e-10, topDb = 80) {
1418
- return requireModule2().powerToDb(values, ref, amin, topDb);
1474
+ return requireModule8().powerToDb(values, ref, amin, topDb);
1419
1475
  }
1420
1476
  function amplitudeToDb(values, ref = 1, amin = 1e-5, topDb = 80) {
1421
- return requireModule2().amplitudeToDb(values, ref, amin, topDb);
1477
+ return requireModule8().amplitudeToDb(values, ref, amin, topDb);
1422
1478
  }
1423
1479
  function dbToPower(values, ref = 1) {
1424
- return requireModule2().dbToPower(values, ref);
1480
+ return requireModule8().dbToPower(values, ref);
1425
1481
  }
1426
1482
  function dbToAmplitude(values, ref = 1) {
1427
- return requireModule2().dbToAmplitude(values, ref);
1483
+ return requireModule8().dbToAmplitude(values, ref);
1428
1484
  }
1429
1485
  function preemphasis(samples, coef = 0.97, zi) {
1430
- return requireModule2().preemphasis(samples, coef, zi ?? null);
1486
+ return requireModule8().preemphasis(samples, coef, zi ?? null);
1431
1487
  }
1432
1488
  function deemphasis(samples, coef = 0.97, zi) {
1433
- return requireModule2().deemphasis(samples, coef, zi ?? null);
1489
+ return requireModule8().deemphasis(samples, coef, zi ?? null);
1434
1490
  }
1435
1491
  function trimSilence(samples, topDb = 60, frameLength = 2048, hopLength = 512) {
1436
- return requireModule2().trimSilence(samples, topDb, frameLength, hopLength);
1492
+ return requireModule8().trimSilence(samples, topDb, frameLength, hopLength);
1437
1493
  }
1438
1494
  function splitSilence(samples, topDb = 60, frameLength = 2048, hopLength = 512) {
1439
- return requireModule2().splitSilence(samples, topDb, frameLength, hopLength);
1495
+ return requireModule8().splitSilence(samples, topDb, frameLength, hopLength);
1440
1496
  }
1441
1497
  function frameSignal(samples, frameLength, hopLength) {
1442
- return requireModule2().frameSignal(samples, frameLength, hopLength);
1498
+ return requireModule8().frameSignal(samples, frameLength, hopLength);
1443
1499
  }
1444
1500
  function padCenter(values, targetSize, padValue = 0) {
1445
- return requireModule2().padCenter(values, targetSize, padValue);
1501
+ return requireModule8().padCenter(values, targetSize, padValue);
1446
1502
  }
1447
1503
  function fixLength(values, targetSize, padValue = 0) {
1448
- return requireModule2().fixLength(values, targetSize, padValue);
1504
+ return requireModule8().fixLength(values, targetSize, padValue);
1449
1505
  }
1450
1506
  function fixFrames(frames, xMin = 0, xMax = -1, pad = true) {
1451
- return requireModule2().fixFrames(frames, xMin, xMax, pad);
1507
+ return requireModule8().fixFrames(frames, xMin, xMax, pad);
1452
1508
  }
1453
1509
  function peakPick(values, preMax, postMax, preAvg, postAvg, delta, wait) {
1454
- return requireModule2().peakPick(values, preMax, postMax, preAvg, postAvg, delta, wait);
1510
+ return requireModule8().peakPick(values, preMax, postMax, preAvg, postAvg, delta, wait);
1455
1511
  }
1456
1512
  function vectorNormalize(values, normType = 0, threshold = 0) {
1457
- return requireModule2().vectorNormalize(values, normType, threshold);
1513
+ return requireModule8().vectorNormalize(values, normType, threshold);
1458
1514
  }
1459
1515
  function pcen(values, nBins, nFrames, options = {}) {
1460
- return requireModule2().pcen(values, nBins, nFrames, options);
1516
+ return requireModule8().pcen(values, nBins, nFrames, options);
1461
1517
  }
1462
1518
  function tonnetz(chromagram, nChroma, nFrames) {
1463
- return requireModule2().tonnetz(chromagram, nChroma, nFrames);
1519
+ return requireModule8().tonnetz(chromagram, nChroma, nFrames);
1464
1520
  }
1465
1521
  function tempogram(onsetEnvelope2, sampleRate = 22050, hopLength = 512, winLength = 384, mode = "autocorrelation") {
1466
- return requireModule2().tempogram(onsetEnvelope2, sampleRate, hopLength, winLength, mode);
1522
+ return requireModule8().tempogram(onsetEnvelope2, sampleRate, hopLength, winLength, mode);
1467
1523
  }
1468
1524
  function cyclicTempogram(onsetEnvelope2, sampleRate = 22050, hopLength = 512, winLength = 384, bpmMin = 60, nBins = 60) {
1469
- return requireModule2().cyclicTempogram(
1525
+ return requireModule8().cyclicTempogram(
1470
1526
  onsetEnvelope2,
1471
1527
  sampleRate,
1472
1528
  hopLength,
@@ -1476,11 +1532,11 @@ function cyclicTempogram(onsetEnvelope2, sampleRate = 22050, hopLength = 512, wi
1476
1532
  );
1477
1533
  }
1478
1534
  function plp(onsetEnvelope2, sampleRate = 22050, hopLength = 512, tempoMin = 30, tempoMax = 300, winLength = 384) {
1479
- return requireModule2().plp(onsetEnvelope2, sampleRate, hopLength, tempoMin, tempoMax, winLength);
1535
+ return requireModule8().plp(onsetEnvelope2, sampleRate, hopLength, tempoMin, tempoMax, winLength);
1480
1536
  }
1481
1537
 
1482
1538
  // src/feature_music.ts
1483
- function requireModule3() {
1539
+ function requireModule9() {
1484
1540
  return getSonareModule();
1485
1541
  }
1486
1542
  function validateMusicSamples(fnName, samples, sampleRate, options = {}) {
@@ -1506,25 +1562,25 @@ function validateFrequencyBounds(fnName, fmin, fmax) {
1506
1562
  }
1507
1563
  function nnlsChroma(samples, sampleRate = 22050, options = {}) {
1508
1564
  validateMusicSamples("nnlsChroma", samples, sampleRate, options);
1509
- return requireModule3().nnlsChroma(samples, sampleRate);
1565
+ return requireModule9().nnlsChroma(samples, sampleRate);
1510
1566
  }
1511
1567
  function cqt(samples, sampleRate = 22050, hopLength = 512, fmin = 32.70319566257483, nBins = 84, binsPerOctave = 12, options = {}) {
1512
1568
  validateMusicSamples("cqt", samples, sampleRate, options);
1513
1569
  validatePositiveIntegers("cqt", { hopLength, nBins, binsPerOctave });
1514
1570
  validateFrequencyBounds("cqt", fmin);
1515
- return requireModule3().cqt(samples, sampleRate, hopLength, fmin, nBins, binsPerOctave);
1571
+ return requireModule9().cqt(samples, sampleRate, hopLength, fmin, nBins, binsPerOctave);
1516
1572
  }
1517
1573
  function pseudoCqt(samples, sampleRate = 22050, hopLength = 512, fmin = 32.70319566257483, nBins = 84, binsPerOctave = 12, options = {}) {
1518
1574
  validateMusicSamples("pseudoCqt", samples, sampleRate, options);
1519
1575
  validatePositiveIntegers("pseudoCqt", { hopLength, nBins, binsPerOctave });
1520
1576
  validateFrequencyBounds("pseudoCqt", fmin);
1521
- return requireModule3().pseudoCqt(samples, sampleRate, hopLength, fmin, nBins, binsPerOctave);
1577
+ return requireModule9().pseudoCqt(samples, sampleRate, hopLength, fmin, nBins, binsPerOctave);
1522
1578
  }
1523
1579
  function hybridCqt(samples, sampleRate = 22050, hopLength = 512, fmin = 32.70319566257483, nBins = 84, binsPerOctave = 12, options = {}) {
1524
1580
  validateMusicSamples("hybridCqt", samples, sampleRate, options);
1525
1581
  validatePositiveIntegers("hybridCqt", { hopLength, nBins, binsPerOctave });
1526
1582
  validateFrequencyBounds("hybridCqt", fmin);
1527
- return requireModule3().hybridCqt(samples, sampleRate, hopLength, fmin, nBins, binsPerOctave);
1583
+ return requireModule9().hybridCqt(samples, sampleRate, hopLength, fmin, nBins, binsPerOctave);
1528
1584
  }
1529
1585
  function vqt(samples, sampleRate = 22050, hopLength = 512, fmin = 32.70319566257483, nBins = 84, binsPerOctave = 12, gamma = 0, options = {}) {
1530
1586
  validateMusicSamples("vqt", samples, sampleRate, options);
@@ -1534,7 +1590,7 @@ function vqt(samples, sampleRate = 22050, hopLength = 512, fmin = 32.70319566257
1534
1590
  if (gamma < 0) {
1535
1591
  throw new RangeError("vqt: gamma must be non-negative");
1536
1592
  }
1537
- return requireModule3().vqt(samples, sampleRate, hopLength, fmin, nBins, binsPerOctave, gamma);
1593
+ return requireModule9().vqt(samples, sampleRate, hopLength, fmin, nBins, binsPerOctave, gamma);
1538
1594
  }
1539
1595
  function analyzeSections(samples, sampleRate = 22050, options = {}) {
1540
1596
  validateMusicSamples("analyzeSections", samples, sampleRate, options);
@@ -1546,7 +1602,7 @@ function analyzeSections(samples, sampleRate = 22050, options = {}) {
1546
1602
  if ((options.minSectionSec ?? 4) <= 0) {
1547
1603
  throw new RangeError("analyzeSections: minSectionSec must be positive");
1548
1604
  }
1549
- const sections = requireModule3().analyzeSections(
1605
+ const sections = requireModule9().analyzeSections(
1550
1606
  samples,
1551
1607
  sampleRate,
1552
1608
  options.nFft ?? 2048,
@@ -1572,7 +1628,7 @@ function analyzeMelody(samples, sampleRate = 22050, options = {}) {
1572
1628
  if (threshold <= 0) {
1573
1629
  throw new RangeError("analyzeMelody: threshold must be positive");
1574
1630
  }
1575
- return requireModule3().analyzeMelody(
1631
+ return requireModule9().analyzeMelody(
1576
1632
  samples,
1577
1633
  sampleRate,
1578
1634
  options.fmin ?? 65,
@@ -1587,47 +1643,47 @@ function analyzeMelody(samples, sampleRate = 22050, options = {}) {
1587
1643
  function onsetEnvelope(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, nMels = 128, options = {}) {
1588
1644
  validateMusicSamples("onsetEnvelope", samples, sampleRate, options);
1589
1645
  validatePositiveIntegers("onsetEnvelope", { nFft, hopLength, nMels });
1590
- return requireModule3().onsetEnvelope(samples, sampleRate, nFft, hopLength, nMels);
1646
+ return requireModule9().onsetEnvelope(samples, sampleRate, nFft, hopLength, nMels);
1591
1647
  }
1592
1648
  function onsetStrengthMulti(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, nMels = 128, nBands = 3, options = {}) {
1593
1649
  validateMusicSamples("onsetStrengthMulti", samples, sampleRate, options);
1594
1650
  validatePositiveIntegers("onsetStrengthMulti", { nFft, hopLength, nMels, nBands });
1595
- return requireModule3().onsetStrengthMulti(samples, sampleRate, nFft, hopLength, nMels, nBands);
1651
+ return requireModule9().onsetStrengthMulti(samples, sampleRate, nFft, hopLength, nMels, nBands);
1596
1652
  }
1597
1653
  function fourierTempogram(onsetEnvelope2, sampleRate = 22050, hopLength = 512, winLength = 384, options = {}) {
1598
1654
  assertSampleRate("fourierTempogram", sampleRate);
1599
1655
  assertSamples("fourierTempogram", onsetEnvelope2, options.validate !== false, "onsetEnvelope");
1600
1656
  validatePositiveIntegers("fourierTempogram", { hopLength, winLength });
1601
- return requireModule3().fourierTempogram(onsetEnvelope2, sampleRate, hopLength, winLength);
1657
+ return requireModule9().fourierTempogram(onsetEnvelope2, sampleRate, hopLength, winLength);
1602
1658
  }
1603
- function tempogramRatio(tempogramData, winLength = 384, sampleRate = 22050, hopLength = 512, options = {}) {
1659
+ function tempogramRatio(tempogramData, winLength = 384, sampleRate = 22050, hopLength = 512, factors, options = {}) {
1604
1660
  assertSampleRate("tempogramRatio", sampleRate);
1605
1661
  assertSamples("tempogramRatio", tempogramData, options.validate !== false, "tempogramData");
1606
1662
  validatePositiveIntegers("tempogramRatio", { winLength, hopLength });
1607
- return requireModule3().tempogramRatio(tempogramData, winLength, sampleRate, hopLength);
1663
+ return requireModule9().tempogramRatio(tempogramData, winLength, sampleRate, hopLength, factors);
1608
1664
  }
1609
1665
  function lufs(samples, sampleRate = 22050, options = {}) {
1610
1666
  assertSampleRate("lufs", sampleRate);
1611
1667
  assertSamples("lufs", samples, options.validate !== false);
1612
- return requireModule3().lufs(samples, sampleRate);
1668
+ return requireModule9().lufs(samples, sampleRate);
1613
1669
  }
1614
1670
  function momentaryLufs(samples, sampleRate = 22050, options = {}) {
1615
1671
  assertSampleRate("momentaryLufs", sampleRate);
1616
1672
  assertSamples("momentaryLufs", samples, options.validate !== false);
1617
- return requireModule3().momentaryLufs(samples, sampleRate);
1673
+ return requireModule9().momentaryLufs(samples, sampleRate);
1618
1674
  }
1619
1675
  function shortTermLufs(samples, sampleRate = 22050, options = {}) {
1620
1676
  assertSampleRate("shortTermLufs", sampleRate);
1621
1677
  assertSamples("shortTermLufs", samples, options.validate !== false);
1622
- return requireModule3().shortTermLufs(samples, sampleRate);
1678
+ return requireModule9().shortTermLufs(samples, sampleRate);
1623
1679
  }
1624
1680
 
1625
1681
  // src/feature_pitch.ts
1626
- function requireModule4() {
1682
+ function requireModule10() {
1627
1683
  return getSonareModule();
1628
1684
  }
1629
1685
  function pitchYin(samples, sampleRate = 22050, frameLength = 2048, hopLength = 512, fmin = 65, fmax = 2093, threshold = 0.3, fillNa = false) {
1630
- return requireModule4().pitchYin(
1686
+ return requireModule10().pitchYin(
1631
1687
  samples,
1632
1688
  sampleRate,
1633
1689
  frameLength,
@@ -1639,7 +1695,7 @@ function pitchYin(samples, sampleRate = 22050, frameLength = 2048, hopLength = 5
1639
1695
  );
1640
1696
  }
1641
1697
  function pitchPyin(samples, sampleRate = 22050, frameLength = 2048, hopLength = 512, fmin = 65, fmax = 2093, threshold = 0.3, fillNa = false) {
1642
- return requireModule4().pitchPyin(
1698
+ return requireModule10().pitchPyin(
1643
1699
  samples,
1644
1700
  sampleRate,
1645
1701
  frameLength,
@@ -1652,22 +1708,22 @@ function pitchPyin(samples, sampleRate = 22050, frameLength = 2048, hopLength =
1652
1708
  }
1653
1709
 
1654
1710
  // src/feature_resample.ts
1655
- function requireModule5() {
1711
+ function requireModule11() {
1656
1712
  return getSonareModule();
1657
1713
  }
1658
1714
  function resample(samples, srcSr, targetSr) {
1659
- return requireModule5().resample(samples, srcSr, targetSr);
1715
+ return requireModule11().resample(samples, srcSr, targetSr);
1660
1716
  }
1661
1717
 
1662
1718
  // src/feature_spectral.ts
1663
- function requireModule6() {
1719
+ function requireModule12() {
1664
1720
  return getSonareModule();
1665
1721
  }
1666
1722
  function spectralCentroid(samples, sampleRate = 22050, nFft = 2048, hopLength = 512) {
1667
- return requireModule6().spectralCentroid(samples, sampleRate, nFft, hopLength);
1723
+ return requireModule12().spectralCentroid(samples, sampleRate, nFft, hopLength);
1668
1724
  }
1669
1725
  function spectralContrast(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, nBands = 6, fmin = 200, quantile = 0.02) {
1670
- return requireModule6().spectralContrast(
1726
+ return requireModule12().spectralContrast(
1671
1727
  samples,
1672
1728
  sampleRate,
1673
1729
  nFft,
@@ -1678,16 +1734,16 @@ function spectralContrast(samples, sampleRate = 22050, nFft = 2048, hopLength =
1678
1734
  );
1679
1735
  }
1680
1736
  function polyFeatures(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, order = 1) {
1681
- return requireModule6().polyFeatures(samples, sampleRate, nFft, hopLength, order);
1737
+ return requireModule12().polyFeatures(samples, sampleRate, nFft, hopLength, order);
1682
1738
  }
1683
1739
  function zeroCrossings(samples, threshold = 1e-10, refMagnitude = false, pad = true, zeroPos = true) {
1684
- return requireModule6().zeroCrossings(samples, threshold, refMagnitude, pad, zeroPos);
1740
+ return requireModule12().zeroCrossings(samples, threshold, refMagnitude, pad, zeroPos);
1685
1741
  }
1686
1742
  function pitchTuning(frequencies, resolution = 0.01, binsPerOctave = 12) {
1687
- return requireModule6().pitchTuning(frequencies, resolution, binsPerOctave);
1743
+ return requireModule12().pitchTuning(frequencies, resolution, binsPerOctave);
1688
1744
  }
1689
1745
  function estimateTuning(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, resolution = 0.01, binsPerOctave = 12) {
1690
- return requireModule6().estimateTuning(
1746
+ return requireModule12().estimateTuning(
1691
1747
  samples,
1692
1748
  sampleRate,
1693
1749
  nFft,
@@ -1697,50 +1753,50 @@ function estimateTuning(samples, sampleRate = 22050, nFft = 2048, hopLength = 51
1697
1753
  );
1698
1754
  }
1699
1755
  function decompose(s, nFeatures, nFrames, nComponents, nIter = 50, beta = 2) {
1700
- return requireModule6().decompose(s, nFeatures, nFrames, nComponents, nIter, beta);
1756
+ return requireModule12().decompose(s, nFeatures, nFrames, nComponents, nIter, beta);
1701
1757
  }
1702
1758
  function decomposeWithInit(s, nFeatures, nFrames, nComponents, nIter = 50, beta = 2, init2 = "random") {
1703
- return requireModule6().decomposeWithInit(s, nFeatures, nFrames, nComponents, nIter, beta, init2);
1759
+ return requireModule12().decomposeWithInit(s, nFeatures, nFrames, nComponents, nIter, beta, init2);
1704
1760
  }
1705
1761
  function nnFilter(s, nFeatures, nFrames, aggregate = "mean", k = 7, width = 1) {
1706
- return requireModule6().nnFilter(s, nFeatures, nFrames, aggregate, k, width);
1762
+ return requireModule12().nnFilter(s, nFeatures, nFrames, aggregate, k, width);
1707
1763
  }
1708
1764
  function remix(samples, intervals, sampleRate = 22050, alignZeros = false) {
1709
1765
  const intervalsI32 = intervals instanceof Int32Array ? intervals : Int32Array.from(intervals, (v) => Math.trunc(v));
1710
- return requireModule6().remix(samples, intervalsI32, sampleRate, alignZeros);
1766
+ return requireModule12().remix(samples, intervalsI32, sampleRate, alignZeros);
1711
1767
  }
1712
1768
  function phaseVocoder(samples, rate, sampleRate = 22050, nFft = 2048, hopLength = 512) {
1713
- return requireModule6().phaseVocoder(samples, sampleRate, rate, nFft, hopLength);
1769
+ return requireModule12().phaseVocoder(samples, sampleRate, rate, nFft, hopLength);
1714
1770
  }
1715
1771
  function hpssWithResidual(samples, sampleRate = 22050, kernelHarmonic = 31, kernelPercussive = 31) {
1716
- return requireModule6().hpssWithResidual(samples, sampleRate, kernelHarmonic, kernelPercussive);
1772
+ return requireModule12().hpssWithResidual(samples, sampleRate, kernelHarmonic, kernelPercussive);
1717
1773
  }
1718
1774
  function lufsInterleaved(samples, channels, sampleRate = 22050, options = {}) {
1719
1775
  assertSampleRate("lufsInterleaved", sampleRate);
1720
1776
  assertInterleavedSamples("lufsInterleaved", samples, channels, options.validate !== false);
1721
- return requireModule6().lufsInterleaved(samples, channels, sampleRate);
1777
+ return requireModule12().lufsInterleaved(samples, channels, sampleRate);
1722
1778
  }
1723
1779
  function ebur128LoudnessRange(samples, sampleRate = 22050) {
1724
- return requireModule6().ebur128LoudnessRange(samples, sampleRate);
1780
+ return requireModule12().ebur128LoudnessRange(samples, sampleRate);
1725
1781
  }
1726
1782
  function spectralBandwidth(samples, sampleRate = 22050, nFft = 2048, hopLength = 512) {
1727
- return requireModule6().spectralBandwidth(samples, sampleRate, nFft, hopLength);
1783
+ return requireModule12().spectralBandwidth(samples, sampleRate, nFft, hopLength);
1728
1784
  }
1729
1785
  function spectralRolloff(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, rollPercent = 0.85) {
1730
- return requireModule6().spectralRolloff(samples, sampleRate, nFft, hopLength, rollPercent);
1786
+ return requireModule12().spectralRolloff(samples, sampleRate, nFft, hopLength, rollPercent);
1731
1787
  }
1732
1788
  function spectralFlatness(samples, sampleRate = 22050, nFft = 2048, hopLength = 512) {
1733
- return requireModule6().spectralFlatness(samples, sampleRate, nFft, hopLength);
1789
+ return requireModule12().spectralFlatness(samples, sampleRate, nFft, hopLength);
1734
1790
  }
1735
1791
  function zeroCrossingRate(samples, sampleRate = 22050, frameLength = 2048, hopLength = 512) {
1736
- return requireModule6().zeroCrossingRate(samples, sampleRate, frameLength, hopLength);
1792
+ return requireModule12().zeroCrossingRate(samples, sampleRate, frameLength, hopLength);
1737
1793
  }
1738
1794
  function rmsEnergy(samples, sampleRate = 22050, frameLength = 2048, hopLength = 512) {
1739
- return requireModule6().rmsEnergy(samples, sampleRate, frameLength, hopLength);
1795
+ return requireModule12().rmsEnergy(samples, sampleRate, frameLength, hopLength);
1740
1796
  }
1741
1797
 
1742
1798
  // src/feature_spectrogram.ts
1743
- function requireModule7() {
1799
+ function requireModule13() {
1744
1800
  return getSonareModule();
1745
1801
  }
1746
1802
  function validateSpectrogramSamples(fnName, samples, sampleRate, options = {}) {
@@ -1777,33 +1833,38 @@ function validateMatrix(fnName, data, rows, frames, dataName, rowName, options =
1777
1833
  function trim(samples, sampleRate, thresholdDb = -60, options = {}) {
1778
1834
  validateSpectrogramSamples("trim", samples, sampleRate, options);
1779
1835
  assertFiniteScalar("trim", thresholdDb, "thresholdDb");
1780
- return requireModule7().trim(samples, sampleRate, thresholdDb);
1836
+ return requireModule13().trim(samples, sampleRate, thresholdDb);
1781
1837
  }
1782
1838
  function stft(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, options = {}) {
1783
1839
  validateSpectrogramSamples("stft", samples, sampleRate, options);
1784
1840
  validatePositiveIntegers2("stft", { nFft, hopLength });
1785
- return requireModule7().stft(samples, sampleRate, nFft, hopLength);
1841
+ return requireModule13().stft(samples, sampleRate, nFft, hopLength);
1786
1842
  }
1787
1843
  function stftDb(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, options = {}) {
1788
1844
  validateSpectrogramSamples("stftDb", samples, sampleRate, options);
1789
1845
  validatePositiveIntegers2("stftDb", { nFft, hopLength });
1790
- return requireModule7().stftDb(samples, sampleRate, nFft, hopLength);
1846
+ return requireModule13().stftDb(samples, sampleRate, nFft, hopLength);
1791
1847
  }
1792
1848
  function chromaCens(samples, sampleRate = 22050, hopLength = 512, nChroma = 12, options = {}) {
1793
1849
  validateSpectrogramSamples("chromaCens", samples, sampleRate, options);
1794
1850
  validatePositiveIntegers2("chromaCens", { hopLength, nChroma });
1795
- return requireModule7().chromaCens(samples, sampleRate, hopLength, nChroma);
1851
+ return requireModule13().chromaCens(samples, sampleRate, hopLength, nChroma);
1852
+ }
1853
+ function chromaCqt(samples, sampleRate = 22050, hopLength = 512, nChroma = 12, options = {}) {
1854
+ validateSpectrogramSamples("chromaCqt", samples, sampleRate, options);
1855
+ validatePositiveIntegers2("chromaCqt", { hopLength, nChroma });
1856
+ return requireModule13().chromaCqt(samples, sampleRate, hopLength, nChroma);
1796
1857
  }
1797
1858
  function bassChroma(samples, sampleRate = 22050, hopLength = 512, nChroma = 12, options = {}) {
1798
1859
  validateSpectrogramSamples("bassChroma", samples, sampleRate, options);
1799
1860
  validatePositiveIntegers2("bassChroma", { hopLength, nChroma });
1800
- return requireModule7().bassChroma(samples, sampleRate, hopLength, nChroma);
1861
+ return requireModule13().bassChroma(samples, sampleRate, hopLength, nChroma);
1801
1862
  }
1802
1863
  function melSpectrogram(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, nMels = 128, fmin = 0, fmax = 0, htk = false, options = {}) {
1803
1864
  validateSpectrogramSamples("melSpectrogram", samples, sampleRate, options);
1804
1865
  validatePositiveIntegers2("melSpectrogram", { nFft, hopLength, nMels });
1805
1866
  validateMelFrequencyRange("melSpectrogram", fmin, fmax, sampleRate);
1806
- return requireModule7().melSpectrogram(
1867
+ return requireModule13().melSpectrogram(
1807
1868
  samples,
1808
1869
  sampleRate,
1809
1870
  nFft,
@@ -1814,25 +1875,36 @@ function melSpectrogram(samples, sampleRate = 22050, nFft = 2048, hopLength = 51
1814
1875
  htk
1815
1876
  );
1816
1877
  }
1817
- function mfcc(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, nMels = 128, nMfcc = 20, fmin = 0, fmax = 0, htk = false, options = {}) {
1878
+ function mfcc(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, nMels = 128, nMfcc = 20, fmin = 0, fmax = 0, htk = false, lifter = 0, options = {}) {
1818
1879
  validateSpectrogramSamples("mfcc", samples, sampleRate, options);
1819
1880
  validatePositiveIntegers2("mfcc", { nFft, hopLength, nMels, nMfcc });
1820
1881
  validateMelFrequencyRange("mfcc", fmin, fmax, sampleRate);
1821
- return requireModule7().mfcc(samples, sampleRate, nFft, hopLength, nMels, nMfcc, fmin, fmax, htk);
1882
+ return requireModule13().mfcc(
1883
+ samples,
1884
+ sampleRate,
1885
+ nFft,
1886
+ hopLength,
1887
+ nMels,
1888
+ nMfcc,
1889
+ fmin,
1890
+ fmax,
1891
+ htk,
1892
+ lifter
1893
+ );
1822
1894
  }
1823
1895
  function melToStft(melPower, nMels, nFrames, sampleRate = 22050, nFft = 2048, fmin = 0, fmax = 0, htk = false, options = {}) {
1824
1896
  assertSampleRate("melToStft", sampleRate);
1825
1897
  validateMatrix("melToStft", melPower, nMels, nFrames, "melPower", "nMels", options);
1826
1898
  validatePositiveIntegers2("melToStft", { nFft });
1827
1899
  validateMelFrequencyRange("melToStft", fmin, fmax, sampleRate);
1828
- return requireModule7().melToStft(melPower, nMels, nFrames, sampleRate, nFft, fmin, fmax, htk);
1900
+ return requireModule13().melToStft(melPower, nMels, nFrames, sampleRate, nFft, fmin, fmax, htk);
1829
1901
  }
1830
1902
  function melToAudio(melPower, nMels, nFrames, sampleRate = 22050, nFft = 2048, hopLength = 512, fmin = 0, fmax = 0, nIter = 32, htk = false, options = {}) {
1831
1903
  assertSampleRate("melToAudio", sampleRate);
1832
1904
  validateMatrix("melToAudio", melPower, nMels, nFrames, "melPower", "nMels", options);
1833
1905
  validatePositiveIntegers2("melToAudio", { nFft, hopLength, nIter });
1834
1906
  validateMelFrequencyRange("melToAudio", fmin, fmax, sampleRate);
1835
- return requireModule7().melToAudio(
1907
+ return requireModule13().melToAudio(
1836
1908
  melPower,
1837
1909
  nMels,
1838
1910
  nFrames,
@@ -1856,7 +1928,7 @@ function mfccToMel(mfccCoefficients, nMfcc, nFrames, nMels = 128, options = {})
1856
1928
  options
1857
1929
  );
1858
1930
  validatePositiveIntegers2("mfccToMel", { nMels });
1859
- return requireModule7().mfccToMel(mfccCoefficients, nMfcc, nFrames, nMels);
1931
+ return requireModule13().mfccToMel(mfccCoefficients, nMfcc, nFrames, nMels);
1860
1932
  }
1861
1933
  function mfccToAudio(mfccCoefficients, nMfcc, nFrames, nMels = 128, sampleRate = 22050, nFft = 2048, hopLength = 512, fmin = 0, fmax = 0, nIter = 32, htk = false, options = {}) {
1862
1934
  assertSampleRate("mfccToAudio", sampleRate);
@@ -1871,7 +1943,7 @@ function mfccToAudio(mfccCoefficients, nMfcc, nFrames, nMels = 128, sampleRate =
1871
1943
  );
1872
1944
  validatePositiveIntegers2("mfccToAudio", { nMels, nFft, hopLength, nIter });
1873
1945
  validateMelFrequencyRange("mfccToAudio", fmin, fmax, sampleRate);
1874
- return requireModule7().mfccToAudio(
1946
+ return requireModule13().mfccToAudio(
1875
1947
  mfccCoefficients,
1876
1948
  nMfcc,
1877
1949
  nFrames,
@@ -1888,10 +1960,10 @@ function mfccToAudio(mfccCoefficients, nMfcc, nFrames, nMels = 128, sampleRate =
1888
1960
  function chroma(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, options = {}) {
1889
1961
  validateSpectrogramSamples("chroma", samples, sampleRate, options);
1890
1962
  validatePositiveIntegers2("chroma", { nFft, hopLength });
1891
- return requireModule7().chroma(samples, sampleRate, nFft, hopLength);
1963
+ return requireModule13().chroma(samples, sampleRate, nFft, hopLength);
1892
1964
  }
1893
1965
 
1894
- // src/public_types.ts
1966
+ // src/public_types_music.ts
1895
1967
  var PitchClass = {
1896
1968
  C: 0,
1897
1969
  Cs: 1,
@@ -2086,7 +2158,7 @@ function convertAnalysisResult(wasm) {
2086
2158
  }
2087
2159
 
2088
2160
  // src/quick_analysis.ts
2089
- function requireModule8() {
2161
+ function requireModule14() {
2090
2162
  return getSonareModule();
2091
2163
  }
2092
2164
  function validateAnalysisInput(fnName, samples, sampleRate, options = {}) {
@@ -2095,11 +2167,11 @@ function validateAnalysisInput(fnName, samples, sampleRate, options = {}) {
2095
2167
  }
2096
2168
  function detectBpm(samples, sampleRate = 22050, options = {}) {
2097
2169
  validateAnalysisInput("detectBpm", samples, sampleRate, options);
2098
- return requireModule8().detectBpm(samples, sampleRate);
2170
+ return requireModule14().detectBpm(samples, sampleRate);
2099
2171
  }
2100
2172
  function detectKey(samples, sampleRate = 22050, options = {}) {
2101
2173
  validateAnalysisInput("detectKey", samples, sampleRate, options);
2102
- const result = requireModule8()._detectKeyWithOptions(
2174
+ const result = requireModule14()._detectKeyWithOptions(
2103
2175
  samples,
2104
2176
  sampleRate,
2105
2177
  options.nFft ?? 4096,
@@ -2121,7 +2193,7 @@ function detectKey(samples, sampleRate = 22050, options = {}) {
2121
2193
  }
2122
2194
  function detectKeyCandidates(samples, sampleRate = 22050, options = {}) {
2123
2195
  validateAnalysisInput("detectKeyCandidates", samples, sampleRate, options);
2124
- const candidates = requireModule8()._detectKeyCandidates(
2196
+ const candidates = requireModule14()._detectKeyCandidates(
2125
2197
  samples,
2126
2198
  sampleRate,
2127
2199
  options.nFft ?? 4096,
@@ -2137,19 +2209,19 @@ function detectKeyCandidates(samples, sampleRate = 22050, options = {}) {
2137
2209
  }
2138
2210
  function detectOnsets(samples, sampleRate = 22050, options = {}) {
2139
2211
  validateAnalysisInput("detectOnsets", samples, sampleRate, options);
2140
- return requireModule8().detectOnsets(samples, sampleRate);
2212
+ return requireModule14().detectOnsets(samples, sampleRate);
2141
2213
  }
2142
2214
  function detectBeats(samples, sampleRate = 22050, options = {}) {
2143
2215
  validateAnalysisInput("detectBeats", samples, sampleRate, options);
2144
- return requireModule8().detectBeats(samples, sampleRate);
2216
+ return requireModule14().detectBeats(samples, sampleRate);
2145
2217
  }
2146
2218
  function detectDownbeats(samples, sampleRate = 22050, options = {}) {
2147
2219
  validateAnalysisInput("detectDownbeats", samples, sampleRate, options);
2148
- return requireModule8().detectDownbeats(samples, sampleRate);
2220
+ return requireModule14().detectDownbeats(samples, sampleRate);
2149
2221
  }
2150
2222
  function detectChords(samples, sampleRate = 22050, options = {}) {
2151
2223
  validateAnalysisInput("detectChords", samples, sampleRate, options);
2152
- const result = requireModule8().detectChords(
2224
+ const result = requireModule14().detectChords(
2153
2225
  samples,
2154
2226
  sampleRate,
2155
2227
  options.minDuration ?? 0.3,
@@ -2171,7 +2243,7 @@ function detectChords(samples, sampleRate = 22050, options = {}) {
2171
2243
  }
2172
2244
  function chordFunctionalAnalysis(samples, keyRoot, keyMode, sampleRate = 22050, options = {}) {
2173
2245
  validateAnalysisInput("chordFunctionalAnalysis", samples, sampleRate, options);
2174
- return requireModule8().chordFunctionalAnalysis(
2246
+ return requireModule14().chordFunctionalAnalysis(
2175
2247
  samples,
2176
2248
  keyRoot,
2177
2249
  keyMode,
@@ -2192,12 +2264,12 @@ function chordFunctionalAnalysis(samples, keyRoot, keyMode, sampleRate = 22050,
2192
2264
  }
2193
2265
  function analyze(samples, sampleRate = 22050, options = {}) {
2194
2266
  validateAnalysisInput("analyze", samples, sampleRate, options);
2195
- const result = requireModule8().analyze(samples, sampleRate);
2267
+ const result = requireModule14().analyze(samples, sampleRate);
2196
2268
  return convertAnalysisResult(result);
2197
2269
  }
2198
2270
  function analyzeImpulseResponse(samples, sampleRate = 48e3, nOctaveBands = 6) {
2199
2271
  validateAnalysisInput("analyzeImpulseResponse", samples, sampleRate);
2200
- const result = requireModule8().analyzeImpulseResponse(
2272
+ const result = requireModule14().analyzeImpulseResponse(
2201
2273
  samples,
2202
2274
  sampleRate,
2203
2275
  nOctaveBands
@@ -2206,7 +2278,7 @@ function analyzeImpulseResponse(samples, sampleRate = 48e3, nOctaveBands = 6) {
2206
2278
  }
2207
2279
  function detectAcoustic(samples, sampleRate = 48e3, options = {}) {
2208
2280
  validateAnalysisInput("detectAcoustic", samples, sampleRate);
2209
- const result = requireModule8().detectAcoustic(
2281
+ const result = requireModule14().detectAcoustic(
2210
2282
  samples,
2211
2283
  sampleRate,
2212
2284
  options.nOctaveBands ?? 6,
@@ -2217,14 +2289,14 @@ function detectAcoustic(samples, sampleRate = 48e3, options = {}) {
2217
2289
  return result;
2218
2290
  }
2219
2291
  function synthesizeRir(options = {}) {
2220
- const module2 = requireModule8();
2292
+ const module2 = requireModule14();
2221
2293
  if (typeof module2.synthesizeRir !== "function") {
2222
2294
  throw new Error("libsonare was built without acoustic-simulation support");
2223
2295
  }
2224
2296
  return module2.synthesizeRir(options);
2225
2297
  }
2226
2298
  function estimateRoom(samples, sampleRate = 48e3, options = {}) {
2227
- const module2 = requireModule8();
2299
+ const module2 = requireModule14();
2228
2300
  if (typeof module2.estimateRoom !== "function") {
2229
2301
  throw new Error("libsonare was built without acoustic-simulation support");
2230
2302
  }
@@ -2232,7 +2304,7 @@ function estimateRoom(samples, sampleRate = 48e3, options = {}) {
2232
2304
  return module2.estimateRoom(samples, sampleRate, options);
2233
2305
  }
2234
2306
  function roomMorph(samples, sampleRate, options = {}) {
2235
- const module2 = requireModule8();
2307
+ const module2 = requireModule14();
2236
2308
  if (typeof module2.roomMorph !== "function") {
2237
2309
  throw new Error("libsonare was built without acoustic-simulation support");
2238
2310
  }
@@ -2241,13 +2313,13 @@ function roomMorph(samples, sampleRate, options = {}) {
2241
2313
  }
2242
2314
  function analyzeWithProgress(samples, sampleRate = 22050, onProgress) {
2243
2315
  validateAnalysisInput("analyzeWithProgress", samples, sampleRate);
2244
- const result = requireModule8().analyzeWithProgress(samples, sampleRate, onProgress);
2316
+ const result = requireModule14().analyzeWithProgress(samples, sampleRate, onProgress);
2245
2317
  return convertAnalysisResult(result);
2246
2318
  }
2247
2319
  function analyzeBpm(samples, sampleRate = 22050, options = {}) {
2248
2320
  validateAnalysisInput("analyzeBpm", samples, sampleRate, options);
2249
2321
  assertNonNegativeInteger("analyzeBpm", options.maxCandidates ?? 5, "maxCandidates");
2250
- return requireModule8().analyzeBpm(
2322
+ return requireModule14().analyzeBpm(
2251
2323
  samples,
2252
2324
  sampleRate,
2253
2325
  options.bpmMin ?? 30,
@@ -2260,7 +2332,7 @@ function analyzeBpm(samples, sampleRate = 22050, options = {}) {
2260
2332
  }
2261
2333
  function analyzeRhythm(samples, sampleRate = 22050, options = {}) {
2262
2334
  validateAnalysisInput("analyzeRhythm", samples, sampleRate, options);
2263
- return requireModule8().analyzeRhythm(
2335
+ return requireModule14().analyzeRhythm(
2264
2336
  samples,
2265
2337
  sampleRate,
2266
2338
  options.bpmMin ?? 60,
@@ -2272,7 +2344,7 @@ function analyzeRhythm(samples, sampleRate = 22050, options = {}) {
2272
2344
  }
2273
2345
  function analyzeDynamics(samples, sampleRate = 22050, options = {}) {
2274
2346
  validateAnalysisInput("analyzeDynamics", samples, sampleRate, options);
2275
- return requireModule8().analyzeDynamics(
2347
+ return requireModule14().analyzeDynamics(
2276
2348
  samples,
2277
2349
  sampleRate,
2278
2350
  options.windowSec ?? 0.4,
@@ -2282,7 +2354,7 @@ function analyzeDynamics(samples, sampleRate = 22050, options = {}) {
2282
2354
  }
2283
2355
  function analyzeTimbre(samples, sampleRate = 22050, options = {}) {
2284
2356
  validateAnalysisInput("analyzeTimbre", samples, sampleRate, options);
2285
- return requireModule8().analyzeTimbre(
2357
+ return requireModule14().analyzeTimbre(
2286
2358
  samples,
2287
2359
  sampleRate,
2288
2360
  options.nFft ?? 2048,
@@ -2293,7 +2365,7 @@ function analyzeTimbre(samples, sampleRate = 22050, options = {}) {
2293
2365
  );
2294
2366
  }
2295
2367
  function hasFfmpegSupport() {
2296
- return requireModule8().hasFfmpegSupport();
2368
+ return requireModule14().hasFfmpegSupport();
2297
2369
  }
2298
2370
 
2299
2371
  // src/audio.ts
@@ -2557,155 +2629,6 @@ var Audio = class _Audio {
2557
2629
  }
2558
2630
  };
2559
2631
 
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
2632
  // src/opfs_clip_pages.ts
2710
2633
  var opfsClipPageWorkerSource = `
2711
2634
  const sonareClipPageReadQueues = new Map();
@@ -2899,60 +2822,324 @@ function createOpfsClipPageProvider(engine, options) {
2899
2822
  };
2900
2823
  }
2901
2824
 
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
- ];
2825
+ // src/clip_page_streamer.ts
2826
+ var ClipPageStreamer = class {
2827
+ constructor(engine, options = {}) {
2828
+ this.sources = /* @__PURE__ */ new Map();
2829
+ this.closed = false;
2830
+ this.engine = engine;
2831
+ this.readAheadPages = Math.max(0, Math.floor(options.readAheadPages ?? 2));
2832
+ this.retainBehindPages = Math.max(0, Math.floor(options.retainBehindPages ?? 1));
2833
+ this.maxRequestsPerPump = Math.max(1, Math.floor(options.maxRequestsPerPump ?? 256));
2834
+ }
2835
+ /**
2836
+ * Register a paged clip. Pages already supplied to the provider before
2837
+ * registration (for example a primed first page) should be passed in
2838
+ * `initialResidentPages` so they participate in eviction.
2839
+ */
2840
+ addSource(source, initialResidentPages = []) {
2841
+ if (source.pageFrames <= 0 || source.numSamples <= 0) {
2842
+ throw new Error("pageFrames and numSamples must be positive");
2843
+ }
2844
+ const lastPage = Math.ceil(source.numSamples / source.pageFrames) - 1;
2845
+ const previous = this.sources.get(source.clipId);
2846
+ if (previous) {
2847
+ this.resetState(previous);
2848
+ }
2849
+ this.sources.set(source.clipId, {
2850
+ source,
2851
+ lastPage,
2852
+ generation: 0,
2853
+ lastFrontier: null,
2854
+ resident: new Map(Array.from(initialResidentPages, (page) => [page, 0]))
2855
+ });
2856
+ }
2857
+ /** Stop tracking a clip. Does not close its binding (the caller owns that). */
2858
+ removeSource(clipId) {
2859
+ const state = this.sources.get(clipId);
2860
+ if (state) {
2861
+ this.resetState(state);
2862
+ }
2863
+ this.sources.delete(clipId);
2864
+ }
2865
+ /**
2866
+ * Explicitly start a new playback generation after a host seek/loop. Resident
2867
+ * pages are evicted and any older in-flight fetch is cleared when it settles.
2868
+ * The next miss establishes the new bounded window.
2869
+ */
2870
+ resetSource(clipId) {
2871
+ const state = this.sources.get(clipId);
2872
+ if (state) {
2873
+ this.resetState(state);
2874
+ }
2875
+ }
2876
+ /**
2877
+ * Drain pending page-miss requests, fetch the missing pages plus their
2878
+ * read-ahead window, and evict out-of-window pages. Resolves once this round's
2879
+ * fetches settle. Concurrent fetches are serialized inside each binding.
2880
+ */
2881
+ async pump() {
2882
+ if (this.closed) {
2883
+ return;
2884
+ }
2885
+ const frontiers = /* @__PURE__ */ new Map();
2886
+ for (let drained = 0; drained < this.maxRequestsPerPump; ++drained) {
2887
+ const request = this.engine.popClipPageRequest();
2888
+ if (!request) {
2889
+ break;
2890
+ }
2891
+ const state = this.sources.get(request.clipId);
2892
+ if (!state) {
2893
+ continue;
2894
+ }
2895
+ const page = Math.floor(request.sample / state.source.pageFrames);
2896
+ frontiers.set(request.clipId, page);
2897
+ }
2898
+ const fetches = [];
2899
+ for (const [clipId, frontier] of frontiers) {
2900
+ const state = this.sources.get(clipId);
2901
+ if (!state) {
2902
+ continue;
2903
+ }
2904
+ fetches.push(...this.serviceFrontier(state, frontier));
2905
+ }
2906
+ await Promise.all(fetches);
2907
+ }
2908
+ /** Close every registered clip's binding and stop tracking. */
2909
+ close() {
2910
+ if (this.closed) {
2911
+ return;
2912
+ }
2913
+ this.closed = true;
2914
+ for (const state of this.sources.values()) {
2915
+ this.resetState(state);
2916
+ state.source.binding.close();
2917
+ }
2918
+ this.sources.clear();
2919
+ }
2920
+ serviceFrontier(state, frontier) {
2921
+ if (state.lastFrontier !== null && frontier < state.lastFrontier) {
2922
+ this.resetState(state);
2923
+ }
2924
+ state.lastFrontier = frontier;
2925
+ const generation = state.generation;
2926
+ const low = Math.max(0, frontier - this.retainBehindPages);
2927
+ const high = Math.min(state.lastPage, frontier + this.readAheadPages);
2928
+ for (const page of state.resident.keys()) {
2929
+ if (page < low || page > high) {
2930
+ state.source.binding.provider.clear(page);
2931
+ state.resident.delete(page);
2932
+ }
2933
+ }
2934
+ const fetches = [];
2935
+ for (let page = low; page <= high; ++page) {
2936
+ if (state.resident.get(page) === generation) {
2937
+ continue;
2938
+ }
2939
+ state.resident.set(page, generation);
2940
+ const pageIndex = page;
2941
+ fetches.push(
2942
+ state.source.binding.supplyPage(pageIndex).then(
2943
+ (ok) => {
2944
+ if (state.generation !== generation) {
2945
+ state.source.binding.provider.clear(pageIndex);
2946
+ } else if (!ok && state.resident.get(pageIndex) === generation) {
2947
+ state.resident.delete(pageIndex);
2948
+ }
2949
+ return ok;
2950
+ },
2951
+ (error) => {
2952
+ if (state.resident.get(pageIndex) === generation) {
2953
+ state.resident.delete(pageIndex);
2954
+ }
2955
+ throw error;
2956
+ }
2957
+ )
2958
+ );
2959
+ }
2960
+ return fetches;
2961
+ }
2962
+ resetState(state) {
2963
+ state.generation += 1;
2964
+ state.lastFrontier = null;
2965
+ for (const page of state.resident.keys()) {
2966
+ state.source.binding.provider.clear(page);
2967
+ }
2968
+ state.resident.clear();
2969
+ }
2970
+ };
2971
+ async function attachOpfsClipStream(streamer, engine, options) {
2972
+ const { clipId, primePages = 1, ...providerOptions } = options;
2973
+ const binding = createOpfsClipPageProvider(engine, providerOptions);
2974
+ const lastPage = Math.ceil(providerOptions.numSamples / providerOptions.pageFrames) - 1;
2975
+ const primed = [];
2976
+ for (let page = 0; page < primePages && page <= lastPage; ++page) {
2977
+ if (await binding.supplyPage(page)) {
2978
+ primed.push(page);
2979
+ }
2980
+ }
2981
+ streamer.addSource(
2982
+ {
2983
+ clipId,
2984
+ binding,
2985
+ pageFrames: providerOptions.pageFrames,
2986
+ numSamples: providerOptions.numSamples
2987
+ },
2988
+ primed
2989
+ );
2990
+ return { binding, provider: binding.provider };
2991
+ }
2992
+
2993
+ // src/live_audio.ts
2994
+ async function bindMicrophoneInput(context, engine, options = {}) {
2995
+ const { stream: providedStream, stopTracksOnClose = true, ...constraints } = options;
2996
+ const stream = providedStream ?? await navigator.mediaDevices.getUserMedia({
2997
+ ...constraints,
2998
+ audio: constraints.audio ?? true,
2999
+ video: constraints.video ?? false
3000
+ });
3001
+ const source = context.createMediaStreamSource(stream);
3002
+ const node = "node" in engine ? engine.node : engine;
3003
+ source.connect(node);
3004
+ let closed = false;
3005
+ return {
3006
+ stream,
3007
+ source,
3008
+ close() {
3009
+ if (closed) {
3010
+ return;
3011
+ }
3012
+ closed = true;
3013
+ source.disconnect();
3014
+ if (stopTracksOnClose) {
3015
+ for (const track of stream.getAudioTracks()) {
3016
+ track.stop();
3017
+ }
3018
+ }
3019
+ }
3020
+ };
3021
+ }
3022
+
3023
+ // src/metering.ts
3024
+ function requireModule15() {
3025
+ return getSonareModule();
3026
+ }
3027
+ function meteringPeakDb(samples, sampleRate = 22050, options = {}) {
3028
+ assertSamples("meteringPeakDb", samples, options.validate !== false);
3029
+ return requireModule15().meteringPeakDb(samples, sampleRate);
3030
+ }
3031
+ function meteringRmsDb(samples, sampleRate = 22050, options = {}) {
3032
+ assertSamples("meteringRmsDb", samples, options.validate !== false);
3033
+ return requireModule15().meteringRmsDb(samples, sampleRate);
3034
+ }
3035
+ function meteringCrestFactorDb(samples, sampleRate = 22050, options = {}) {
3036
+ assertSamples("meteringCrestFactorDb", samples, options.validate !== false);
3037
+ return requireModule15().meteringCrestFactorDb(samples, sampleRate);
3038
+ }
3039
+ function meteringDcOffset(samples, sampleRate = 22050, options = {}) {
3040
+ assertSamples("meteringDcOffset", samples, options.validate !== false);
3041
+ return requireModule15().meteringDcOffset(samples, sampleRate);
3042
+ }
3043
+ function meteringTruePeakDb(samples, sampleRate = 22050, oversampleFactor = 4, options = {}) {
3044
+ assertSamples("meteringTruePeakDb", samples, options.validate !== false);
3045
+ const factor = oversampleFactor === 0 ? 4 : oversampleFactor;
3046
+ if (factor < 1 || factor > 16 || (factor & factor - 1) !== 0) {
3047
+ throw new RangeError(
3048
+ "meteringTruePeakDb: oversampleFactor must be 0 or a power of two from 1 to 16"
3049
+ );
3050
+ }
3051
+ return requireModule15().meteringTruePeakDb(samples, sampleRate, oversampleFactor);
3052
+ }
3053
+ function meteringDetectClipping(samples, sampleRate = 22050, options = {}) {
3054
+ assertSamples("meteringDetectClipping", samples, options.validate !== false);
3055
+ return requireModule15().meteringDetectClipping(
3056
+ samples,
3057
+ sampleRate,
3058
+ options.threshold ?? 0.999,
3059
+ options.minRegionSamples ?? 1
3060
+ );
3061
+ }
3062
+ function meteringDynamicRange(samples, sampleRate = 22050, options = {}) {
3063
+ assertSamples("meteringDynamicRange", samples, options.validate !== false);
3064
+ return requireModule15().meteringDynamicRange(
3065
+ samples,
3066
+ sampleRate,
3067
+ options.windowSec ?? 0,
3068
+ options.hopSec ?? 0,
3069
+ options.lowPercentile ?? -1,
3070
+ options.highPercentile ?? -1
3071
+ );
3072
+ }
3073
+ function meteringStereoCorrelation(left, right, sampleRate = 22050, options = {}) {
3074
+ const validate = options.validate !== false;
3075
+ assertSamples("meteringStereoCorrelation", left, validate, "left");
3076
+ assertSamples("meteringStereoCorrelation", right, validate, "right");
3077
+ return requireModule15().meteringStereoCorrelation(left, right, sampleRate);
3078
+ }
3079
+ function meteringStereoWidth(left, right, sampleRate = 22050, options = {}) {
3080
+ const validate = options.validate !== false;
3081
+ assertSamples("meteringStereoWidth", left, validate, "left");
3082
+ assertSamples("meteringStereoWidth", right, validate, "right");
3083
+ return requireModule15().meteringStereoWidth(left, right, sampleRate);
3084
+ }
3085
+ function meteringVectorscope(left, right, sampleRate = 22050, options = {}) {
3086
+ const validate = options.validate !== false;
3087
+ assertSamples("meteringVectorscope", left, validate, "left");
3088
+ assertSamples("meteringVectorscope", right, validate, "right");
3089
+ return requireModule15().meteringVectorscope(left, right, sampleRate);
3090
+ }
3091
+ function meteringVectorscopeDecimated(left, right, sampleRate = 22050, maxPoints = 0, options = {}) {
3092
+ const validate = options.validate !== false;
3093
+ assertSamples("meteringVectorscopeDecimated", left, validate, "left");
3094
+ assertSamples("meteringVectorscopeDecimated", right, validate, "right");
3095
+ return requireModule15().meteringVectorscopeDecimated(left, right, sampleRate, maxPoints);
3096
+ }
3097
+ function meteringPhaseScope(left, right, sampleRate = 22050, options = {}) {
3098
+ const validate = options.validate !== false;
3099
+ assertSamples("meteringPhaseScope", left, validate, "left");
3100
+ assertSamples("meteringPhaseScope", right, validate, "right");
3101
+ return requireModule15().meteringPhaseScope(left, right, sampleRate);
3102
+ }
3103
+ function meteringPhaseScopeDecimated(left, right, sampleRate = 22050, maxPoints = 0, options = {}) {
3104
+ const validate = options.validate !== false;
3105
+ assertSamples("meteringPhaseScopeDecimated", left, validate, "left");
3106
+ assertSamples("meteringPhaseScopeDecimated", right, validate, "right");
3107
+ return requireModule15().meteringPhaseScopeDecimated(left, right, sampleRate, maxPoints);
3108
+ }
3109
+ function meteringSpectrum(samples, sampleRate = 22050, options) {
3110
+ const validate = options?.validate !== false;
3111
+ assertSamples("meteringSpectrum", samples, validate);
3112
+ return requireModule15().meteringSpectrum(samples, sampleRate, options ?? {});
3113
+ }
3114
+ function meteringSpectrumFrame(samples, sampleRate = 22050, frameOffset = 0, options) {
3115
+ const validate = options?.validate !== false;
3116
+ assertSamples("meteringSpectrumFrame", samples, validate);
3117
+ return requireModule15().meteringSpectrumFrame(samples, sampleRate, frameOffset, options ?? {});
3118
+ }
3119
+ function waveformPeaks(samples, channels, options = {}) {
3120
+ assertSamples("waveformPeaks", samples, options.validate !== false);
3121
+ if (channels <= 0 || samples.length % channels !== 0) {
3122
+ throw new RangeError("waveformPeaks: samples length must be a multiple of channels");
3123
+ }
3124
+ const samplesPerBucket = options.samplesPerBucket ?? 512;
3125
+ if (samplesPerBucket <= 0) {
3126
+ throw new RangeError("waveformPeaks: samplesPerBucket must be > 0");
3127
+ }
3128
+ return requireModule15().waveformPeaks(samples, channels, samplesPerBucket);
3129
+ }
3130
+ function waveformPeakPyramid(samples, channels, options = {}) {
3131
+ assertSamples("waveformPeakPyramid", samples, options.validate !== false);
3132
+ if (channels <= 0 || samples.length % channels !== 0) {
3133
+ throw new RangeError("waveformPeakPyramid: samples length must be a multiple of channels");
3134
+ }
3135
+ const levels = options.samplesPerBucketLevels ?? [512, 1024, 2048, 4096];
3136
+ if (levels.length === 0 || levels.some((level) => level <= 0)) {
3137
+ throw new RangeError("waveformPeakPyramid: samplesPerBucketLevels must be non-empty and > 0");
3138
+ }
3139
+ return requireModule15().waveformPeakPyramid(samples, channels, levels);
3140
+ }
3141
+
3142
+ // src/project_internal.ts
2956
3143
  function projectModule() {
2957
3144
  const candidate = getSonareModule();
2958
3145
  if (typeof candidate.projectAbiVersion !== "function" || candidate.Project === void 0) {
@@ -3017,18 +3204,41 @@ function assertProjectMidiEvents(fnName, events) {
3017
3204
  }
3018
3205
  });
3019
3206
  }
3020
- function projectAbiVersion() {
3021
- return projectModule().projectAbiVersion();
3022
- }
3023
- function synthPresetNames() {
3024
- return Array.from(projectModule().synthPresetNames());
3207
+ function projectTrackKindValue(kind) {
3208
+ if (kind === void 0 || kind === "audio") {
3209
+ return 0;
3210
+ }
3211
+ if (kind === "midi") {
3212
+ return 1;
3213
+ }
3214
+ if (kind === "aux") {
3215
+ return 2;
3216
+ }
3217
+ return kind;
3025
3218
  }
3026
- function synthPresetPatch(name) {
3027
- return { ...projectModule().synthPresetPatch(name) };
3219
+ function projectWarpModeValue(mode) {
3220
+ if (mode === void 0 || mode === "off") {
3221
+ return 0;
3222
+ }
3223
+ if (mode === "repitch") {
3224
+ return 1;
3225
+ }
3226
+ if (mode === "tempo-sync") {
3227
+ return 2;
3228
+ }
3229
+ return mode;
3028
3230
  }
3029
- function synthEnumTables() {
3030
- return projectModule()._synthEnumTables();
3231
+ function projectLoopModeValue(mode) {
3232
+ if (mode === void 0 || mode === "off") {
3233
+ return 0;
3234
+ }
3235
+ if (mode === "loop") {
3236
+ return 1;
3237
+ }
3238
+ return mode;
3031
3239
  }
3240
+
3241
+ // src/project_class.ts
3032
3242
  var Project = class _Project {
3033
3243
  constructor() {
3034
3244
  this.native = new (projectModule()).Project();
@@ -3364,8 +3574,10 @@ var Project = class _Project {
3364
3574
  * built-in oscillator synth so a MIDI-only arrangement bounces to audible
3365
3575
  * audio. Pass a {@link BuiltinSynthBinding} (or an array of them) to choose
3366
3576
  * the patch and MIDI destination; omit it (or pass `{}`) for one
3367
- * default-destination sine patch. An explicitly empty array `[]` (or
3368
- * `undefined` / `null`) produces zero bindings, so MIDI tracks render silently.
3577
+ * default-destination sine patch. Because the parameter defaults to `{}`,
3578
+ * omission and explicit `undefined` both create that one default binding.
3579
+ * Use an explicitly empty array `[]` (or runtime `null`) for zero bindings,
3580
+ * so MIDI tracks render silently.
3369
3581
  *
3370
3582
  * Like {@link bounce}, omitting `totalFrames` auto-derives the render length
3371
3583
  * from the arrangement plus the synth's release tail.
@@ -3390,9 +3602,10 @@ var Project = class _Project {
3390
3602
  * string (`'saw-lead'` / `'va:saw-lead'`; see {@link synthPresetNames}), or
3391
3603
  * an array of either; each object entry may carry a `destinationId` binding
3392
3604
  * convenience (default 0), which is not part of the NativeSynth patch itself.
3393
- * An explicitly empty array (or `undefined` / `null`) produces zero bindings.
3394
- * Unknown preset names throw. Deterministic for a fixed project + options +
3395
- * patch.
3605
+ * Because the parameter defaults to `{}`, omission and explicit `undefined`
3606
+ * both create one default binding. Use an explicitly empty array `[]` (or
3607
+ * runtime `null`) for zero bindings. Unknown preset names throw.
3608
+ * Deterministic for a fixed project + options + patch.
3396
3609
  */
3397
3610
  bounceWithSynthInstrument(instrument = {}, options = {}) {
3398
3611
  return this.native.bounceWithSynthInstrument(instrument, options);
@@ -3434,8 +3647,10 @@ var Project = class _Project {
3434
3647
  * honored. Programs the SoundFont does not cover — including bouncing with
3435
3648
  * no SoundFont loaded at all — play through the built-in synthesizer GM
3436
3649
  * fallback bank (the data-free floor; see {@link soundFontManifest} for the
3437
- * per-program backend). An explicitly empty array `[]` (or `undefined` /
3438
- * `null`) produces zero bindings, so MIDI tracks render silently.
3650
+ * per-program backend). Because the parameter defaults to `{}`, omission and
3651
+ * explicit `undefined` both create one default binding. Use an explicitly
3652
+ * empty array `[]` (or runtime `null`) for zero bindings, so MIDI tracks
3653
+ * render silently.
3439
3654
  */
3440
3655
  bounceWithSf2Instrument(instrument = {}, options = {}) {
3441
3656
  return this.native.bounceWithSf2Instrument(instrument, options);
@@ -3581,6 +3796,10 @@ var Project = class _Project {
3581
3796
  trackCount() {
3582
3797
  return this.native.trackCount();
3583
3798
  }
3799
+ /** Number of clips in the project. */
3800
+ clipCount() {
3801
+ return this.native.clipCount();
3802
+ }
3584
3803
  /** Number of audio sources registered on the project. */
3585
3804
  sourceCount() {
3586
3805
  return this.native.sourceCount();
@@ -3618,51 +3837,103 @@ var Project = class _Project {
3618
3837
  this.delete();
3619
3838
  }
3620
3839
  };
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;
3840
+
3841
+ // src/project_synth.ts
3842
+ function projectAbiVersion() {
3843
+ return projectModule().projectAbiVersion();
3632
3844
  }
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;
3845
+ function synthPresetNames() {
3846
+ return Array.from(projectModule().synthPresetNames());
3644
3847
  }
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;
3848
+ function synthPresetPatch(name) {
3849
+ return { ...projectModule().synthPresetPatch(name) };
3850
+ }
3851
+ function synthEnumTables() {
3852
+ return projectModule()._synthEnumTables();
3653
3853
  }
3654
3854
 
3855
+ // src/project_types.ts
3856
+ var EXPECTED_PROJECT_ABI_VERSION = 1;
3857
+ var MarkerKind = {
3858
+ marker: 0,
3859
+ text: 1,
3860
+ lyric: 2,
3861
+ cuePoint: 3,
3862
+ keySignature: 4
3863
+ };
3864
+ var SYNTH_ENGINE_MODES = [
3865
+ "default",
3866
+ "subtractive",
3867
+ "fm",
3868
+ "karplus-strong",
3869
+ "modal",
3870
+ "additive",
3871
+ "percussion",
3872
+ "piano",
3873
+ "pipe-organ",
3874
+ "bowed-string",
3875
+ "reed",
3876
+ "brass",
3877
+ "flute",
3878
+ "plucked-string",
3879
+ "vocal",
3880
+ "free-reed"
3881
+ ];
3882
+ var SYNTH_OSC_WAVEFORMS = [
3883
+ "default",
3884
+ "sine",
3885
+ "saw",
3886
+ "square",
3887
+ "triangle",
3888
+ "noise"
3889
+ ];
3890
+ var SYNTH_FILTER_MODELS = [
3891
+ "default",
3892
+ "svf",
3893
+ "moog-ladder",
3894
+ "diode-ladder",
3895
+ "sallen-key"
3896
+ ];
3897
+ var SYNTH_FILTER_OUTPUTS = ["default", "lowpass", "bandpass", "highpass"];
3898
+ var SYNTH_BODY_TYPES = [
3899
+ "default",
3900
+ "none",
3901
+ "guitar",
3902
+ "violin",
3903
+ "wood-tube",
3904
+ "brass-bell",
3905
+ "vocal"
3906
+ ];
3907
+ var SYNTH_MOD_SOURCES = [
3908
+ "none",
3909
+ "amp-env",
3910
+ "filter-env",
3911
+ "lfo1",
3912
+ "lfo2",
3913
+ "velocity",
3914
+ "key-track",
3915
+ "mod-wheel",
3916
+ "random"
3917
+ ];
3918
+ var SYNTH_MOD_DESTINATIONS = [
3919
+ "none",
3920
+ "pitch-cents",
3921
+ "cutoff-cents",
3922
+ "amp-gain",
3923
+ "pan-units"
3924
+ ];
3925
+
3655
3926
  // src/realtime_engine.ts
3656
3927
  var EXPECTED_ENGINE_ABI_VERSION = 3;
3657
3928
  function engineCapabilities() {
3658
- const abiVersion = getSonareModule().engineAbiVersion();
3929
+ const abiVersion2 = getSonareModule().engineAbiVersion();
3659
3930
  const sharedArrayBuffer = typeof globalThis.SharedArrayBuffer === "function";
3660
3931
  const atomics = typeof globalThis.Atomics === "object";
3661
3932
  const audioWorklet = typeof AudioWorkletNode !== "undefined" || typeof globalThis.AudioWorkletProcessor !== "undefined";
3662
3933
  return {
3663
- engineAbiVersion: abiVersion,
3934
+ engineAbiVersion: abiVersion2,
3664
3935
  expectedEngineAbiVersion: EXPECTED_ENGINE_ABI_VERSION,
3665
- abiCompatible: abiVersion === EXPECTED_ENGINE_ABI_VERSION,
3936
+ abiCompatible: abiVersion2 === EXPECTED_ENGINE_ABI_VERSION,
3666
3937
  sharedArrayBuffer,
3667
3938
  atomics,
3668
3939
  audioWorklet,
@@ -3696,6 +3967,14 @@ var RealtimeEngine = class {
3696
3967
  setParameterSmoothed(paramId, value, renderFrame = -1) {
3697
3968
  this.native.setParameterSmoothed(paramId, value, renderFrame);
3698
3969
  }
3970
+ /**
3971
+ * Set the default ramp time (ms) for engine-level smoothed parameters —
3972
+ * fader/pan glides, insert-parameter automation, and MIDI-CC mappings. The
3973
+ * default is 20 ms; pass `0` for instant (un-ramped) changes.
3974
+ */
3975
+ setParamSmoothingMs(smoothingMs) {
3976
+ this.native.setParamSmoothingMs(smoothingMs);
3977
+ }
3699
3978
  setSoloMute(laneIndex, solo, mute, renderFrame = -1) {
3700
3979
  this.native.setSoloMute(laneIndex, solo, mute, renderFrame);
3701
3980
  }
@@ -3781,6 +4060,35 @@ var RealtimeEngine = class {
3781
4060
  midiInputPendingCount() {
3782
4061
  return this.native.midiInputPendingCount();
3783
4062
  }
4063
+ /**
4064
+ * Route a destination's (track lane's) MIDI to the external output queue
4065
+ * instead of the internal instrument rack, so the track plays an external
4066
+ * device. Clearing it restores internal-synth playback.
4067
+ */
4068
+ setMidiDestinationExternal(destinationId, external) {
4069
+ this.native.setMidiDestinationExternal(destinationId, external);
4070
+ }
4071
+ /**
4072
+ * Enable/disable forwarding MIDI clock + transport (start/continue/stop) to
4073
+ * the external output queue so external gear tracks the transport tempo.
4074
+ */
4075
+ setExternalMidiClockEnabled(enabled) {
4076
+ this.native.setExternalMidiClockEnabled(enabled);
4077
+ }
4078
+ /** Count of external-MIDI events dropped because the output queue was full. */
4079
+ externalMidiDroppedCount() {
4080
+ return this.native.externalMidiDroppedCount();
4081
+ }
4082
+ /**
4083
+ * Drain queued external-MIDI events, already lowered to MIDI 1.0 byte
4084
+ * messages ready to write to a Web MIDI output port. Call once per audio
4085
+ * block / animation frame. `maxRecords` caps the number of output events
4086
+ * returned — the shared unit across every surface. Events past the cap stay
4087
+ * queued for the next call (lossless); call again to drain the rest.
4088
+ */
4089
+ drainExternalMidi(maxRecords = 1024) {
4090
+ return this.native.drainExternalMidi(maxRecords);
4091
+ }
3784
4092
  pushMidiInputNoteOn(group, channel, note, velocity, portTimeSamples = 0) {
3785
4093
  this.native.pushMidiInputNoteOn(group, channel, note, velocity, portTimeSamples);
3786
4094
  }
@@ -3805,6 +4113,15 @@ var RealtimeEngine = class {
3805
4113
  pushMidiCc(destinationId, group, channel, controller, value, renderFrame = -1) {
3806
4114
  this.native.pushMidiCc(destinationId, group, channel, controller, value, renderFrame);
3807
4115
  }
4116
+ /**
4117
+ * Queue an immediate (live) MIDI SysEx frame to a MIDI destination. `data` is
4118
+ * the full message including the leading 0xF0 and trailing 0xF7 (1..512
4119
+ * bytes). `renderFrame` is the frame to fire at, or -1 for immediate. Mirrors
4120
+ * the Node/Python/C-ABI `pushMidiSysex`.
4121
+ */
4122
+ pushMidiSysex(destinationId, data, renderFrame = -1) {
4123
+ this.native.pushMidiSysex(destinationId, data, renderFrame);
4124
+ }
3808
4125
  /**
3809
4126
  * Queue a MIDI panic (all-notes-off) releasing every sounding note at
3810
4127
  * `renderFrame` (-1 = immediate). Mirrors the C-ABI `pushMidiPanic`.
@@ -4023,6 +4340,30 @@ var RealtimeEngine = class {
4023
4340
  setMasterStripInsertParamByName(insertIndex, paramName, value) {
4024
4341
  this.native.setMasterStripInsertParamByName(insertIndex, paramName, value);
4025
4342
  }
4343
+ /** Bus-strip counterpart of {@link setTrackStripInsertParamByName}. */
4344
+ setBusStripInsertParamByName(busId, insertIndex, paramName, value) {
4345
+ this.native.setBusStripInsertParamByName(busId, insertIndex, paramName, value);
4346
+ }
4347
+ /** Bus-strip counterpart of {@link setTrackStripInsertBypassed}. */
4348
+ setBusStripInsertBypassed(busId, insertIndex, bypassed, resetOnBypass = false) {
4349
+ this.native.setBusStripInsertBypassed(busId, insertIndex, bypassed, resetOnBypass);
4350
+ }
4351
+ /**
4352
+ * Resolves a track-lane insert parameter (by its JSON-key name) to the
4353
+ * reserved automation id usable with `setAutomationLane` / `setParameter`.
4354
+ * Returns `-1` when the track, insert, or name is unknown. (The Python binding
4355
+ * raises a `SonareError` for an unknown id where Node/WASM return the `-1`
4356
+ * sentinel.)
4357
+ */
4358
+ resolveTrackInsertAutomationId(trackId, insertIndex, paramName) {
4359
+ return this.native.resolveTrackInsertAutomationId(trackId, insertIndex, paramName);
4360
+ }
4361
+ resolveMasterInsertAutomationId(insertIndex, paramName) {
4362
+ return this.native.resolveMasterInsertAutomationId(insertIndex, paramName);
4363
+ }
4364
+ resolveBusInsertAutomationId(busId, insertIndex, paramName) {
4365
+ return this.native.resolveBusInsertAutomationId(busId, insertIndex, paramName);
4366
+ }
4026
4367
  /** Sets a track lane strip's pan position in realtime (glitch-free). */
4027
4368
  setTrackStripPan(trackId, pan) {
4028
4369
  this.native.setTrackStripPan(trackId, pan);
@@ -4238,6 +4579,7 @@ var StreamAnalyzer = class {
4238
4579
  config.computeSpectral ?? defaults.computeSpectral,
4239
4580
  config.emitEveryNFrames ?? defaults.emitEveryNFrames,
4240
4581
  config.magnitudeDownsample ?? defaults.magnitudeDownsample,
4582
+ config.maxPendingFrames ?? defaults.maxPendingFrames,
4241
4583
  config.keyUpdateIntervalSec ?? defaults.keyUpdateIntervalSec,
4242
4584
  config.bpmUpdateIntervalSec ?? defaults.bpmUpdateIntervalSec,
4243
4585
  config.window ?? defaults.window,
@@ -4321,6 +4663,8 @@ var StreamAnalyzer = class {
4321
4663
  totalFrames: s.totalFrames,
4322
4664
  totalSamples: s.totalSamples,
4323
4665
  durationSeconds: s.durationSeconds,
4666
+ pendingFrames: s.pendingFrames,
4667
+ droppedOutputFrames: s.droppedOutputFrames,
4324
4668
  estimate: {
4325
4669
  bpm: s.estimate.bpm,
4326
4670
  bpmConfidence: s.estimate.bpmConfidence,
@@ -4682,6 +5026,12 @@ function version() {
4682
5026
  }
4683
5027
  return module.version();
4684
5028
  }
5029
+ function abiVersion() {
5030
+ if (!module) {
5031
+ throw new Error("Module not initialized. Call init() first.");
5032
+ }
5033
+ return module.abiVersion();
5034
+ }
4685
5035
  function engineAbiVersion() {
4686
5036
  if (!module) {
4687
5037
  throw new Error("Module not initialized. Call init() first.");
@@ -4727,6 +5077,7 @@ function realtimeVoiceChangerPresetConfig(preset) {
4727
5077
  export {
4728
5078
  Audio,
4729
5079
  ChordQuality,
5080
+ ClipPageStreamer,
4730
5081
  EXPECTED_ENGINE_ABI_VERSION,
4731
5082
  EXPECTED_PROJECT_ABI_VERSION,
4732
5083
  ErrorCode,
@@ -4752,6 +5103,7 @@ export {
4752
5103
  StreamingEqualizer,
4753
5104
  StreamingMasteringChain,
4754
5105
  StreamingRetune,
5106
+ abiVersion,
4755
5107
  amplitudeToDb,
4756
5108
  analyze,
4757
5109
  analyzeBpm,
@@ -4762,12 +5114,14 @@ export {
4762
5114
  analyzeSections,
4763
5115
  analyzeTimbre,
4764
5116
  analyzeWithProgress,
5117
+ attachOpfsClipStream,
4765
5118
  bassChroma,
4766
5119
  bindMicrophoneInput,
4767
5120
  bindWebMidi,
4768
5121
  chordFunctionalAnalysis,
4769
5122
  chroma,
4770
5123
  chromaCens,
5124
+ chromaCqt,
4771
5125
  cqt,
4772
5126
  createOpfsClipPageProvider,
4773
5127
  createOpfsClipPageWorker,
@@ -4886,6 +5240,7 @@ export {
4886
5240
  peakPick,
4887
5241
  percussive,
4888
5242
  phaseVocoder,
5243
+ pitchCorrectTimevarying,
4889
5244
  pitchCorrectToMidi,
4890
5245
  pitchCorrectToMidiTimevarying,
4891
5246
  pitchPyin,