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