@libraz/libsonare 1.2.1 → 1.2.3
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 +56 -4
- package/dist/index.d.ts +820 -296
- package/dist/index.js +770 -128
- package/dist/index.js.map +1 -1
- package/dist/sonare-rt.wasm +0 -0
- package/dist/sonare.js +1 -1
- package/dist/sonare.wasm +0 -0
- package/dist/worklet.d.ts +101 -3
- package/dist/worklet.js +706 -69
- package/dist/worklet.js.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +1764 -287
- package/src/public_types.ts +128 -0
- package/src/sonare.js.d.ts +580 -79
- package/src/stream_types.ts +4 -1
- package/src/worklet.ts +796 -66
- package/src/wasm_types.ts +0 -1259
package/dist/index.js
CHANGED
|
@@ -92,6 +92,21 @@ function panLawCode(panLaw) {
|
|
|
92
92
|
return 0;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
+
function panModeCode(panMode) {
|
|
96
|
+
if (typeof panMode === "number") {
|
|
97
|
+
return panMode;
|
|
98
|
+
}
|
|
99
|
+
switch (panMode) {
|
|
100
|
+
case "stereoPan":
|
|
101
|
+
case "stereo-pan":
|
|
102
|
+
return 1;
|
|
103
|
+
case "dualPan":
|
|
104
|
+
case "dual-pan":
|
|
105
|
+
return 2;
|
|
106
|
+
default:
|
|
107
|
+
return 0;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
95
110
|
function meterTapCode(tap) {
|
|
96
111
|
return tap === "preFader" || tap === 0 ? 0 : 1;
|
|
97
112
|
}
|
|
@@ -100,6 +115,31 @@ function sendTimingCode(timing) {
|
|
|
100
115
|
}
|
|
101
116
|
var module = null;
|
|
102
117
|
var initPromise = null;
|
|
118
|
+
function assertNonEmptySamples(fnName, samples, argName = "samples") {
|
|
119
|
+
if (samples.length === 0) {
|
|
120
|
+
throw new RangeError(`${fnName}: ${argName} must not be empty`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function assertFiniteSamples(fnName, samples, validate, argName = "samples") {
|
|
124
|
+
if (!validate) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
for (let i = 0; i < samples.length; i++) {
|
|
128
|
+
const v = samples[i];
|
|
129
|
+
if (!Number.isFinite(v)) {
|
|
130
|
+
throw new RangeError(`${fnName}: ${argName} contains NaN or Inf at index ${i}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function assertSamples(fnName, samples, validate, argName = "samples") {
|
|
135
|
+
assertNonEmptySamples(fnName, samples, argName);
|
|
136
|
+
assertFiniteSamples(fnName, samples, validate, argName);
|
|
137
|
+
}
|
|
138
|
+
function assertFiniteScalar(fnName, value, argName) {
|
|
139
|
+
if (!Number.isFinite(value)) {
|
|
140
|
+
throw new RangeError(`${fnName}: ${argName} must be a finite number`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
103
143
|
async function init(options) {
|
|
104
144
|
if (module) {
|
|
105
145
|
return;
|
|
@@ -133,6 +173,42 @@ function engineAbiVersion() {
|
|
|
133
173
|
}
|
|
134
174
|
return module.engineAbiVersion();
|
|
135
175
|
}
|
|
176
|
+
function voiceChangerAbiVersion() {
|
|
177
|
+
if (!module) {
|
|
178
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
179
|
+
}
|
|
180
|
+
return module.voiceChangerAbiVersion();
|
|
181
|
+
}
|
|
182
|
+
var VOICE_PRESET_ORDINALS = [
|
|
183
|
+
"neutral-monitor",
|
|
184
|
+
"bright-idol",
|
|
185
|
+
"soft-whisper",
|
|
186
|
+
"deep-narrator",
|
|
187
|
+
"robot-mascot",
|
|
188
|
+
"dark-villain"
|
|
189
|
+
];
|
|
190
|
+
function resolveVoicePresetOrdinal(preset) {
|
|
191
|
+
if (typeof preset === "number") {
|
|
192
|
+
return preset;
|
|
193
|
+
}
|
|
194
|
+
const ordinal = VOICE_PRESET_ORDINALS.indexOf(preset);
|
|
195
|
+
if (ordinal < 0) {
|
|
196
|
+
throw new Error(`Unknown voice character preset: ${preset}`);
|
|
197
|
+
}
|
|
198
|
+
return ordinal;
|
|
199
|
+
}
|
|
200
|
+
function voiceCharacterPresetId(preset) {
|
|
201
|
+
if (!module) {
|
|
202
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
203
|
+
}
|
|
204
|
+
return module.voiceCharacterPresetId(resolveVoicePresetOrdinal(preset));
|
|
205
|
+
}
|
|
206
|
+
function realtimeVoiceChangerPresetConfig(preset) {
|
|
207
|
+
if (!module) {
|
|
208
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
209
|
+
}
|
|
210
|
+
return module.realtimeVoiceChangerPresetConfig(resolveVoicePresetOrdinal(preset));
|
|
211
|
+
}
|
|
136
212
|
function engineCapabilities() {
|
|
137
213
|
const abiVersion = engineAbiVersion();
|
|
138
214
|
const sharedArrayBuffer = typeof globalThis.SharedArrayBuffer === "function";
|
|
@@ -283,6 +359,31 @@ var RealtimeEngine = class {
|
|
|
283
359
|
process(channels) {
|
|
284
360
|
return this.native.process(channels);
|
|
285
361
|
}
|
|
362
|
+
/**
|
|
363
|
+
* Allocates persistent per-channel WASM-heap scratch for the zero-copy
|
|
364
|
+
* `getChannelBuffer` / `processPrepared` realtime path. Call once (off the
|
|
365
|
+
* audio thread) before driving `processPrepared` from an AudioWorklet so the
|
|
366
|
+
* render callback never allocates on the C++/JS heap.
|
|
367
|
+
*/
|
|
368
|
+
prepareChannels(numChannels, maxFrames) {
|
|
369
|
+
this.native.prepareChannels(numChannels, maxFrames);
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Returns a Float32Array view onto the persistent WASM-heap scratch for one
|
|
373
|
+
* channel (valid for up to `numFrames`). Fill it, call `processPrepared`, then
|
|
374
|
+
* read the same view back. Re-acquire after WASM memory growth.
|
|
375
|
+
*/
|
|
376
|
+
getChannelBuffer(channel, numFrames) {
|
|
377
|
+
return this.native.getChannelBuffer(channel, numFrames);
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Runs the engine in place over the prepared per-channel scratch buffers.
|
|
381
|
+
* Allocation-free: safe to call on the AudioWorklet render thread after
|
|
382
|
+
* `prepareChannels`.
|
|
383
|
+
*/
|
|
384
|
+
processPrepared(numFrames) {
|
|
385
|
+
this.native.processPrepared(numFrames);
|
|
386
|
+
}
|
|
286
387
|
processWithMonitor(channels) {
|
|
287
388
|
return this.native.processWithMonitor(channels);
|
|
288
389
|
}
|
|
@@ -305,13 +406,13 @@ var RealtimeEngine = class {
|
|
|
305
406
|
this.native.delete();
|
|
306
407
|
}
|
|
307
408
|
};
|
|
308
|
-
function detectBpm(samples, sampleRate) {
|
|
409
|
+
function detectBpm(samples, sampleRate = 22050) {
|
|
309
410
|
if (!module) {
|
|
310
411
|
throw new Error("Module not initialized. Call init() first.");
|
|
311
412
|
}
|
|
312
413
|
return module.detectBpm(samples, sampleRate);
|
|
313
414
|
}
|
|
314
|
-
function detectKey(samples, sampleRate, options = {}) {
|
|
415
|
+
function detectKey(samples, sampleRate = 22050, options = {}) {
|
|
315
416
|
if (!module) {
|
|
316
417
|
throw new Error("Module not initialized. Call init() first.");
|
|
317
418
|
}
|
|
@@ -400,7 +501,7 @@ function keyProfileValue(profile) {
|
|
|
400
501
|
};
|
|
401
502
|
return names[profile];
|
|
402
503
|
}
|
|
403
|
-
function detectKeyCandidates(samples, sampleRate, options = {}) {
|
|
504
|
+
function detectKeyCandidates(samples, sampleRate = 22050, options = {}) {
|
|
404
505
|
if (!module) {
|
|
405
506
|
throw new Error("Module not initialized. Call init() first.");
|
|
406
507
|
}
|
|
@@ -417,19 +518,19 @@ function detectKeyCandidates(samples, sampleRate, options = {}) {
|
|
|
417
518
|
options.genreHint ?? ""
|
|
418
519
|
).map(convertKeyCandidate);
|
|
419
520
|
}
|
|
420
|
-
function detectOnsets(samples, sampleRate) {
|
|
521
|
+
function detectOnsets(samples, sampleRate = 22050) {
|
|
421
522
|
if (!module) {
|
|
422
523
|
throw new Error("Module not initialized. Call init() first.");
|
|
423
524
|
}
|
|
424
525
|
return module.detectOnsets(samples, sampleRate);
|
|
425
526
|
}
|
|
426
|
-
function detectBeats(samples, sampleRate) {
|
|
527
|
+
function detectBeats(samples, sampleRate = 22050) {
|
|
427
528
|
if (!module) {
|
|
428
529
|
throw new Error("Module not initialized. Call init() first.");
|
|
429
530
|
}
|
|
430
531
|
return module.detectBeats(samples, sampleRate);
|
|
431
532
|
}
|
|
432
|
-
function detectDownbeats(samples, sampleRate) {
|
|
533
|
+
function detectDownbeats(samples, sampleRate = 22050) {
|
|
433
534
|
if (!module) {
|
|
434
535
|
throw new Error("Module not initialized. Call init() first.");
|
|
435
536
|
}
|
|
@@ -448,7 +549,7 @@ function convertChordAnalysisResult(wasm) {
|
|
|
448
549
|
}))
|
|
449
550
|
};
|
|
450
551
|
}
|
|
451
|
-
function detectChords(samples, sampleRate, options = {}) {
|
|
552
|
+
function detectChords(samples, sampleRate = 22050, options = {}) {
|
|
452
553
|
if (!module) {
|
|
453
554
|
throw new Error("Module not initialized. Call init() first.");
|
|
454
555
|
}
|
|
@@ -522,14 +623,14 @@ function convertAnalysisResult(wasm) {
|
|
|
522
623
|
form: wasm.form
|
|
523
624
|
};
|
|
524
625
|
}
|
|
525
|
-
function analyze(samples, sampleRate) {
|
|
626
|
+
function analyze(samples, sampleRate = 22050) {
|
|
526
627
|
if (!module) {
|
|
527
628
|
throw new Error("Module not initialized. Call init() first.");
|
|
528
629
|
}
|
|
529
630
|
const result = module.analyze(samples, sampleRate);
|
|
530
631
|
return convertAnalysisResult(result);
|
|
531
632
|
}
|
|
532
|
-
function analyzeImpulseResponse(samples, sampleRate, nOctaveBands = 6) {
|
|
633
|
+
function analyzeImpulseResponse(samples, sampleRate = 48e3, nOctaveBands = 6) {
|
|
533
634
|
if (!module) {
|
|
534
635
|
throw new Error("Module not initialized. Call init() first.");
|
|
535
636
|
}
|
|
@@ -540,7 +641,7 @@ function analyzeImpulseResponse(samples, sampleRate, nOctaveBands = 6) {
|
|
|
540
641
|
);
|
|
541
642
|
return result;
|
|
542
643
|
}
|
|
543
|
-
function detectAcoustic(samples, sampleRate, nOctaveBands = 6, nThirdOctaveSubbands = 24, minDecayDb = 30, noiseFloorMarginDb = 10) {
|
|
644
|
+
function detectAcoustic(samples, sampleRate = 48e3, nOctaveBands = 6, nThirdOctaveSubbands = 24, minDecayDb = 30, noiseFloorMarginDb = 10) {
|
|
544
645
|
if (!module) {
|
|
545
646
|
throw new Error("Module not initialized. Call init() first.");
|
|
546
647
|
}
|
|
@@ -554,68 +655,174 @@ function detectAcoustic(samples, sampleRate, nOctaveBands = 6, nThirdOctaveSubba
|
|
|
554
655
|
);
|
|
555
656
|
return result;
|
|
556
657
|
}
|
|
557
|
-
function
|
|
658
|
+
function synthesizeRir(options = {}) {
|
|
659
|
+
if (!module) {
|
|
660
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
661
|
+
}
|
|
662
|
+
if (typeof module.synthesizeRir !== "function") {
|
|
663
|
+
throw new Error("libsonare was built without acoustic-simulation support");
|
|
664
|
+
}
|
|
665
|
+
return module.synthesizeRir(options);
|
|
666
|
+
}
|
|
667
|
+
function estimateRoom(samples, sampleRate = 48e3, options = {}) {
|
|
668
|
+
if (!module) {
|
|
669
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
670
|
+
}
|
|
671
|
+
if (typeof module.estimateRoom !== "function") {
|
|
672
|
+
throw new Error("libsonare was built without acoustic-simulation support");
|
|
673
|
+
}
|
|
674
|
+
return module.estimateRoom(samples, sampleRate, options);
|
|
675
|
+
}
|
|
676
|
+
function roomMorph(samples, sampleRate, options = {}) {
|
|
677
|
+
if (!module) {
|
|
678
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
679
|
+
}
|
|
680
|
+
if (typeof module.roomMorph !== "function") {
|
|
681
|
+
throw new Error("libsonare was built without acoustic-simulation support");
|
|
682
|
+
}
|
|
683
|
+
return module.roomMorph(samples, sampleRate, options);
|
|
684
|
+
}
|
|
685
|
+
function analyzeWithProgress(samples, sampleRate = 22050, onProgress) {
|
|
558
686
|
if (!module) {
|
|
559
687
|
throw new Error("Module not initialized. Call init() first.");
|
|
560
688
|
}
|
|
561
689
|
const result = module.analyzeWithProgress(samples, sampleRate, onProgress);
|
|
562
690
|
return convertAnalysisResult(result);
|
|
563
691
|
}
|
|
564
|
-
function
|
|
692
|
+
function analyzeBpm(samples, sampleRate = 22050, bpmMin = 30, bpmMax = 300, startBpm = 120, nFft = 2048, hopLength = 512, maxCandidates = 5) {
|
|
693
|
+
if (!module) {
|
|
694
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
695
|
+
}
|
|
696
|
+
return module.analyzeBpm(
|
|
697
|
+
samples,
|
|
698
|
+
sampleRate,
|
|
699
|
+
bpmMin,
|
|
700
|
+
bpmMax,
|
|
701
|
+
startBpm,
|
|
702
|
+
nFft,
|
|
703
|
+
hopLength,
|
|
704
|
+
maxCandidates
|
|
705
|
+
);
|
|
706
|
+
}
|
|
707
|
+
function analyzeRhythm(samples, sampleRate = 22050, bpmMin = 60, bpmMax = 200, startBpm = 120, nFft = 2048, hopLength = 512) {
|
|
708
|
+
if (!module) {
|
|
709
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
710
|
+
}
|
|
711
|
+
return module.analyzeRhythm(samples, sampleRate, bpmMin, bpmMax, startBpm, nFft, hopLength);
|
|
712
|
+
}
|
|
713
|
+
function analyzeDynamics(samples, sampleRate = 22050, windowSec = 0.4, hopLength = 512, compressionThreshold = 6) {
|
|
714
|
+
if (!module) {
|
|
715
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
716
|
+
}
|
|
717
|
+
return module.analyzeDynamics(samples, sampleRate, windowSec, hopLength, compressionThreshold);
|
|
718
|
+
}
|
|
719
|
+
function analyzeTimbre(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, nMels = 128, nMfcc = 13, windowSec = 0.5) {
|
|
720
|
+
if (!module) {
|
|
721
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
722
|
+
}
|
|
723
|
+
return module.analyzeTimbre(samples, sampleRate, nFft, hopLength, nMels, nMfcc, windowSec);
|
|
724
|
+
}
|
|
725
|
+
function hasFfmpegSupport() {
|
|
726
|
+
if (!module) {
|
|
727
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
728
|
+
}
|
|
729
|
+
return module.hasFfmpegSupport();
|
|
730
|
+
}
|
|
731
|
+
function hpss(samples, sampleRate = 22050, kernelHarmonic = 31, kernelPercussive = 31) {
|
|
565
732
|
if (!module) {
|
|
566
733
|
throw new Error("Module not initialized. Call init() first.");
|
|
567
734
|
}
|
|
568
735
|
return module.hpss(samples, sampleRate, kernelHarmonic, kernelPercussive);
|
|
569
736
|
}
|
|
570
|
-
function harmonic(samples, sampleRate) {
|
|
737
|
+
function harmonic(samples, sampleRate, options = {}) {
|
|
571
738
|
if (!module) {
|
|
572
739
|
throw new Error("Module not initialized. Call init() first.");
|
|
573
740
|
}
|
|
741
|
+
assertSamples("harmonic", samples, options.validate !== false);
|
|
574
742
|
return module.harmonic(samples, sampleRate);
|
|
575
743
|
}
|
|
576
|
-
function percussive(samples, sampleRate) {
|
|
744
|
+
function percussive(samples, sampleRate, options = {}) {
|
|
577
745
|
if (!module) {
|
|
578
746
|
throw new Error("Module not initialized. Call init() first.");
|
|
579
747
|
}
|
|
748
|
+
assertSamples("percussive", samples, options.validate !== false);
|
|
580
749
|
return module.percussive(samples, sampleRate);
|
|
581
750
|
}
|
|
582
|
-
function timeStretch(samples, sampleRate, rate) {
|
|
751
|
+
function timeStretch(samples, sampleRate, rate, options = {}) {
|
|
583
752
|
if (!module) {
|
|
584
753
|
throw new Error("Module not initialized. Call init() first.");
|
|
585
754
|
}
|
|
755
|
+
assertSamples("timeStretch", samples, options.validate !== false);
|
|
586
756
|
return module.timeStretch(samples, sampleRate, rate);
|
|
587
757
|
}
|
|
588
|
-
function pitchShift(samples, sampleRate, semitones) {
|
|
758
|
+
function pitchShift(samples, sampleRate, semitones, options = {}) {
|
|
589
759
|
if (!module) {
|
|
590
760
|
throw new Error("Module not initialized. Call init() first.");
|
|
591
761
|
}
|
|
762
|
+
assertSamples("pitchShift", samples, options.validate !== false);
|
|
592
763
|
return module.pitchShift(samples, sampleRate, semitones);
|
|
593
764
|
}
|
|
594
|
-
function pitchCorrectToMidi(samples, sampleRate, currentMidi, targetMidi) {
|
|
765
|
+
function pitchCorrectToMidi(samples, sampleRate = 22050, currentMidi = 69, targetMidi = 69, options = {}) {
|
|
595
766
|
if (!module) {
|
|
596
767
|
throw new Error("Module not initialized. Call init() first.");
|
|
597
768
|
}
|
|
769
|
+
assertSamples("pitchCorrectToMidi", samples, options.validate !== false);
|
|
598
770
|
return module.pitchCorrectToMidi(samples, sampleRate, currentMidi, targetMidi);
|
|
599
771
|
}
|
|
600
|
-
function noteStretch(samples, sampleRate, onsetSample, offsetSample, stretchRatio) {
|
|
772
|
+
function noteStretch(samples, sampleRate = 22050, onsetSample = 0, offsetSample = 0, stretchRatio = 1, options = {}) {
|
|
601
773
|
if (!module) {
|
|
602
774
|
throw new Error("Module not initialized. Call init() first.");
|
|
603
775
|
}
|
|
776
|
+
assertSamples("noteStretch", samples, options.validate !== false);
|
|
604
777
|
return module.noteStretch(samples, sampleRate, onsetSample, offsetSample, stretchRatio);
|
|
605
778
|
}
|
|
606
|
-
function voiceChange(samples, sampleRate, pitchSemitones, formantFactor) {
|
|
779
|
+
function voiceChange(samples, sampleRate = 22050, pitchSemitones = 0, formantFactor = 1, options = {}) {
|
|
607
780
|
if (!module) {
|
|
608
781
|
throw new Error("Module not initialized. Call init() first.");
|
|
609
782
|
}
|
|
783
|
+
assertSamples("voiceChange", samples, options.validate !== false);
|
|
610
784
|
return module.voiceChange(samples, sampleRate, pitchSemitones, formantFactor);
|
|
611
785
|
}
|
|
612
|
-
function
|
|
786
|
+
function voiceChangeRealtime(samples, options = {}) {
|
|
787
|
+
if (!module) {
|
|
788
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
789
|
+
}
|
|
790
|
+
assertSamples("voiceChangeRealtime", samples, options.validate !== false);
|
|
791
|
+
const channels = options.channels ?? 1;
|
|
792
|
+
if (channels !== 1 && channels !== 2) {
|
|
793
|
+
throw new Error("voiceChangeRealtime: channels must be 1 or 2.");
|
|
794
|
+
}
|
|
795
|
+
const sampleRate = options.sampleRate ?? 48e3;
|
|
796
|
+
const blockSize = Math.max(1, Math.floor(options.blockSize ?? 512));
|
|
797
|
+
const changer = new RealtimeVoiceChanger(options.preset ?? "neutral-monitor");
|
|
798
|
+
try {
|
|
799
|
+
changer.prepare(sampleRate, blockSize, channels);
|
|
800
|
+
const out = new Float32Array(samples.length);
|
|
801
|
+
if (channels === 1) {
|
|
802
|
+
for (let offset = 0; offset < samples.length; offset += blockSize) {
|
|
803
|
+
const block = samples.subarray(offset, Math.min(offset + blockSize, samples.length));
|
|
804
|
+
out.set(changer.processMono(block), offset);
|
|
805
|
+
}
|
|
806
|
+
} else {
|
|
807
|
+
const frameStride = blockSize * 2;
|
|
808
|
+
for (let offset = 0; offset < samples.length; offset += frameStride) {
|
|
809
|
+
const block = samples.subarray(offset, Math.min(offset + frameStride, samples.length));
|
|
810
|
+
out.set(changer.processInterleaved(block, 2), offset);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
return out;
|
|
814
|
+
} finally {
|
|
815
|
+
changer.delete();
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
function normalize(samples, sampleRate, targetDb = 0, options = {}) {
|
|
613
819
|
if (!module) {
|
|
614
820
|
throw new Error("Module not initialized. Call init() first.");
|
|
615
821
|
}
|
|
822
|
+
assertSamples("normalize", samples, options.validate !== false);
|
|
616
823
|
return module.normalize(samples, sampleRate, targetDb);
|
|
617
824
|
}
|
|
618
|
-
function mastering(samples, sampleRate, targetLufs = -14, ceilingDb = -1, truePeakOversample = 4) {
|
|
825
|
+
function mastering(samples, sampleRate = 22050, targetLufs = -14, ceilingDb = -1, truePeakOversample = 4) {
|
|
619
826
|
if (!module) {
|
|
620
827
|
throw new Error("Module not initialized. Call init() first.");
|
|
621
828
|
}
|
|
@@ -645,13 +852,13 @@ function masteringStereoAnalysisNames() {
|
|
|
645
852
|
}
|
|
646
853
|
return module.masteringStereoAnalysisNames();
|
|
647
854
|
}
|
|
648
|
-
function masteringProcess(processorName, samples, sampleRate, params = {}) {
|
|
855
|
+
function masteringProcess(processorName, samples, sampleRate = 22050, params = {}) {
|
|
649
856
|
if (!module) {
|
|
650
857
|
throw new Error("Module not initialized. Call init() first.");
|
|
651
858
|
}
|
|
652
859
|
return module.masteringProcess(processorName, samples, sampleRate, params);
|
|
653
860
|
}
|
|
654
|
-
function masteringProcessStereo(processorName, left, right, sampleRate, params = {}) {
|
|
861
|
+
function masteringProcessStereo(processorName, left, right, sampleRate = 22050, params = {}) {
|
|
655
862
|
if (!module) {
|
|
656
863
|
throw new Error("Module not initialized. Call init() first.");
|
|
657
864
|
}
|
|
@@ -660,49 +867,92 @@ function masteringProcessStereo(processorName, left, right, sampleRate, params =
|
|
|
660
867
|
}
|
|
661
868
|
return module.masteringProcessStereo(processorName, left, right, sampleRate, params);
|
|
662
869
|
}
|
|
663
|
-
function masteringPairProcess(processorName, source, reference, sampleRate, params = {}) {
|
|
870
|
+
function masteringPairProcess(processorName, source, reference, sampleRate = 22050, params = {}) {
|
|
664
871
|
if (!module) {
|
|
665
872
|
throw new Error("Module not initialized. Call init() first.");
|
|
666
873
|
}
|
|
667
874
|
return module.masteringPairProcess(processorName, source, reference, sampleRate, params);
|
|
668
875
|
}
|
|
669
|
-
function masteringPairAnalyze(analysisName, source, reference, sampleRate, params = {}) {
|
|
876
|
+
function masteringPairAnalyze(analysisName, source, reference, sampleRate = 22050, params = {}) {
|
|
670
877
|
if (!module) {
|
|
671
878
|
throw new Error("Module not initialized. Call init() first.");
|
|
672
879
|
}
|
|
673
880
|
return module.masteringPairAnalyze(analysisName, source, reference, sampleRate, params);
|
|
674
881
|
}
|
|
675
|
-
function masteringStereoAnalyze(analysisName, left, right, sampleRate, params = {}) {
|
|
882
|
+
function masteringStereoAnalyze(analysisName, left, right, sampleRate = 22050, params = {}) {
|
|
676
883
|
if (!module) {
|
|
677
884
|
throw new Error("Module not initialized. Call init() first.");
|
|
678
885
|
}
|
|
679
886
|
return module.masteringStereoAnalyze(analysisName, left, right, sampleRate, params);
|
|
680
887
|
}
|
|
681
|
-
function masteringAssistantSuggest(samples, sampleRate, params = {}) {
|
|
888
|
+
function masteringAssistantSuggest(samples, sampleRate = 22050, params = {}) {
|
|
682
889
|
if (!module) {
|
|
683
890
|
throw new Error("Module not initialized. Call init() first.");
|
|
684
891
|
}
|
|
685
892
|
return module.masteringAssistantSuggest(samples, sampleRate, params);
|
|
686
893
|
}
|
|
687
|
-
function masteringAudioProfile(samples, sampleRate, params = {}) {
|
|
894
|
+
function masteringAudioProfile(samples, sampleRate = 22050, params = {}) {
|
|
688
895
|
if (!module) {
|
|
689
896
|
throw new Error("Module not initialized. Call init() first.");
|
|
690
897
|
}
|
|
691
898
|
return module.masteringAudioProfile(samples, sampleRate, params);
|
|
692
899
|
}
|
|
693
|
-
function masteringStreamingPreview(samples, sampleRate, platforms = []) {
|
|
900
|
+
function masteringStreamingPreview(samples, sampleRate = 22050, platforms = []) {
|
|
694
901
|
if (!module) {
|
|
695
902
|
throw new Error("Module not initialized. Call init() first.");
|
|
696
903
|
}
|
|
697
904
|
return module.masteringStreamingPreview(samples, sampleRate, platforms);
|
|
698
905
|
}
|
|
699
|
-
function
|
|
906
|
+
function masteringRepairDeclick(samples, sampleRate, options = {}) {
|
|
907
|
+
return requireModule().masteringRepairDeclick(samples, sampleRate, options);
|
|
908
|
+
}
|
|
909
|
+
function masteringRepairDenoiseClassical(samples, sampleRate, options = {}) {
|
|
910
|
+
return requireModule().masteringRepairDenoiseClassical(samples, sampleRate, options);
|
|
911
|
+
}
|
|
912
|
+
function masteringRepairDeclip(samples, sampleRate, options = {}) {
|
|
913
|
+
return requireModule().masteringRepairDeclip(samples, sampleRate, options);
|
|
914
|
+
}
|
|
915
|
+
function masteringRepairDecrackle(samples, sampleRate, options = {}) {
|
|
916
|
+
return requireModule().masteringRepairDecrackle(samples, sampleRate, options);
|
|
917
|
+
}
|
|
918
|
+
function masteringRepairDehum(samples, sampleRate, options = {}) {
|
|
919
|
+
return requireModule().masteringRepairDehum(samples, sampleRate, options);
|
|
920
|
+
}
|
|
921
|
+
function masteringRepairDereverbClassical(samples, sampleRate, options = {}) {
|
|
922
|
+
return requireModule().masteringRepairDereverbClassical(samples, sampleRate, options);
|
|
923
|
+
}
|
|
924
|
+
function masteringRepairTrimSilence(samples, sampleRate, options = {}) {
|
|
925
|
+
return requireModule().masteringRepairTrimSilence(samples, sampleRate, options);
|
|
926
|
+
}
|
|
927
|
+
var COMPRESSOR_DETECTOR_MAP = {
|
|
928
|
+
peak: 0,
|
|
929
|
+
rms: 1,
|
|
930
|
+
log_rms: 2
|
|
931
|
+
};
|
|
932
|
+
function masteringDynamicsCompressor(samples, sampleRate, options = {}) {
|
|
933
|
+
assertSamples("masteringDynamicsCompressor", samples, options.validate !== false);
|
|
934
|
+
const detector = typeof options.detector === "string" ? COMPRESSOR_DETECTOR_MAP[options.detector] : options.detector;
|
|
935
|
+
const opts = { ...options };
|
|
936
|
+
if (detector !== void 0) {
|
|
937
|
+
opts.detector = detector;
|
|
938
|
+
}
|
|
939
|
+
return requireModule().masteringDynamicsCompressor(samples, sampleRate, opts);
|
|
940
|
+
}
|
|
941
|
+
function masteringDynamicsGate(samples, sampleRate, options = {}) {
|
|
942
|
+
assertSamples("masteringDynamicsGate", samples, options.validate !== false);
|
|
943
|
+
return requireModule().masteringDynamicsGate(samples, sampleRate, options);
|
|
944
|
+
}
|
|
945
|
+
function masteringDynamicsTransientShaper(samples, sampleRate, options = {}) {
|
|
946
|
+
assertSamples("masteringDynamicsTransientShaper", samples, options.validate !== false);
|
|
947
|
+
return requireModule().masteringDynamicsTransientShaper(samples, sampleRate, options);
|
|
948
|
+
}
|
|
949
|
+
function masteringChain(samples, sampleRate = 22050, config) {
|
|
700
950
|
if (!module) {
|
|
701
951
|
throw new Error("Module not initialized. Call init() first.");
|
|
702
952
|
}
|
|
703
953
|
return module.masteringChain(samples, sampleRate, config);
|
|
704
954
|
}
|
|
705
|
-
function masteringChainStereo(left, right, sampleRate, config) {
|
|
955
|
+
function masteringChainStereo(left, right, sampleRate = 22050, config) {
|
|
706
956
|
if (!module) {
|
|
707
957
|
throw new Error("Module not initialized. Call init() first.");
|
|
708
958
|
}
|
|
@@ -711,7 +961,7 @@ function masteringChainStereo(left, right, sampleRate, config) {
|
|
|
711
961
|
}
|
|
712
962
|
return module.masteringChainStereo(left, right, sampleRate, config);
|
|
713
963
|
}
|
|
714
|
-
function masteringChainWithProgress(samples, sampleRate, config, onProgress) {
|
|
964
|
+
function masteringChainWithProgress(samples, sampleRate = 22050, config, onProgress) {
|
|
715
965
|
if (!module) {
|
|
716
966
|
throw new Error("Module not initialized. Call init() first.");
|
|
717
967
|
}
|
|
@@ -722,7 +972,7 @@ function masteringChainWithProgress(samples, sampleRate, config, onProgress) {
|
|
|
722
972
|
onProgress
|
|
723
973
|
);
|
|
724
974
|
}
|
|
725
|
-
function masteringChainStereoWithProgress(left, right, sampleRate, config, onProgress) {
|
|
975
|
+
function masteringChainStereoWithProgress(left, right, sampleRate = 22050, config, onProgress) {
|
|
726
976
|
if (!module) {
|
|
727
977
|
throw new Error("Module not initialized. Call init() first.");
|
|
728
978
|
}
|
|
@@ -743,13 +993,13 @@ function masteringPresetNames() {
|
|
|
743
993
|
}
|
|
744
994
|
return module.masteringPresetNames();
|
|
745
995
|
}
|
|
746
|
-
function masterAudio(samples, sampleRate, presetName, overrides = null) {
|
|
996
|
+
function masterAudio(samples, sampleRate = 22050, presetName, overrides = null) {
|
|
747
997
|
if (!module) {
|
|
748
998
|
throw new Error("Module not initialized. Call init() first.");
|
|
749
999
|
}
|
|
750
1000
|
return module.masterAudio(presetName, samples, sampleRate, overrides);
|
|
751
1001
|
}
|
|
752
|
-
function masterAudioStereo(left, right, sampleRate, presetName, overrides = null) {
|
|
1002
|
+
function masterAudioStereo(left, right, sampleRate = 22050, presetName, overrides = null) {
|
|
753
1003
|
if (!module) {
|
|
754
1004
|
throw new Error("Module not initialized. Call init() first.");
|
|
755
1005
|
}
|
|
@@ -758,17 +1008,39 @@ function masterAudioStereo(left, right, sampleRate, presetName, overrides = null
|
|
|
758
1008
|
}
|
|
759
1009
|
return module.masterAudioStereo(presetName, left, right, sampleRate, overrides);
|
|
760
1010
|
}
|
|
1011
|
+
function masterAudioWithProgress(samples, sampleRate = 22050, presetName, onProgress, overrides = null) {
|
|
1012
|
+
if (!module) {
|
|
1013
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
1014
|
+
}
|
|
1015
|
+
return module.masterAudioWithProgress(presetName, samples, sampleRate, overrides, onProgress);
|
|
1016
|
+
}
|
|
1017
|
+
function masterAudioStereoWithProgress(left, right, sampleRate = 22050, presetName, onProgress, overrides = null) {
|
|
1018
|
+
if (!module) {
|
|
1019
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
1020
|
+
}
|
|
1021
|
+
if (left.length !== right.length) {
|
|
1022
|
+
throw new Error("Stereo channel lengths must match.");
|
|
1023
|
+
}
|
|
1024
|
+
return module.masterAudioStereoWithProgress(
|
|
1025
|
+
presetName,
|
|
1026
|
+
left,
|
|
1027
|
+
right,
|
|
1028
|
+
sampleRate,
|
|
1029
|
+
overrides,
|
|
1030
|
+
onProgress
|
|
1031
|
+
);
|
|
1032
|
+
}
|
|
761
1033
|
function mixingScenePresetNames() {
|
|
762
1034
|
if (!module) {
|
|
763
1035
|
throw new Error("Module not initialized. Call init() first.");
|
|
764
1036
|
}
|
|
765
1037
|
return module.mixingScenePresetNames();
|
|
766
1038
|
}
|
|
767
|
-
function mixingScenePresetJson(
|
|
1039
|
+
function mixingScenePresetJson(presetName) {
|
|
768
1040
|
if (!module) {
|
|
769
1041
|
throw new Error("Module not initialized. Call init() first.");
|
|
770
1042
|
}
|
|
771
|
-
return module.mixingScenePresetJson(
|
|
1043
|
+
return module.mixingScenePresetJson(presetName);
|
|
772
1044
|
}
|
|
773
1045
|
function mixStereo(leftChannels, rightChannels, sampleRate = 48e3, options = {}) {
|
|
774
1046
|
if (!module) {
|
|
@@ -979,11 +1251,158 @@ var StreamingRetune = class {
|
|
|
979
1251
|
this.retune.delete();
|
|
980
1252
|
}
|
|
981
1253
|
};
|
|
982
|
-
|
|
1254
|
+
var RealtimeVoiceChanger = class {
|
|
1255
|
+
constructor(config = "neutral-monitor") {
|
|
1256
|
+
if (!module) {
|
|
1257
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
1258
|
+
}
|
|
1259
|
+
this.changer = module.createRealtimeVoiceChanger(config);
|
|
1260
|
+
}
|
|
1261
|
+
prepare(sampleRate, maxBlockSize = 128, channels = 1) {
|
|
1262
|
+
this.changer.prepare(sampleRate, maxBlockSize, channels);
|
|
1263
|
+
}
|
|
1264
|
+
reset() {
|
|
1265
|
+
this.changer.reset();
|
|
1266
|
+
}
|
|
1267
|
+
setConfig(config) {
|
|
1268
|
+
this.changer.setConfig(config);
|
|
1269
|
+
}
|
|
1270
|
+
configJson() {
|
|
1271
|
+
return this.changer.configJson();
|
|
1272
|
+
}
|
|
1273
|
+
latencySamples() {
|
|
1274
|
+
return this.changer.latencySamples();
|
|
1275
|
+
}
|
|
1276
|
+
processMono(samples) {
|
|
1277
|
+
return this.changer.processMono(samples);
|
|
1278
|
+
}
|
|
1279
|
+
processMonoInto(samples, output) {
|
|
1280
|
+
this.changer.processMonoInto(samples, output);
|
|
1281
|
+
}
|
|
1282
|
+
processInterleaved(samples, channels) {
|
|
1283
|
+
return this.changer.processInterleaved(samples, channels);
|
|
1284
|
+
}
|
|
1285
|
+
processInterleavedInto(samples, channels, output) {
|
|
1286
|
+
this.changer.processInterleavedInto(samples, channels, output);
|
|
1287
|
+
}
|
|
1288
|
+
/**
|
|
1289
|
+
* Acquire a typed-memory view onto the WASM heap for mono input.
|
|
1290
|
+
*
|
|
1291
|
+
* Write your input samples into the returned `Float32Array` directly (e.g.
|
|
1292
|
+
* via `input.set(source)`); no copy crosses the JS↔C++ bridge until
|
|
1293
|
+
* {@link processPreparedMono} is called. The view is owned by this
|
|
1294
|
+
* RealtimeVoiceChanger and becomes invalid after {@link delete}; it may
|
|
1295
|
+
* also be invalidated if you later call this method with a larger
|
|
1296
|
+
* `numSamples` value (the underlying buffer may be reallocated).
|
|
1297
|
+
*/
|
|
1298
|
+
getMonoInputBuffer(numSamples) {
|
|
1299
|
+
return this.changer.getMonoInputBuffer(numSamples);
|
|
1300
|
+
}
|
|
1301
|
+
/** Mono output view counterpart to {@link getMonoInputBuffer}. */
|
|
1302
|
+
getMonoOutputBuffer(numSamples) {
|
|
1303
|
+
return this.changer.getMonoOutputBuffer(numSamples);
|
|
1304
|
+
}
|
|
1305
|
+
/**
|
|
1306
|
+
* Process the previously-acquired mono input buffer in place. The output
|
|
1307
|
+
* appears in the buffer returned by {@link getMonoOutputBuffer}. No JS↔C++
|
|
1308
|
+
* sample-level crossings happen on this call — it just hands control to
|
|
1309
|
+
* the underlying DSP on already-on-heap data.
|
|
1310
|
+
*/
|
|
1311
|
+
processPreparedMono(numSamples) {
|
|
1312
|
+
this.changer.processPreparedMono(numSamples);
|
|
1313
|
+
}
|
|
1314
|
+
/** Interleaved input view (layout L0,R0,L1,R1,...). */
|
|
1315
|
+
getInterleavedInputBuffer(numFrames, numChannels) {
|
|
1316
|
+
return this.changer.getInterleavedInputBuffer(numFrames, numChannels);
|
|
1317
|
+
}
|
|
1318
|
+
/** Interleaved output view counterpart. */
|
|
1319
|
+
getInterleavedOutputBuffer(numFrames, numChannels) {
|
|
1320
|
+
return this.changer.getInterleavedOutputBuffer(numFrames, numChannels);
|
|
1321
|
+
}
|
|
1322
|
+
/**
|
|
1323
|
+
* Process the previously-acquired interleaved buffer in place. Output
|
|
1324
|
+
* appears in the buffer returned by {@link getInterleavedOutputBuffer}.
|
|
1325
|
+
*/
|
|
1326
|
+
processPreparedInterleaved(numFrames, numChannels) {
|
|
1327
|
+
this.changer.processPreparedInterleaved(numFrames, numChannels);
|
|
1328
|
+
}
|
|
1329
|
+
/**
|
|
1330
|
+
* Planar-channel input/output view (one Float32Array per channel). Matches
|
|
1331
|
+
* AudioWorklet's native layout; processing happens in place.
|
|
1332
|
+
*/
|
|
1333
|
+
getPlanarChannelBuffer(channel, numFrames) {
|
|
1334
|
+
return this.changer.getPlanarChannelBuffer(channel, numFrames);
|
|
1335
|
+
}
|
|
1336
|
+
/**
|
|
1337
|
+
* Process the previously-acquired planar channel buffers in place. Each
|
|
1338
|
+
* channel must have been obtained from {@link getPlanarChannelBuffer}
|
|
1339
|
+
* with the same `numFrames`. Output replaces input in the same buffers.
|
|
1340
|
+
*/
|
|
1341
|
+
processPreparedPlanar(numFrames) {
|
|
1342
|
+
this.changer.processPreparedPlanar(numFrames);
|
|
1343
|
+
}
|
|
1344
|
+
/**
|
|
1345
|
+
* Convenience factory for the mono zero-copy path: returns the input/output
|
|
1346
|
+
* heap views plus a `process()` thunk wired to the same `numSamples`. The
|
|
1347
|
+
* views are reused across calls and become invalid after {@link delete}.
|
|
1348
|
+
*/
|
|
1349
|
+
createRealtimeMonoBuffer(numSamples) {
|
|
1350
|
+
const input = this.getMonoInputBuffer(numSamples);
|
|
1351
|
+
const output = this.getMonoOutputBuffer(numSamples);
|
|
1352
|
+
return {
|
|
1353
|
+
input,
|
|
1354
|
+
output,
|
|
1355
|
+
process: () => this.processPreparedMono(numSamples)
|
|
1356
|
+
};
|
|
1357
|
+
}
|
|
1358
|
+
/** Same as {@link createRealtimeMonoBuffer} but for interleaved I/O. */
|
|
1359
|
+
createRealtimeInterleavedBuffer(numFrames, numChannels) {
|
|
1360
|
+
const input = this.getInterleavedInputBuffer(numFrames, numChannels);
|
|
1361
|
+
const output = this.getInterleavedOutputBuffer(numFrames, numChannels);
|
|
1362
|
+
return {
|
|
1363
|
+
input,
|
|
1364
|
+
output,
|
|
1365
|
+
channels: numChannels,
|
|
1366
|
+
process: () => this.processPreparedInterleaved(numFrames, numChannels)
|
|
1367
|
+
};
|
|
1368
|
+
}
|
|
1369
|
+
/**
|
|
1370
|
+
* Convenience factory for the planar zero-copy path. Acquires one
|
|
1371
|
+
* heap-backed Float32Array per channel and returns a `process()` thunk
|
|
1372
|
+
* wired to the same `numFrames`. Buffers are reused across calls and
|
|
1373
|
+
* become invalid after {@link delete}.
|
|
1374
|
+
*/
|
|
1375
|
+
createRealtimePlanarBuffer(numFrames, numChannels) {
|
|
1376
|
+
const channels = [];
|
|
1377
|
+
for (let ch = 0; ch < numChannels; ch++) {
|
|
1378
|
+
channels.push(this.getPlanarChannelBuffer(ch, numFrames));
|
|
1379
|
+
}
|
|
1380
|
+
return {
|
|
1381
|
+
channels,
|
|
1382
|
+
process: () => this.processPreparedPlanar(numFrames)
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1385
|
+
delete() {
|
|
1386
|
+
this.changer.delete();
|
|
1387
|
+
}
|
|
1388
|
+
};
|
|
1389
|
+
function realtimeVoiceChangerPresetNames() {
|
|
983
1390
|
if (!module) {
|
|
984
1391
|
throw new Error("Module not initialized. Call init() first.");
|
|
985
1392
|
}
|
|
986
|
-
return module.
|
|
1393
|
+
return module.realtimeVoiceChangerPresetNames();
|
|
1394
|
+
}
|
|
1395
|
+
function realtimeVoiceChangerPresetJson(name) {
|
|
1396
|
+
if (!module) {
|
|
1397
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
1398
|
+
}
|
|
1399
|
+
return module.realtimeVoiceChangerPresetJson(name);
|
|
1400
|
+
}
|
|
1401
|
+
function validateRealtimeVoiceChangerPresetJson(json) {
|
|
1402
|
+
if (!module) {
|
|
1403
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
1404
|
+
}
|
|
1405
|
+
return module.validateRealtimeVoiceChangerPresetJson(json);
|
|
987
1406
|
}
|
|
988
1407
|
var Mixer = class _Mixer {
|
|
989
1408
|
constructor(mixer) {
|
|
@@ -1128,6 +1547,26 @@ var Mixer = class _Mixer {
|
|
|
1128
1547
|
vcaGroupCount() {
|
|
1129
1548
|
return this.mixer.vcaGroupCount();
|
|
1130
1549
|
}
|
|
1550
|
+
/** Set the strip's input trim in dB. */
|
|
1551
|
+
setInputTrimDb(stripIndex, db) {
|
|
1552
|
+
this.mixer.setInputTrimDb(stripIndex, db);
|
|
1553
|
+
}
|
|
1554
|
+
/** Set the strip's fader level in dB. */
|
|
1555
|
+
setFaderDb(stripIndex, db) {
|
|
1556
|
+
this.mixer.setFaderDb(stripIndex, db);
|
|
1557
|
+
}
|
|
1558
|
+
/** Set the strip's pan position. */
|
|
1559
|
+
setPan(stripIndex, pan, panMode = 0) {
|
|
1560
|
+
this.mixer.setPan(stripIndex, pan, panModeCode(panMode));
|
|
1561
|
+
}
|
|
1562
|
+
/** Set the strip's stereo width. */
|
|
1563
|
+
setWidth(stripIndex, width) {
|
|
1564
|
+
this.mixer.setWidth(stripIndex, width);
|
|
1565
|
+
}
|
|
1566
|
+
/** Set the strip's mute state. */
|
|
1567
|
+
setMuted(stripIndex, muted) {
|
|
1568
|
+
this.mixer.setMuted(stripIndex, muted);
|
|
1569
|
+
}
|
|
1131
1570
|
/**
|
|
1132
1571
|
* Set a strip's solo state. Takes effect on the next process without a
|
|
1133
1572
|
* graph recompile.
|
|
@@ -1278,37 +1717,37 @@ function trim(samples, sampleRate, thresholdDb = -60) {
|
|
|
1278
1717
|
}
|
|
1279
1718
|
return module.trim(samples, sampleRate, thresholdDb);
|
|
1280
1719
|
}
|
|
1281
|
-
function stft(samples, sampleRate, nFft = 2048, hopLength = 512) {
|
|
1720
|
+
function stft(samples, sampleRate = 22050, nFft = 2048, hopLength = 512) {
|
|
1282
1721
|
if (!module) {
|
|
1283
1722
|
throw new Error("Module not initialized. Call init() first.");
|
|
1284
1723
|
}
|
|
1285
1724
|
return module.stft(samples, sampleRate, nFft, hopLength);
|
|
1286
1725
|
}
|
|
1287
|
-
function stftDb(samples, sampleRate, nFft = 2048, hopLength = 512) {
|
|
1726
|
+
function stftDb(samples, sampleRate = 22050, nFft = 2048, hopLength = 512) {
|
|
1288
1727
|
if (!module) {
|
|
1289
1728
|
throw new Error("Module not initialized. Call init() first.");
|
|
1290
1729
|
}
|
|
1291
1730
|
return module.stftDb(samples, sampleRate, nFft, hopLength);
|
|
1292
1731
|
}
|
|
1293
|
-
function melSpectrogram(samples, sampleRate, nFft = 2048, hopLength = 512, nMels = 128) {
|
|
1732
|
+
function melSpectrogram(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, nMels = 128) {
|
|
1294
1733
|
if (!module) {
|
|
1295
1734
|
throw new Error("Module not initialized. Call init() first.");
|
|
1296
1735
|
}
|
|
1297
1736
|
return module.melSpectrogram(samples, sampleRate, nFft, hopLength, nMels);
|
|
1298
1737
|
}
|
|
1299
|
-
function mfcc(samples, sampleRate, nFft = 2048, hopLength = 512, nMels = 128, nMfcc =
|
|
1738
|
+
function mfcc(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, nMels = 128, nMfcc = 20) {
|
|
1300
1739
|
if (!module) {
|
|
1301
1740
|
throw new Error("Module not initialized. Call init() first.");
|
|
1302
1741
|
}
|
|
1303
1742
|
return module.mfcc(samples, sampleRate, nFft, hopLength, nMels, nMfcc);
|
|
1304
1743
|
}
|
|
1305
|
-
function melToStft(melPower, nMels, nFrames, sampleRate
|
|
1744
|
+
function melToStft(melPower, nMels, nFrames, sampleRate = 22050, nFft = 2048, fmin = 0, fmax = 0) {
|
|
1306
1745
|
if (!module) {
|
|
1307
1746
|
throw new Error("Module not initialized. Call init() first.");
|
|
1308
1747
|
}
|
|
1309
|
-
return module.melToStft(melPower, nMels, nFrames, sampleRate, nFft,
|
|
1748
|
+
return module.melToStft(melPower, nMels, nFrames, sampleRate, nFft, fmin, fmax);
|
|
1310
1749
|
}
|
|
1311
|
-
function melToAudio(melPower, nMels, nFrames, sampleRate, nFft = 2048, hopLength = 512,
|
|
1750
|
+
function melToAudio(melPower, nMels, nFrames, sampleRate = 22050, nFft = 2048, hopLength = 512, fmin = 0, fmax = 0, nIter = 32) {
|
|
1312
1751
|
if (!module) {
|
|
1313
1752
|
throw new Error("Module not initialized. Call init() first.");
|
|
1314
1753
|
}
|
|
@@ -1319,9 +1758,9 @@ function melToAudio(melPower, nMels, nFrames, sampleRate, nFft = 2048, hopLength
|
|
|
1319
1758
|
sampleRate,
|
|
1320
1759
|
nFft,
|
|
1321
1760
|
hopLength,
|
|
1322
|
-
nIter,
|
|
1323
1761
|
fmin,
|
|
1324
|
-
fmax
|
|
1762
|
+
fmax,
|
|
1763
|
+
nIter
|
|
1325
1764
|
);
|
|
1326
1765
|
}
|
|
1327
1766
|
function mfccToMel(mfccCoefficients, nMfcc, nFrames, nMels = 128) {
|
|
@@ -1330,7 +1769,7 @@ function mfccToMel(mfccCoefficients, nMfcc, nFrames, nMels = 128) {
|
|
|
1330
1769
|
}
|
|
1331
1770
|
return module.mfccToMel(mfccCoefficients, nMfcc, nFrames, nMels);
|
|
1332
1771
|
}
|
|
1333
|
-
function mfccToAudio(mfccCoefficients, nMfcc, nFrames, nMels, sampleRate, nFft = 2048, hopLength = 512,
|
|
1772
|
+
function mfccToAudio(mfccCoefficients, nMfcc, nFrames, nMels = 128, sampleRate = 22050, nFft = 2048, hopLength = 512, fmin = 0, fmax = 0, nIter = 32) {
|
|
1334
1773
|
if (!module) {
|
|
1335
1774
|
throw new Error("Module not initialized. Call init() first.");
|
|
1336
1775
|
}
|
|
@@ -1342,64 +1781,155 @@ function mfccToAudio(mfccCoefficients, nMfcc, nFrames, nMels, sampleRate, nFft =
|
|
|
1342
1781
|
sampleRate,
|
|
1343
1782
|
nFft,
|
|
1344
1783
|
hopLength,
|
|
1345
|
-
nIter,
|
|
1346
1784
|
fmin,
|
|
1347
|
-
fmax
|
|
1785
|
+
fmax,
|
|
1786
|
+
nIter
|
|
1348
1787
|
);
|
|
1349
1788
|
}
|
|
1350
|
-
function chroma(samples, sampleRate, nFft = 2048, hopLength = 512) {
|
|
1789
|
+
function chroma(samples, sampleRate = 22050, nFft = 2048, hopLength = 512) {
|
|
1351
1790
|
if (!module) {
|
|
1352
1791
|
throw new Error("Module not initialized. Call init() first.");
|
|
1353
1792
|
}
|
|
1354
1793
|
return module.chroma(samples, sampleRate, nFft, hopLength);
|
|
1355
1794
|
}
|
|
1356
|
-
function spectralCentroid(samples, sampleRate, nFft = 2048, hopLength = 512) {
|
|
1795
|
+
function spectralCentroid(samples, sampleRate = 22050, nFft = 2048, hopLength = 512) {
|
|
1357
1796
|
if (!module) {
|
|
1358
1797
|
throw new Error("Module not initialized. Call init() first.");
|
|
1359
1798
|
}
|
|
1360
1799
|
return module.spectralCentroid(samples, sampleRate, nFft, hopLength);
|
|
1361
1800
|
}
|
|
1362
|
-
function
|
|
1801
|
+
function spectralContrast(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, nBands = 6, fmin = 200, quantile = 0.02) {
|
|
1802
|
+
if (!module) {
|
|
1803
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
1804
|
+
}
|
|
1805
|
+
return module.spectralContrast(samples, sampleRate, nFft, hopLength, nBands, fmin, quantile);
|
|
1806
|
+
}
|
|
1807
|
+
function polyFeatures(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, order = 1) {
|
|
1808
|
+
if (!module) {
|
|
1809
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
1810
|
+
}
|
|
1811
|
+
return module.polyFeatures(samples, sampleRate, nFft, hopLength, order);
|
|
1812
|
+
}
|
|
1813
|
+
function zeroCrossings(samples, threshold = 1e-10, refMagnitude = false, pad = true, zeroPos = true) {
|
|
1814
|
+
if (!module) {
|
|
1815
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
1816
|
+
}
|
|
1817
|
+
return module.zeroCrossings(samples, threshold, refMagnitude, pad, zeroPos);
|
|
1818
|
+
}
|
|
1819
|
+
function pitchTuning(frequencies, resolution = 0.01, binsPerOctave = 12) {
|
|
1820
|
+
if (!module) {
|
|
1821
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
1822
|
+
}
|
|
1823
|
+
return module.pitchTuning(frequencies, resolution, binsPerOctave);
|
|
1824
|
+
}
|
|
1825
|
+
function estimateTuning(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, resolution = 0.01, binsPerOctave = 12) {
|
|
1826
|
+
if (!module) {
|
|
1827
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
1828
|
+
}
|
|
1829
|
+
return module.estimateTuning(samples, sampleRate, nFft, hopLength, resolution, binsPerOctave);
|
|
1830
|
+
}
|
|
1831
|
+
function decompose(s, nFeatures, nFrames, nComponents, nIter = 50, beta = 2) {
|
|
1832
|
+
if (!module) {
|
|
1833
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
1834
|
+
}
|
|
1835
|
+
return module.decompose(s, nFeatures, nFrames, nComponents, nIter, beta);
|
|
1836
|
+
}
|
|
1837
|
+
function nnFilter(s, nFeatures, nFrames, aggregate = "mean", k = 7, width = 1) {
|
|
1838
|
+
if (!module) {
|
|
1839
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
1840
|
+
}
|
|
1841
|
+
return module.nnFilter(s, nFeatures, nFrames, aggregate, k, width);
|
|
1842
|
+
}
|
|
1843
|
+
function remix(samples, intervals, sampleRate = 22050, alignZeros = false) {
|
|
1844
|
+
if (!module) {
|
|
1845
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
1846
|
+
}
|
|
1847
|
+
const intervalsI32 = intervals instanceof Int32Array ? intervals : Int32Array.from(intervals, (v) => Math.trunc(v));
|
|
1848
|
+
return module.remix(samples, intervalsI32, sampleRate, alignZeros);
|
|
1849
|
+
}
|
|
1850
|
+
function phaseVocoder(samples, rate, sampleRate = 22050, nFft = 2048, hopLength = 512) {
|
|
1851
|
+
if (!module) {
|
|
1852
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
1853
|
+
}
|
|
1854
|
+
return module.phaseVocoder(samples, sampleRate, rate, nFft, hopLength);
|
|
1855
|
+
}
|
|
1856
|
+
function hpssWithResidual(samples, sampleRate = 22050, kernelHarmonic = 31, kernelPercussive = 31) {
|
|
1857
|
+
if (!module) {
|
|
1858
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
1859
|
+
}
|
|
1860
|
+
return module.hpssWithResidual(samples, sampleRate, kernelHarmonic, kernelPercussive);
|
|
1861
|
+
}
|
|
1862
|
+
function lufsInterleaved(samples, channels, sampleRate = 22050) {
|
|
1863
|
+
if (!module) {
|
|
1864
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
1865
|
+
}
|
|
1866
|
+
return module.lufsInterleaved(samples, channels, sampleRate);
|
|
1867
|
+
}
|
|
1868
|
+
function ebur128LoudnessRange(samples, sampleRate = 22050) {
|
|
1869
|
+
if (!module) {
|
|
1870
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
1871
|
+
}
|
|
1872
|
+
return module.ebur128LoudnessRange(samples, sampleRate);
|
|
1873
|
+
}
|
|
1874
|
+
function spectralBandwidth(samples, sampleRate = 22050, nFft = 2048, hopLength = 512) {
|
|
1363
1875
|
if (!module) {
|
|
1364
1876
|
throw new Error("Module not initialized. Call init() first.");
|
|
1365
1877
|
}
|
|
1366
1878
|
return module.spectralBandwidth(samples, sampleRate, nFft, hopLength);
|
|
1367
1879
|
}
|
|
1368
|
-
function spectralRolloff(samples, sampleRate, nFft = 2048, hopLength = 512, rollPercent = 0.85) {
|
|
1880
|
+
function spectralRolloff(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, rollPercent = 0.85) {
|
|
1369
1881
|
if (!module) {
|
|
1370
1882
|
throw new Error("Module not initialized. Call init() first.");
|
|
1371
1883
|
}
|
|
1372
1884
|
return module.spectralRolloff(samples, sampleRate, nFft, hopLength, rollPercent);
|
|
1373
1885
|
}
|
|
1374
|
-
function spectralFlatness(samples, sampleRate, nFft = 2048, hopLength = 512) {
|
|
1886
|
+
function spectralFlatness(samples, sampleRate = 22050, nFft = 2048, hopLength = 512) {
|
|
1375
1887
|
if (!module) {
|
|
1376
1888
|
throw new Error("Module not initialized. Call init() first.");
|
|
1377
1889
|
}
|
|
1378
1890
|
return module.spectralFlatness(samples, sampleRate, nFft, hopLength);
|
|
1379
1891
|
}
|
|
1380
|
-
function zeroCrossingRate(samples, sampleRate, frameLength = 2048, hopLength = 512) {
|
|
1892
|
+
function zeroCrossingRate(samples, sampleRate = 22050, frameLength = 2048, hopLength = 512) {
|
|
1381
1893
|
if (!module) {
|
|
1382
1894
|
throw new Error("Module not initialized. Call init() first.");
|
|
1383
1895
|
}
|
|
1384
1896
|
return module.zeroCrossingRate(samples, sampleRate, frameLength, hopLength);
|
|
1385
1897
|
}
|
|
1386
|
-
function rmsEnergy(samples, sampleRate, frameLength = 2048, hopLength = 512) {
|
|
1898
|
+
function rmsEnergy(samples, sampleRate = 22050, frameLength = 2048, hopLength = 512) {
|
|
1387
1899
|
if (!module) {
|
|
1388
1900
|
throw new Error("Module not initialized. Call init() first.");
|
|
1389
1901
|
}
|
|
1390
1902
|
return module.rmsEnergy(samples, sampleRate, frameLength, hopLength);
|
|
1391
1903
|
}
|
|
1392
|
-
function pitchYin(samples, sampleRate, frameLength = 2048, hopLength = 512, fmin = 65, fmax = 2093, threshold = 0.3) {
|
|
1904
|
+
function pitchYin(samples, sampleRate = 22050, frameLength = 2048, hopLength = 512, fmin = 65, fmax = 2093, threshold = 0.3, fillNa = false) {
|
|
1393
1905
|
if (!module) {
|
|
1394
1906
|
throw new Error("Module not initialized. Call init() first.");
|
|
1395
1907
|
}
|
|
1396
|
-
return module.pitchYin(
|
|
1908
|
+
return module.pitchYin(
|
|
1909
|
+
samples,
|
|
1910
|
+
sampleRate,
|
|
1911
|
+
frameLength,
|
|
1912
|
+
hopLength,
|
|
1913
|
+
fmin,
|
|
1914
|
+
fmax,
|
|
1915
|
+
threshold,
|
|
1916
|
+
fillNa
|
|
1917
|
+
);
|
|
1397
1918
|
}
|
|
1398
|
-
function pitchPyin(samples, sampleRate, frameLength = 2048, hopLength = 512, fmin = 65, fmax = 2093, threshold = 0.3) {
|
|
1919
|
+
function pitchPyin(samples, sampleRate = 22050, frameLength = 2048, hopLength = 512, fmin = 65, fmax = 2093, threshold = 0.3, fillNa = false) {
|
|
1399
1920
|
if (!module) {
|
|
1400
1921
|
throw new Error("Module not initialized. Call init() first.");
|
|
1401
1922
|
}
|
|
1402
|
-
return module.pitchPyin(
|
|
1923
|
+
return module.pitchPyin(
|
|
1924
|
+
samples,
|
|
1925
|
+
sampleRate,
|
|
1926
|
+
frameLength,
|
|
1927
|
+
hopLength,
|
|
1928
|
+
fmin,
|
|
1929
|
+
fmax,
|
|
1930
|
+
threshold,
|
|
1931
|
+
fillNa
|
|
1932
|
+
);
|
|
1403
1933
|
}
|
|
1404
1934
|
function hzToMel(hz) {
|
|
1405
1935
|
if (!module) {
|
|
@@ -1437,13 +1967,13 @@ function noteToHz(note) {
|
|
|
1437
1967
|
}
|
|
1438
1968
|
return module.noteToHz(note);
|
|
1439
1969
|
}
|
|
1440
|
-
function framesToTime(frames, sr, hopLength) {
|
|
1970
|
+
function framesToTime(frames, sr = 22050, hopLength = 512) {
|
|
1441
1971
|
if (!module) {
|
|
1442
1972
|
throw new Error("Module not initialized. Call init() first.");
|
|
1443
1973
|
}
|
|
1444
1974
|
return module.framesToTime(frames, sr, hopLength);
|
|
1445
1975
|
}
|
|
1446
|
-
function timeToFrames(time, sr, hopLength) {
|
|
1976
|
+
function timeToFrames(time, sr = 22050, hopLength = 512) {
|
|
1447
1977
|
if (!module) {
|
|
1448
1978
|
throw new Error("Module not initialized. Call init() first.");
|
|
1449
1979
|
}
|
|
@@ -1515,17 +2045,17 @@ function frameSignal(samples, frameLength, hopLength) {
|
|
|
1515
2045
|
}
|
|
1516
2046
|
return module.frameSignal(samples, frameLength, hopLength);
|
|
1517
2047
|
}
|
|
1518
|
-
function padCenter(values,
|
|
2048
|
+
function padCenter(values, targetSize, padValue = 0) {
|
|
1519
2049
|
if (!module) {
|
|
1520
2050
|
throw new Error("Module not initialized. Call init() first.");
|
|
1521
2051
|
}
|
|
1522
|
-
return module.padCenter(values,
|
|
2052
|
+
return module.padCenter(values, targetSize, padValue);
|
|
1523
2053
|
}
|
|
1524
|
-
function fixLength(values,
|
|
2054
|
+
function fixLength(values, targetSize, padValue = 0) {
|
|
1525
2055
|
if (!module) {
|
|
1526
2056
|
throw new Error("Module not initialized. Call init() first.");
|
|
1527
2057
|
}
|
|
1528
|
-
return module.fixLength(values,
|
|
2058
|
+
return module.fixLength(values, targetSize, padValue);
|
|
1529
2059
|
}
|
|
1530
2060
|
function fixFrames(frames, xMin = 0, xMax = -1, pad = true) {
|
|
1531
2061
|
if (!module) {
|
|
@@ -1539,7 +2069,7 @@ function peakPick(values, preMax, postMax, preAvg, postAvg, delta, wait) {
|
|
|
1539
2069
|
}
|
|
1540
2070
|
return module.peakPick(values, preMax, postMax, preAvg, postAvg, delta, wait);
|
|
1541
2071
|
}
|
|
1542
|
-
function vectorNormalize(values, normType = 0, threshold =
|
|
2072
|
+
function vectorNormalize(values, normType = 0, threshold = 0) {
|
|
1543
2073
|
if (!module) {
|
|
1544
2074
|
throw new Error("Module not initialized. Call init() first.");
|
|
1545
2075
|
}
|
|
@@ -1557,19 +2087,19 @@ function tonnetz(chromagram, nChroma, nFrames) {
|
|
|
1557
2087
|
}
|
|
1558
2088
|
return module.tonnetz(chromagram, nChroma, nFrames);
|
|
1559
2089
|
}
|
|
1560
|
-
function tempogram(onsetEnvelope2, sampleRate, hopLength = 512, winLength = 384, mode = "autocorrelation") {
|
|
2090
|
+
function tempogram(onsetEnvelope2, sampleRate = 22050, hopLength = 512, winLength = 384, mode = "autocorrelation") {
|
|
1561
2091
|
if (!module) {
|
|
1562
2092
|
throw new Error("Module not initialized. Call init() first.");
|
|
1563
2093
|
}
|
|
1564
2094
|
return module.tempogram(onsetEnvelope2, sampleRate, hopLength, winLength, mode);
|
|
1565
2095
|
}
|
|
1566
|
-
function cyclicTempogram(onsetEnvelope2, sampleRate, hopLength = 512, winLength = 384, bpmMin = 60, nBins = 60) {
|
|
2096
|
+
function cyclicTempogram(onsetEnvelope2, sampleRate = 22050, hopLength = 512, winLength = 384, bpmMin = 60, nBins = 60) {
|
|
1567
2097
|
if (!module) {
|
|
1568
2098
|
throw new Error("Module not initialized. Call init() first.");
|
|
1569
2099
|
}
|
|
1570
2100
|
return module.cyclicTempogram(onsetEnvelope2, sampleRate, hopLength, winLength, bpmMin, nBins);
|
|
1571
2101
|
}
|
|
1572
|
-
function plp(onsetEnvelope2, sampleRate, hopLength = 512, tempoMin = 30, tempoMax = 300, winLength = 384) {
|
|
2102
|
+
function plp(onsetEnvelope2, sampleRate = 22050, hopLength = 512, tempoMin = 30, tempoMax = 300, winLength = 384) {
|
|
1573
2103
|
if (!module) {
|
|
1574
2104
|
throw new Error("Module not initialized. Call init() first.");
|
|
1575
2105
|
}
|
|
@@ -1593,13 +2123,13 @@ function vqt(samples, sampleRate = 22050, hopLength = 512, fmin = 32.70319566257
|
|
|
1593
2123
|
}
|
|
1594
2124
|
return module.vqt(samples, sampleRate, hopLength, fmin, nBins, binsPerOctave, gamma);
|
|
1595
2125
|
}
|
|
1596
|
-
function analyzeSections(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, minSectionSec =
|
|
2126
|
+
function analyzeSections(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, minSectionSec = 4) {
|
|
1597
2127
|
if (!module) {
|
|
1598
2128
|
throw new Error("Module not initialized. Call init() first.");
|
|
1599
2129
|
}
|
|
1600
2130
|
return module.analyzeSections(samples, sampleRate, nFft, hopLength, minSectionSec).map((s) => ({ ...s, type: s.type }));
|
|
1601
2131
|
}
|
|
1602
|
-
function analyzeMelody(samples, sampleRate = 22050, fmin = 65, fmax = 2093, frameLength = 2048, hopLength =
|
|
2132
|
+
function analyzeMelody(samples, sampleRate = 22050, fmin = 65, fmax = 2093, frameLength = 2048, hopLength = 256, threshold = 0.1) {
|
|
1603
2133
|
if (!module) {
|
|
1604
2134
|
throw new Error("Module not initialized. Call init() first.");
|
|
1605
2135
|
}
|
|
@@ -1623,24 +2153,110 @@ function tempogramRatio(tempogramData, winLength = 384, sampleRate = 22050, hopL
|
|
|
1623
2153
|
}
|
|
1624
2154
|
return module.tempogramRatio(tempogramData, winLength, sampleRate, hopLength);
|
|
1625
2155
|
}
|
|
1626
|
-
function lufs(samples, sampleRate = 22050) {
|
|
2156
|
+
function lufs(samples, sampleRate = 22050, options = {}) {
|
|
1627
2157
|
if (!module) {
|
|
1628
2158
|
throw new Error("Module not initialized. Call init() first.");
|
|
1629
2159
|
}
|
|
2160
|
+
assertSamples("lufs", samples, options.validate !== false);
|
|
1630
2161
|
return module.lufs(samples, sampleRate);
|
|
1631
2162
|
}
|
|
1632
|
-
function momentaryLufs(samples, sampleRate = 22050) {
|
|
2163
|
+
function momentaryLufs(samples, sampleRate = 22050, options = {}) {
|
|
1633
2164
|
if (!module) {
|
|
1634
2165
|
throw new Error("Module not initialized. Call init() first.");
|
|
1635
2166
|
}
|
|
2167
|
+
assertSamples("momentaryLufs", samples, options.validate !== false);
|
|
1636
2168
|
return module.momentaryLufs(samples, sampleRate);
|
|
1637
2169
|
}
|
|
1638
|
-
function shortTermLufs(samples, sampleRate = 22050) {
|
|
2170
|
+
function shortTermLufs(samples, sampleRate = 22050, options = {}) {
|
|
1639
2171
|
if (!module) {
|
|
1640
2172
|
throw new Error("Module not initialized. Call init() first.");
|
|
1641
2173
|
}
|
|
2174
|
+
assertSamples("shortTermLufs", samples, options.validate !== false);
|
|
1642
2175
|
return module.shortTermLufs(samples, sampleRate);
|
|
1643
2176
|
}
|
|
2177
|
+
function requireModule() {
|
|
2178
|
+
if (!module) {
|
|
2179
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
2180
|
+
}
|
|
2181
|
+
return module;
|
|
2182
|
+
}
|
|
2183
|
+
function meteringPeakDb(samples, sampleRate = 22050, options = {}) {
|
|
2184
|
+
assertSamples("meteringPeakDb", samples, options.validate !== false);
|
|
2185
|
+
return requireModule().meteringPeakDb(samples, sampleRate);
|
|
2186
|
+
}
|
|
2187
|
+
function meteringRmsDb(samples, sampleRate = 22050, options = {}) {
|
|
2188
|
+
assertSamples("meteringRmsDb", samples, options.validate !== false);
|
|
2189
|
+
return requireModule().meteringRmsDb(samples, sampleRate);
|
|
2190
|
+
}
|
|
2191
|
+
function meteringCrestFactorDb(samples, sampleRate = 22050, options = {}) {
|
|
2192
|
+
assertSamples("meteringCrestFactorDb", samples, options.validate !== false);
|
|
2193
|
+
return requireModule().meteringCrestFactorDb(samples, sampleRate);
|
|
2194
|
+
}
|
|
2195
|
+
function meteringDcOffset(samples, sampleRate = 22050, options = {}) {
|
|
2196
|
+
assertSamples("meteringDcOffset", samples, options.validate !== false);
|
|
2197
|
+
return requireModule().meteringDcOffset(samples, sampleRate);
|
|
2198
|
+
}
|
|
2199
|
+
function meteringTruePeakDb(samples, sampleRate = 22050, oversampleFactor = 4, options = {}) {
|
|
2200
|
+
assertSamples("meteringTruePeakDb", samples, options.validate !== false);
|
|
2201
|
+
return requireModule().meteringTruePeakDb(samples, sampleRate, oversampleFactor);
|
|
2202
|
+
}
|
|
2203
|
+
function meteringDetectClipping(samples, sampleRate = 22050, threshold = 0.999, minRegionSamples = 1, options = {}) {
|
|
2204
|
+
assertSamples("meteringDetectClipping", samples, options.validate !== false);
|
|
2205
|
+
return requireModule().meteringDetectClipping(samples, sampleRate, threshold, minRegionSamples);
|
|
2206
|
+
}
|
|
2207
|
+
function meteringDynamicRange(samples, sampleRate = 22050, windowSec = 0, hopSec = 0, lowPercentile = 0, highPercentile = 0, options = {}) {
|
|
2208
|
+
assertSamples("meteringDynamicRange", samples, options.validate !== false);
|
|
2209
|
+
return requireModule().meteringDynamicRange(
|
|
2210
|
+
samples,
|
|
2211
|
+
sampleRate,
|
|
2212
|
+
windowSec,
|
|
2213
|
+
hopSec,
|
|
2214
|
+
lowPercentile,
|
|
2215
|
+
highPercentile
|
|
2216
|
+
);
|
|
2217
|
+
}
|
|
2218
|
+
function meteringStereoCorrelation(left, right, sampleRate = 22050, options = {}) {
|
|
2219
|
+
const validate = options.validate !== false;
|
|
2220
|
+
assertSamples("meteringStereoCorrelation", left, validate, "left");
|
|
2221
|
+
assertSamples("meteringStereoCorrelation", right, validate, "right");
|
|
2222
|
+
return requireModule().meteringStereoCorrelation(left, right, sampleRate);
|
|
2223
|
+
}
|
|
2224
|
+
function meteringStereoWidth(left, right, sampleRate = 22050, options = {}) {
|
|
2225
|
+
const validate = options.validate !== false;
|
|
2226
|
+
assertSamples("meteringStereoWidth", left, validate, "left");
|
|
2227
|
+
assertSamples("meteringStereoWidth", right, validate, "right");
|
|
2228
|
+
return requireModule().meteringStereoWidth(left, right, sampleRate);
|
|
2229
|
+
}
|
|
2230
|
+
function meteringVectorscope(left, right, sampleRate = 22050, options = {}) {
|
|
2231
|
+
const validate = options.validate !== false;
|
|
2232
|
+
assertSamples("meteringVectorscope", left, validate, "left");
|
|
2233
|
+
assertSamples("meteringVectorscope", right, validate, "right");
|
|
2234
|
+
return requireModule().meteringVectorscope(left, right, sampleRate);
|
|
2235
|
+
}
|
|
2236
|
+
function meteringPhaseScope(left, right, sampleRate = 22050, options = {}) {
|
|
2237
|
+
const validate = options.validate !== false;
|
|
2238
|
+
assertSamples("meteringPhaseScope", left, validate, "left");
|
|
2239
|
+
assertSamples("meteringPhaseScope", right, validate, "right");
|
|
2240
|
+
return requireModule().meteringPhaseScope(left, right, sampleRate);
|
|
2241
|
+
}
|
|
2242
|
+
function meteringSpectrum(samples, sampleRate = 22050, options) {
|
|
2243
|
+
const validate = options?.validate !== false;
|
|
2244
|
+
assertSamples("meteringSpectrum", samples, validate);
|
|
2245
|
+
return requireModule().meteringSpectrum(samples, sampleRate, options ?? {});
|
|
2246
|
+
}
|
|
2247
|
+
function scaleQuantizeMidi(root, modeMask, midi, referenceMidi = 0) {
|
|
2248
|
+
assertFiniteScalar("scaleQuantizeMidi", midi, "midi");
|
|
2249
|
+
assertFiniteScalar("scaleQuantizeMidi", referenceMidi, "referenceMidi");
|
|
2250
|
+
return requireModule().scaleQuantizeMidi(root, modeMask, midi, referenceMidi);
|
|
2251
|
+
}
|
|
2252
|
+
function scaleCorrectionSemitones(root, modeMask, midi, referenceMidi = 0) {
|
|
2253
|
+
assertFiniteScalar("scaleCorrectionSemitones", midi, "midi");
|
|
2254
|
+
assertFiniteScalar("scaleCorrectionSemitones", referenceMidi, "referenceMidi");
|
|
2255
|
+
return requireModule().scaleCorrectionSemitones(root, modeMask, midi, referenceMidi);
|
|
2256
|
+
}
|
|
2257
|
+
function scalePitchClassEnabled(root, modeMask, pitchClass) {
|
|
2258
|
+
return requireModule().scalePitchClassEnabled(root, modeMask, pitchClass);
|
|
2259
|
+
}
|
|
1644
2260
|
function resample(samples, srcSr, targetSr) {
|
|
1645
2261
|
if (!module) {
|
|
1646
2262
|
throw new Error("Module not initialized. Call init() first.");
|
|
@@ -1716,13 +2332,13 @@ var Audio = class _Audio {
|
|
|
1716
2332
|
pitchShift(semitones) {
|
|
1717
2333
|
return pitchShift(this._samples, this._sampleRate, semitones);
|
|
1718
2334
|
}
|
|
1719
|
-
pitchCorrectToMidi(currentMidi, targetMidi) {
|
|
2335
|
+
pitchCorrectToMidi(currentMidi = 69, targetMidi = 69) {
|
|
1720
2336
|
return pitchCorrectToMidi(this._samples, this._sampleRate, currentMidi, targetMidi);
|
|
1721
2337
|
}
|
|
1722
|
-
noteStretch(onsetSample, offsetSample, stretchRatio) {
|
|
2338
|
+
noteStretch(onsetSample = 0, offsetSample = 0, stretchRatio = 1) {
|
|
1723
2339
|
return noteStretch(this._samples, this._sampleRate, onsetSample, offsetSample, stretchRatio);
|
|
1724
2340
|
}
|
|
1725
|
-
voiceChange(pitchSemitones, formantFactor) {
|
|
2341
|
+
voiceChange(pitchSemitones = 0, formantFactor = 1) {
|
|
1726
2342
|
return voiceChange(this._samples, this._sampleRate, pitchSemitones, formantFactor);
|
|
1727
2343
|
}
|
|
1728
2344
|
normalize(targetDb = 0) {
|
|
@@ -1753,7 +2369,7 @@ var Audio = class _Audio {
|
|
|
1753
2369
|
melSpectrogram(nFft = 2048, hopLength = 512, nMels = 128) {
|
|
1754
2370
|
return melSpectrogram(this._samples, this._sampleRate, nFft, hopLength, nMels);
|
|
1755
2371
|
}
|
|
1756
|
-
mfcc(nFft = 2048, hopLength = 512, nMels = 128, nMfcc =
|
|
2372
|
+
mfcc(nFft = 2048, hopLength = 512, nMels = 128, nMfcc = 20) {
|
|
1757
2373
|
return mfcc(this._samples, this._sampleRate, nFft, hopLength, nMels, nMfcc);
|
|
1758
2374
|
}
|
|
1759
2375
|
chroma(nFft = 2048, hopLength = 512) {
|
|
@@ -1792,10 +2408,19 @@ var Audio = class _Audio {
|
|
|
1792
2408
|
rmsEnergy(frameLength = 2048, hopLength = 512) {
|
|
1793
2409
|
return rmsEnergy(this._samples, this._sampleRate, frameLength, hopLength);
|
|
1794
2410
|
}
|
|
1795
|
-
pitchYin(frameLength = 2048, hopLength = 512, fmin = 65, fmax = 2093, threshold = 0.3) {
|
|
1796
|
-
return pitchYin(
|
|
2411
|
+
pitchYin(frameLength = 2048, hopLength = 512, fmin = 65, fmax = 2093, threshold = 0.3, fillNa = false) {
|
|
2412
|
+
return pitchYin(
|
|
2413
|
+
this._samples,
|
|
2414
|
+
this._sampleRate,
|
|
2415
|
+
frameLength,
|
|
2416
|
+
hopLength,
|
|
2417
|
+
fmin,
|
|
2418
|
+
fmax,
|
|
2419
|
+
threshold,
|
|
2420
|
+
fillNa
|
|
2421
|
+
);
|
|
1797
2422
|
}
|
|
1798
|
-
pitchPyin(frameLength = 2048, hopLength = 512, fmin = 65, fmax = 2093, threshold = 0.3) {
|
|
2423
|
+
pitchPyin(frameLength = 2048, hopLength = 512, fmin = 65, fmax = 2093, threshold = 0.3, fillNa = false) {
|
|
1799
2424
|
return pitchPyin(
|
|
1800
2425
|
this._samples,
|
|
1801
2426
|
this._sampleRate,
|
|
@@ -1803,7 +2428,8 @@ var Audio = class _Audio {
|
|
|
1803
2428
|
hopLength,
|
|
1804
2429
|
fmin,
|
|
1805
2430
|
fmax,
|
|
1806
|
-
threshold
|
|
2431
|
+
threshold,
|
|
2432
|
+
fillNa
|
|
1807
2433
|
);
|
|
1808
2434
|
}
|
|
1809
2435
|
resample(targetSr) {
|
|
@@ -1820,9 +2446,8 @@ var StreamAnalyzer = class {
|
|
|
1820
2446
|
if (!module) {
|
|
1821
2447
|
throw new Error("Module not initialized. Call init() first.");
|
|
1822
2448
|
}
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
config.sampleRate,
|
|
2449
|
+
this.analyzer = new module.StreamAnalyzer(
|
|
2450
|
+
config.sampleRate ?? 44100,
|
|
1826
2451
|
config.nFft ?? 2048,
|
|
1827
2452
|
config.hopLength ?? 512,
|
|
1828
2453
|
config.nMels ?? 128,
|
|
@@ -1840,44 +2465,7 @@ var StreamAnalyzer = class {
|
|
|
1840
2465
|
config.bpmUpdateIntervalSec ?? 10,
|
|
1841
2466
|
config.window ?? 0,
|
|
1842
2467
|
config.outputFormat ?? 0
|
|
1843
|
-
|
|
1844
|
-
const isArityError = (error) => {
|
|
1845
|
-
const message = String(error?.message ?? error);
|
|
1846
|
-
return message.includes("invalid number of parameters");
|
|
1847
|
-
};
|
|
1848
|
-
const createLegacy = () => {
|
|
1849
|
-
const LegacyStreamAnalyzer = wasmModule.StreamAnalyzer;
|
|
1850
|
-
return new LegacyStreamAnalyzer(
|
|
1851
|
-
args[0],
|
|
1852
|
-
args[1],
|
|
1853
|
-
args[2],
|
|
1854
|
-
args[3],
|
|
1855
|
-
args[8],
|
|
1856
|
-
args[9],
|
|
1857
|
-
args[10],
|
|
1858
|
-
args[12]
|
|
1859
|
-
);
|
|
1860
|
-
};
|
|
1861
|
-
const hasExtendedConfig = config.fmin !== void 0 || config.fmax !== void 0 || config.tuningRefHz !== void 0 || config.computeMagnitude !== void 0 || config.computeSpectral !== void 0 || config.magnitudeDownsample !== void 0 || config.keyUpdateIntervalSec !== void 0 || config.bpmUpdateIntervalSec !== void 0 || config.window !== void 0 || config.outputFormat !== void 0;
|
|
1862
|
-
if (hasExtendedConfig) {
|
|
1863
|
-
try {
|
|
1864
|
-
this.analyzer = new wasmModule.StreamAnalyzer(...args);
|
|
1865
|
-
} catch (error) {
|
|
1866
|
-
if (!isArityError(error)) {
|
|
1867
|
-
throw error;
|
|
1868
|
-
}
|
|
1869
|
-
this.analyzer = createLegacy();
|
|
1870
|
-
}
|
|
1871
|
-
} else {
|
|
1872
|
-
try {
|
|
1873
|
-
this.analyzer = createLegacy();
|
|
1874
|
-
} catch (error) {
|
|
1875
|
-
if (!isArityError(error)) {
|
|
1876
|
-
throw error;
|
|
1877
|
-
}
|
|
1878
|
-
this.analyzer = new wasmModule.StreamAnalyzer(...args);
|
|
1879
|
-
}
|
|
1880
|
-
}
|
|
2468
|
+
);
|
|
1881
2469
|
}
|
|
1882
2470
|
/**
|
|
1883
2471
|
* Process audio samples.
|
|
@@ -2046,6 +2634,7 @@ export {
|
|
|
2046
2634
|
PitchClass as Pitch,
|
|
2047
2635
|
PitchClass,
|
|
2048
2636
|
RealtimeEngine,
|
|
2637
|
+
RealtimeVoiceChanger,
|
|
2049
2638
|
SectionType,
|
|
2050
2639
|
StreamAnalyzer,
|
|
2051
2640
|
StreamingEqualizer,
|
|
@@ -2053,15 +2642,20 @@ export {
|
|
|
2053
2642
|
StreamingRetune,
|
|
2054
2643
|
amplitudeToDb,
|
|
2055
2644
|
analyze,
|
|
2645
|
+
analyzeBpm,
|
|
2646
|
+
analyzeDynamics,
|
|
2056
2647
|
analyzeImpulseResponse,
|
|
2057
2648
|
analyzeMelody,
|
|
2649
|
+
analyzeRhythm,
|
|
2058
2650
|
analyzeSections,
|
|
2651
|
+
analyzeTimbre,
|
|
2059
2652
|
analyzeWithProgress,
|
|
2060
2653
|
chroma,
|
|
2061
2654
|
cqt,
|
|
2062
2655
|
cyclicTempogram,
|
|
2063
2656
|
dbToAmplitude,
|
|
2064
2657
|
dbToPower,
|
|
2658
|
+
decompose,
|
|
2065
2659
|
deemphasis,
|
|
2066
2660
|
detectAcoustic,
|
|
2067
2661
|
detectBeats,
|
|
@@ -2071,8 +2665,11 @@ export {
|
|
|
2071
2665
|
detectKey,
|
|
2072
2666
|
detectKeyCandidates,
|
|
2073
2667
|
detectOnsets,
|
|
2668
|
+
ebur128LoudnessRange,
|
|
2074
2669
|
engineAbiVersion,
|
|
2075
2670
|
engineCapabilities,
|
|
2671
|
+
estimateRoom,
|
|
2672
|
+
estimateTuning,
|
|
2076
2673
|
fixFrames,
|
|
2077
2674
|
fixLength,
|
|
2078
2675
|
fourierTempogram,
|
|
@@ -2080,15 +2677,20 @@ export {
|
|
|
2080
2677
|
framesToSamples,
|
|
2081
2678
|
framesToTime,
|
|
2082
2679
|
harmonic,
|
|
2680
|
+
hasFfmpegSupport,
|
|
2083
2681
|
hpss,
|
|
2682
|
+
hpssWithResidual,
|
|
2084
2683
|
hzToMel,
|
|
2085
2684
|
hzToMidi,
|
|
2086
2685
|
hzToNote,
|
|
2087
2686
|
init,
|
|
2088
2687
|
isInitialized,
|
|
2089
2688
|
lufs,
|
|
2689
|
+
lufsInterleaved,
|
|
2090
2690
|
masterAudio,
|
|
2091
2691
|
masterAudioStereo,
|
|
2692
|
+
masterAudioStereoWithProgress,
|
|
2693
|
+
masterAudioWithProgress,
|
|
2092
2694
|
mastering,
|
|
2093
2695
|
masteringAssistantSuggest,
|
|
2094
2696
|
masteringAudioProfile,
|
|
@@ -2096,6 +2698,9 @@ export {
|
|
|
2096
2698
|
masteringChainStereo,
|
|
2097
2699
|
masteringChainStereoWithProgress,
|
|
2098
2700
|
masteringChainWithProgress,
|
|
2701
|
+
masteringDynamicsCompressor,
|
|
2702
|
+
masteringDynamicsGate,
|
|
2703
|
+
masteringDynamicsTransientShaper,
|
|
2099
2704
|
masteringPairAnalysisNames,
|
|
2100
2705
|
masteringPairAnalyze,
|
|
2101
2706
|
masteringPairProcess,
|
|
@@ -2104,6 +2709,13 @@ export {
|
|
|
2104
2709
|
masteringProcess,
|
|
2105
2710
|
masteringProcessStereo,
|
|
2106
2711
|
masteringProcessorNames,
|
|
2712
|
+
masteringRepairDeclick,
|
|
2713
|
+
masteringRepairDeclip,
|
|
2714
|
+
masteringRepairDecrackle,
|
|
2715
|
+
masteringRepairDehum,
|
|
2716
|
+
masteringRepairDenoiseClassical,
|
|
2717
|
+
masteringRepairDereverbClassical,
|
|
2718
|
+
masteringRepairTrimSilence,
|
|
2107
2719
|
masteringStereoAnalysisNames,
|
|
2108
2720
|
masteringStereoAnalyze,
|
|
2109
2721
|
masteringStreamingPreview,
|
|
@@ -2111,15 +2723,27 @@ export {
|
|
|
2111
2723
|
melToAudio,
|
|
2112
2724
|
melToHz,
|
|
2113
2725
|
melToStft,
|
|
2726
|
+
meteringCrestFactorDb,
|
|
2727
|
+
meteringDcOffset,
|
|
2728
|
+
meteringDetectClipping,
|
|
2729
|
+
meteringDynamicRange,
|
|
2730
|
+
meteringPeakDb,
|
|
2731
|
+
meteringPhaseScope,
|
|
2732
|
+
meteringRmsDb,
|
|
2733
|
+
meteringSpectrum,
|
|
2734
|
+
meteringStereoCorrelation,
|
|
2735
|
+
meteringStereoWidth,
|
|
2736
|
+
meteringTruePeakDb,
|
|
2737
|
+
meteringVectorscope,
|
|
2114
2738
|
mfcc,
|
|
2115
2739
|
mfccToAudio,
|
|
2116
2740
|
mfccToMel,
|
|
2117
2741
|
midiToHz,
|
|
2118
2742
|
mixStereo,
|
|
2119
|
-
mixerScenePresetJson,
|
|
2120
2743
|
mixingScenePresetJson,
|
|
2121
2744
|
mixingScenePresetNames,
|
|
2122
2745
|
momentaryLufs,
|
|
2746
|
+
nnFilter,
|
|
2123
2747
|
nnlsChroma,
|
|
2124
2748
|
normalize,
|
|
2125
2749
|
noteStretch,
|
|
@@ -2129,24 +2753,37 @@ export {
|
|
|
2129
2753
|
pcen,
|
|
2130
2754
|
peakPick,
|
|
2131
2755
|
percussive,
|
|
2756
|
+
phaseVocoder,
|
|
2132
2757
|
pitchCorrectToMidi,
|
|
2133
2758
|
pitchPyin,
|
|
2134
2759
|
pitchShift,
|
|
2760
|
+
pitchTuning,
|
|
2135
2761
|
pitchYin,
|
|
2136
2762
|
plp,
|
|
2763
|
+
polyFeatures,
|
|
2137
2764
|
powerToDb,
|
|
2138
2765
|
preemphasis,
|
|
2766
|
+
realtimeVoiceChangerPresetConfig,
|
|
2767
|
+
realtimeVoiceChangerPresetJson,
|
|
2768
|
+
realtimeVoiceChangerPresetNames,
|
|
2769
|
+
remix,
|
|
2139
2770
|
resample,
|
|
2140
2771
|
rmsEnergy,
|
|
2772
|
+
roomMorph,
|
|
2141
2773
|
samplesToFrames,
|
|
2774
|
+
scaleCorrectionSemitones,
|
|
2775
|
+
scalePitchClassEnabled,
|
|
2776
|
+
scaleQuantizeMidi,
|
|
2142
2777
|
shortTermLufs,
|
|
2143
2778
|
spectralBandwidth,
|
|
2144
2779
|
spectralCentroid,
|
|
2780
|
+
spectralContrast,
|
|
2145
2781
|
spectralFlatness,
|
|
2146
2782
|
spectralRolloff,
|
|
2147
2783
|
splitSilence,
|
|
2148
2784
|
stft,
|
|
2149
2785
|
stftDb,
|
|
2786
|
+
synthesizeRir,
|
|
2150
2787
|
tempogram,
|
|
2151
2788
|
tempogramRatio,
|
|
2152
2789
|
timeStretch,
|
|
@@ -2154,10 +2791,15 @@ export {
|
|
|
2154
2791
|
tonnetz,
|
|
2155
2792
|
trim,
|
|
2156
2793
|
trimSilence,
|
|
2794
|
+
validateRealtimeVoiceChangerPresetJson,
|
|
2157
2795
|
vectorNormalize,
|
|
2158
2796
|
version,
|
|
2159
2797
|
voiceChange,
|
|
2798
|
+
voiceChangeRealtime,
|
|
2799
|
+
voiceChangerAbiVersion,
|
|
2800
|
+
voiceCharacterPresetId,
|
|
2160
2801
|
vqt,
|
|
2161
|
-
zeroCrossingRate
|
|
2802
|
+
zeroCrossingRate,
|
|
2803
|
+
zeroCrossings
|
|
2162
2804
|
};
|
|
2163
2805
|
//# sourceMappingURL=index.js.map
|