@libraz/libsonare 1.2.1 → 1.2.2

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/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";
@@ -305,13 +381,13 @@ var RealtimeEngine = class {
305
381
  this.native.delete();
306
382
  }
307
383
  };
308
- function detectBpm(samples, sampleRate) {
384
+ function detectBpm(samples, sampleRate = 22050) {
309
385
  if (!module) {
310
386
  throw new Error("Module not initialized. Call init() first.");
311
387
  }
312
388
  return module.detectBpm(samples, sampleRate);
313
389
  }
314
- function detectKey(samples, sampleRate, options = {}) {
390
+ function detectKey(samples, sampleRate = 22050, options = {}) {
315
391
  if (!module) {
316
392
  throw new Error("Module not initialized. Call init() first.");
317
393
  }
@@ -400,7 +476,7 @@ function keyProfileValue(profile) {
400
476
  };
401
477
  return names[profile];
402
478
  }
403
- function detectKeyCandidates(samples, sampleRate, options = {}) {
479
+ function detectKeyCandidates(samples, sampleRate = 22050, options = {}) {
404
480
  if (!module) {
405
481
  throw new Error("Module not initialized. Call init() first.");
406
482
  }
@@ -417,19 +493,19 @@ function detectKeyCandidates(samples, sampleRate, options = {}) {
417
493
  options.genreHint ?? ""
418
494
  ).map(convertKeyCandidate);
419
495
  }
420
- function detectOnsets(samples, sampleRate) {
496
+ function detectOnsets(samples, sampleRate = 22050) {
421
497
  if (!module) {
422
498
  throw new Error("Module not initialized. Call init() first.");
423
499
  }
424
500
  return module.detectOnsets(samples, sampleRate);
425
501
  }
426
- function detectBeats(samples, sampleRate) {
502
+ function detectBeats(samples, sampleRate = 22050) {
427
503
  if (!module) {
428
504
  throw new Error("Module not initialized. Call init() first.");
429
505
  }
430
506
  return module.detectBeats(samples, sampleRate);
431
507
  }
432
- function detectDownbeats(samples, sampleRate) {
508
+ function detectDownbeats(samples, sampleRate = 22050) {
433
509
  if (!module) {
434
510
  throw new Error("Module not initialized. Call init() first.");
435
511
  }
@@ -448,7 +524,7 @@ function convertChordAnalysisResult(wasm) {
448
524
  }))
449
525
  };
450
526
  }
451
- function detectChords(samples, sampleRate, options = {}) {
527
+ function detectChords(samples, sampleRate = 22050, options = {}) {
452
528
  if (!module) {
453
529
  throw new Error("Module not initialized. Call init() first.");
454
530
  }
@@ -522,14 +598,14 @@ function convertAnalysisResult(wasm) {
522
598
  form: wasm.form
523
599
  };
524
600
  }
525
- function analyze(samples, sampleRate) {
601
+ function analyze(samples, sampleRate = 22050) {
526
602
  if (!module) {
527
603
  throw new Error("Module not initialized. Call init() first.");
528
604
  }
529
605
  const result = module.analyze(samples, sampleRate);
530
606
  return convertAnalysisResult(result);
531
607
  }
532
- function analyzeImpulseResponse(samples, sampleRate, nOctaveBands = 6) {
608
+ function analyzeImpulseResponse(samples, sampleRate = 48e3, nOctaveBands = 6) {
533
609
  if (!module) {
534
610
  throw new Error("Module not initialized. Call init() first.");
535
611
  }
@@ -540,7 +616,7 @@ function analyzeImpulseResponse(samples, sampleRate, nOctaveBands = 6) {
540
616
  );
541
617
  return result;
542
618
  }
543
- function detectAcoustic(samples, sampleRate, nOctaveBands = 6, nThirdOctaveSubbands = 24, minDecayDb = 30, noiseFloorMarginDb = 10) {
619
+ function detectAcoustic(samples, sampleRate = 48e3, nOctaveBands = 6, nThirdOctaveSubbands = 24, minDecayDb = 30, noiseFloorMarginDb = 10) {
544
620
  if (!module) {
545
621
  throw new Error("Module not initialized. Call init() first.");
546
622
  }
@@ -554,14 +630,53 @@ function detectAcoustic(samples, sampleRate, nOctaveBands = 6, nThirdOctaveSubba
554
630
  );
555
631
  return result;
556
632
  }
557
- function analyzeWithProgress(samples, sampleRate, onProgress) {
633
+ function analyzeWithProgress(samples, sampleRate = 22050, onProgress) {
558
634
  if (!module) {
559
635
  throw new Error("Module not initialized. Call init() first.");
560
636
  }
561
637
  const result = module.analyzeWithProgress(samples, sampleRate, onProgress);
562
638
  return convertAnalysisResult(result);
563
639
  }
564
- function hpss(samples, sampleRate, kernelHarmonic = 31, kernelPercussive = 31) {
640
+ function analyzeBpm(samples, sampleRate = 22050, bpmMin = 30, bpmMax = 300, startBpm = 120, nFft = 2048, hopLength = 512, maxCandidates = 5) {
641
+ if (!module) {
642
+ throw new Error("Module not initialized. Call init() first.");
643
+ }
644
+ return module.analyzeBpm(
645
+ samples,
646
+ sampleRate,
647
+ bpmMin,
648
+ bpmMax,
649
+ startBpm,
650
+ nFft,
651
+ hopLength,
652
+ maxCandidates
653
+ );
654
+ }
655
+ function analyzeRhythm(samples, sampleRate = 22050, bpmMin = 60, bpmMax = 200, startBpm = 120, nFft = 2048, hopLength = 512) {
656
+ if (!module) {
657
+ throw new Error("Module not initialized. Call init() first.");
658
+ }
659
+ return module.analyzeRhythm(samples, sampleRate, bpmMin, bpmMax, startBpm, nFft, hopLength);
660
+ }
661
+ function analyzeDynamics(samples, sampleRate = 22050, windowSec = 0.4, hopLength = 512, compressionThreshold = 6) {
662
+ if (!module) {
663
+ throw new Error("Module not initialized. Call init() first.");
664
+ }
665
+ return module.analyzeDynamics(samples, sampleRate, windowSec, hopLength, compressionThreshold);
666
+ }
667
+ function analyzeTimbre(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, nMels = 128, nMfcc = 13, windowSec = 0.5) {
668
+ if (!module) {
669
+ throw new Error("Module not initialized. Call init() first.");
670
+ }
671
+ return module.analyzeTimbre(samples, sampleRate, nFft, hopLength, nMels, nMfcc, windowSec);
672
+ }
673
+ function hasFfmpegSupport() {
674
+ if (!module) {
675
+ throw new Error("Module not initialized. Call init() first.");
676
+ }
677
+ return module.hasFfmpegSupport();
678
+ }
679
+ function hpss(samples, sampleRate = 22050, kernelHarmonic = 31, kernelPercussive = 31) {
565
680
  if (!module) {
566
681
  throw new Error("Module not initialized. Call init() first.");
567
682
  }
@@ -591,22 +706,23 @@ function pitchShift(samples, sampleRate, semitones) {
591
706
  }
592
707
  return module.pitchShift(samples, sampleRate, semitones);
593
708
  }
594
- function pitchCorrectToMidi(samples, sampleRate, currentMidi, targetMidi) {
709
+ function pitchCorrectToMidi(samples, sampleRate = 22050, currentMidi = 69, targetMidi = 69) {
595
710
  if (!module) {
596
711
  throw new Error("Module not initialized. Call init() first.");
597
712
  }
598
713
  return module.pitchCorrectToMidi(samples, sampleRate, currentMidi, targetMidi);
599
714
  }
600
- function noteStretch(samples, sampleRate, onsetSample, offsetSample, stretchRatio) {
715
+ function noteStretch(samples, sampleRate = 22050, onsetSample = 0, offsetSample = 0, stretchRatio = 1) {
601
716
  if (!module) {
602
717
  throw new Error("Module not initialized. Call init() first.");
603
718
  }
604
719
  return module.noteStretch(samples, sampleRate, onsetSample, offsetSample, stretchRatio);
605
720
  }
606
- function voiceChange(samples, sampleRate, pitchSemitones, formantFactor) {
721
+ function voiceChange(samples, sampleRate = 22050, pitchSemitones = 0, formantFactor = 1, options = {}) {
607
722
  if (!module) {
608
723
  throw new Error("Module not initialized. Call init() first.");
609
724
  }
725
+ assertSamples("voiceChange", samples, options.validate !== false);
610
726
  return module.voiceChange(samples, sampleRate, pitchSemitones, formantFactor);
611
727
  }
612
728
  function normalize(samples, sampleRate, targetDb = 0) {
@@ -615,7 +731,7 @@ function normalize(samples, sampleRate, targetDb = 0) {
615
731
  }
616
732
  return module.normalize(samples, sampleRate, targetDb);
617
733
  }
618
- function mastering(samples, sampleRate, targetLufs = -14, ceilingDb = -1, truePeakOversample = 4) {
734
+ function mastering(samples, sampleRate = 22050, targetLufs = -14, ceilingDb = -1, truePeakOversample = 4) {
619
735
  if (!module) {
620
736
  throw new Error("Module not initialized. Call init() first.");
621
737
  }
@@ -645,13 +761,13 @@ function masteringStereoAnalysisNames() {
645
761
  }
646
762
  return module.masteringStereoAnalysisNames();
647
763
  }
648
- function masteringProcess(processorName, samples, sampleRate, params = {}) {
764
+ function masteringProcess(processorName, samples, sampleRate = 22050, params = {}) {
649
765
  if (!module) {
650
766
  throw new Error("Module not initialized. Call init() first.");
651
767
  }
652
768
  return module.masteringProcess(processorName, samples, sampleRate, params);
653
769
  }
654
- function masteringProcessStereo(processorName, left, right, sampleRate, params = {}) {
770
+ function masteringProcessStereo(processorName, left, right, sampleRate = 22050, params = {}) {
655
771
  if (!module) {
656
772
  throw new Error("Module not initialized. Call init() first.");
657
773
  }
@@ -660,49 +776,92 @@ function masteringProcessStereo(processorName, left, right, sampleRate, params =
660
776
  }
661
777
  return module.masteringProcessStereo(processorName, left, right, sampleRate, params);
662
778
  }
663
- function masteringPairProcess(processorName, source, reference, sampleRate, params = {}) {
779
+ function masteringPairProcess(processorName, source, reference, sampleRate = 22050, params = {}) {
664
780
  if (!module) {
665
781
  throw new Error("Module not initialized. Call init() first.");
666
782
  }
667
783
  return module.masteringPairProcess(processorName, source, reference, sampleRate, params);
668
784
  }
669
- function masteringPairAnalyze(analysisName, source, reference, sampleRate, params = {}) {
785
+ function masteringPairAnalyze(analysisName, source, reference, sampleRate = 22050, params = {}) {
670
786
  if (!module) {
671
787
  throw new Error("Module not initialized. Call init() first.");
672
788
  }
673
789
  return module.masteringPairAnalyze(analysisName, source, reference, sampleRate, params);
674
790
  }
675
- function masteringStereoAnalyze(analysisName, left, right, sampleRate, params = {}) {
791
+ function masteringStereoAnalyze(analysisName, left, right, sampleRate = 22050, params = {}) {
676
792
  if (!module) {
677
793
  throw new Error("Module not initialized. Call init() first.");
678
794
  }
679
795
  return module.masteringStereoAnalyze(analysisName, left, right, sampleRate, params);
680
796
  }
681
- function masteringAssistantSuggest(samples, sampleRate, params = {}) {
797
+ function masteringAssistantSuggest(samples, sampleRate = 22050, params = {}) {
682
798
  if (!module) {
683
799
  throw new Error("Module not initialized. Call init() first.");
684
800
  }
685
801
  return module.masteringAssistantSuggest(samples, sampleRate, params);
686
802
  }
687
- function masteringAudioProfile(samples, sampleRate, params = {}) {
803
+ function masteringAudioProfile(samples, sampleRate = 22050, params = {}) {
688
804
  if (!module) {
689
805
  throw new Error("Module not initialized. Call init() first.");
690
806
  }
691
807
  return module.masteringAudioProfile(samples, sampleRate, params);
692
808
  }
693
- function masteringStreamingPreview(samples, sampleRate, platforms = []) {
809
+ function masteringStreamingPreview(samples, sampleRate = 22050, platforms = []) {
694
810
  if (!module) {
695
811
  throw new Error("Module not initialized. Call init() first.");
696
812
  }
697
813
  return module.masteringStreamingPreview(samples, sampleRate, platforms);
698
814
  }
699
- function masteringChain(samples, sampleRate, config) {
815
+ function masteringRepairDeclick(samples, sampleRate, options = {}) {
816
+ return requireModule().masteringRepairDeclick(samples, sampleRate, options);
817
+ }
818
+ function masteringRepairDenoiseClassical(samples, sampleRate, options = {}) {
819
+ return requireModule().masteringRepairDenoiseClassical(samples, sampleRate, options);
820
+ }
821
+ function masteringRepairDeclip(samples, sampleRate, options = {}) {
822
+ return requireModule().masteringRepairDeclip(samples, sampleRate, options);
823
+ }
824
+ function masteringRepairDecrackle(samples, sampleRate, options = {}) {
825
+ return requireModule().masteringRepairDecrackle(samples, sampleRate, options);
826
+ }
827
+ function masteringRepairDehum(samples, sampleRate, options = {}) {
828
+ return requireModule().masteringRepairDehum(samples, sampleRate, options);
829
+ }
830
+ function masteringRepairDereverbClassical(samples, sampleRate, options = {}) {
831
+ return requireModule().masteringRepairDereverbClassical(samples, sampleRate, options);
832
+ }
833
+ function masteringRepairTrimSilence(samples, sampleRate, options = {}) {
834
+ return requireModule().masteringRepairTrimSilence(samples, sampleRate, options);
835
+ }
836
+ var COMPRESSOR_DETECTOR_MAP = {
837
+ peak: 0,
838
+ rms: 1,
839
+ log_rms: 2
840
+ };
841
+ function masteringDynamicsCompressor(samples, sampleRate, options = {}) {
842
+ assertSamples("masteringDynamicsCompressor", samples, options.validate !== false);
843
+ const detector = typeof options.detector === "string" ? COMPRESSOR_DETECTOR_MAP[options.detector] : options.detector;
844
+ const opts = { ...options };
845
+ if (detector !== void 0) {
846
+ opts.detector = detector;
847
+ }
848
+ return requireModule().masteringDynamicsCompressor(samples, sampleRate, opts);
849
+ }
850
+ function masteringDynamicsGate(samples, sampleRate, options = {}) {
851
+ assertSamples("masteringDynamicsGate", samples, options.validate !== false);
852
+ return requireModule().masteringDynamicsGate(samples, sampleRate, options);
853
+ }
854
+ function masteringDynamicsTransientShaper(samples, sampleRate, options = {}) {
855
+ assertSamples("masteringDynamicsTransientShaper", samples, options.validate !== false);
856
+ return requireModule().masteringDynamicsTransientShaper(samples, sampleRate, options);
857
+ }
858
+ function masteringChain(samples, sampleRate = 22050, config) {
700
859
  if (!module) {
701
860
  throw new Error("Module not initialized. Call init() first.");
702
861
  }
703
862
  return module.masteringChain(samples, sampleRate, config);
704
863
  }
705
- function masteringChainStereo(left, right, sampleRate, config) {
864
+ function masteringChainStereo(left, right, sampleRate = 22050, config) {
706
865
  if (!module) {
707
866
  throw new Error("Module not initialized. Call init() first.");
708
867
  }
@@ -711,7 +870,7 @@ function masteringChainStereo(left, right, sampleRate, config) {
711
870
  }
712
871
  return module.masteringChainStereo(left, right, sampleRate, config);
713
872
  }
714
- function masteringChainWithProgress(samples, sampleRate, config, onProgress) {
873
+ function masteringChainWithProgress(samples, sampleRate = 22050, config, onProgress) {
715
874
  if (!module) {
716
875
  throw new Error("Module not initialized. Call init() first.");
717
876
  }
@@ -722,7 +881,7 @@ function masteringChainWithProgress(samples, sampleRate, config, onProgress) {
722
881
  onProgress
723
882
  );
724
883
  }
725
- function masteringChainStereoWithProgress(left, right, sampleRate, config, onProgress) {
884
+ function masteringChainStereoWithProgress(left, right, sampleRate = 22050, config, onProgress) {
726
885
  if (!module) {
727
886
  throw new Error("Module not initialized. Call init() first.");
728
887
  }
@@ -743,13 +902,13 @@ function masteringPresetNames() {
743
902
  }
744
903
  return module.masteringPresetNames();
745
904
  }
746
- function masterAudio(samples, sampleRate, presetName, overrides = null) {
905
+ function masterAudio(samples, sampleRate = 22050, presetName, overrides = null) {
747
906
  if (!module) {
748
907
  throw new Error("Module not initialized. Call init() first.");
749
908
  }
750
909
  return module.masterAudio(presetName, samples, sampleRate, overrides);
751
910
  }
752
- function masterAudioStereo(left, right, sampleRate, presetName, overrides = null) {
911
+ function masterAudioStereo(left, right, sampleRate = 22050, presetName, overrides = null) {
753
912
  if (!module) {
754
913
  throw new Error("Module not initialized. Call init() first.");
755
914
  }
@@ -758,17 +917,39 @@ function masterAudioStereo(left, right, sampleRate, presetName, overrides = null
758
917
  }
759
918
  return module.masterAudioStereo(presetName, left, right, sampleRate, overrides);
760
919
  }
920
+ function masterAudioWithProgress(samples, sampleRate = 22050, presetName, onProgress, overrides = null) {
921
+ if (!module) {
922
+ throw new Error("Module not initialized. Call init() first.");
923
+ }
924
+ return module.masterAudioWithProgress(presetName, samples, sampleRate, overrides, onProgress);
925
+ }
926
+ function masterAudioStereoWithProgress(left, right, sampleRate = 22050, presetName, onProgress, overrides = null) {
927
+ if (!module) {
928
+ throw new Error("Module not initialized. Call init() first.");
929
+ }
930
+ if (left.length !== right.length) {
931
+ throw new Error("Stereo channel lengths must match.");
932
+ }
933
+ return module.masterAudioStereoWithProgress(
934
+ presetName,
935
+ left,
936
+ right,
937
+ sampleRate,
938
+ overrides,
939
+ onProgress
940
+ );
941
+ }
761
942
  function mixingScenePresetNames() {
762
943
  if (!module) {
763
944
  throw new Error("Module not initialized. Call init() first.");
764
945
  }
765
946
  return module.mixingScenePresetNames();
766
947
  }
767
- function mixingScenePresetJson(preset) {
948
+ function mixingScenePresetJson(presetName) {
768
949
  if (!module) {
769
950
  throw new Error("Module not initialized. Call init() first.");
770
951
  }
771
- return module.mixingScenePresetJson(preset);
952
+ return module.mixingScenePresetJson(presetName);
772
953
  }
773
954
  function mixStereo(leftChannels, rightChannels, sampleRate = 48e3, options = {}) {
774
955
  if (!module) {
@@ -979,11 +1160,158 @@ var StreamingRetune = class {
979
1160
  this.retune.delete();
980
1161
  }
981
1162
  };
982
- function mixerScenePresetJson(preset) {
1163
+ var RealtimeVoiceChanger = class {
1164
+ constructor(config = "neutral-monitor") {
1165
+ if (!module) {
1166
+ throw new Error("Module not initialized. Call init() first.");
1167
+ }
1168
+ this.changer = module.createRealtimeVoiceChanger(config);
1169
+ }
1170
+ prepare(sampleRate, maxBlockSize = 128, channels = 1) {
1171
+ this.changer.prepare(sampleRate, maxBlockSize, channels);
1172
+ }
1173
+ reset() {
1174
+ this.changer.reset();
1175
+ }
1176
+ setConfig(config) {
1177
+ this.changer.setConfig(config);
1178
+ }
1179
+ configJson() {
1180
+ return this.changer.configJson();
1181
+ }
1182
+ latencySamples() {
1183
+ return this.changer.latencySamples();
1184
+ }
1185
+ processMono(samples) {
1186
+ return this.changer.processMono(samples);
1187
+ }
1188
+ processMonoInto(samples, output) {
1189
+ this.changer.processMonoInto(samples, output);
1190
+ }
1191
+ processInterleaved(samples, channels) {
1192
+ return this.changer.processInterleaved(samples, channels);
1193
+ }
1194
+ processInterleavedInto(samples, channels, output) {
1195
+ this.changer.processInterleavedInto(samples, channels, output);
1196
+ }
1197
+ /**
1198
+ * Acquire a typed-memory view onto the WASM heap for mono input.
1199
+ *
1200
+ * Write your input samples into the returned `Float32Array` directly (e.g.
1201
+ * via `input.set(source)`); no copy crosses the JS↔C++ bridge until
1202
+ * {@link processPreparedMono} is called. The view is owned by this
1203
+ * RealtimeVoiceChanger and becomes invalid after {@link delete}; it may
1204
+ * also be invalidated if you later call this method with a larger
1205
+ * `numSamples` value (the underlying buffer may be reallocated).
1206
+ */
1207
+ getMonoInputBuffer(numSamples) {
1208
+ return this.changer.getMonoInputBuffer(numSamples);
1209
+ }
1210
+ /** Mono output view counterpart to {@link getMonoInputBuffer}. */
1211
+ getMonoOutputBuffer(numSamples) {
1212
+ return this.changer.getMonoOutputBuffer(numSamples);
1213
+ }
1214
+ /**
1215
+ * Process the previously-acquired mono input buffer in place. The output
1216
+ * appears in the buffer returned by {@link getMonoOutputBuffer}. No JS↔C++
1217
+ * sample-level crossings happen on this call — it just hands control to
1218
+ * the underlying DSP on already-on-heap data.
1219
+ */
1220
+ processPreparedMono(numSamples) {
1221
+ this.changer.processPreparedMono(numSamples);
1222
+ }
1223
+ /** Interleaved input view (layout L0,R0,L1,R1,...). */
1224
+ getInterleavedInputBuffer(numFrames, numChannels) {
1225
+ return this.changer.getInterleavedInputBuffer(numFrames, numChannels);
1226
+ }
1227
+ /** Interleaved output view counterpart. */
1228
+ getInterleavedOutputBuffer(numFrames, numChannels) {
1229
+ return this.changer.getInterleavedOutputBuffer(numFrames, numChannels);
1230
+ }
1231
+ /**
1232
+ * Process the previously-acquired interleaved buffer in place. Output
1233
+ * appears in the buffer returned by {@link getInterleavedOutputBuffer}.
1234
+ */
1235
+ processPreparedInterleaved(numFrames, numChannels) {
1236
+ this.changer.processPreparedInterleaved(numFrames, numChannels);
1237
+ }
1238
+ /**
1239
+ * Planar-channel input/output view (one Float32Array per channel). Matches
1240
+ * AudioWorklet's native layout; processing happens in place.
1241
+ */
1242
+ getPlanarChannelBuffer(channel, numFrames) {
1243
+ return this.changer.getPlanarChannelBuffer(channel, numFrames);
1244
+ }
1245
+ /**
1246
+ * Process the previously-acquired planar channel buffers in place. Each
1247
+ * channel must have been obtained from {@link getPlanarChannelBuffer}
1248
+ * with the same `numFrames`. Output replaces input in the same buffers.
1249
+ */
1250
+ processPreparedPlanar(numFrames) {
1251
+ this.changer.processPreparedPlanar(numFrames);
1252
+ }
1253
+ /**
1254
+ * Convenience factory for the mono zero-copy path: returns the input/output
1255
+ * heap views plus a `process()` thunk wired to the same `numSamples`. The
1256
+ * views are reused across calls and become invalid after {@link delete}.
1257
+ */
1258
+ createRealtimeMonoBuffer(numSamples) {
1259
+ const input = this.getMonoInputBuffer(numSamples);
1260
+ const output = this.getMonoOutputBuffer(numSamples);
1261
+ return {
1262
+ input,
1263
+ output,
1264
+ process: () => this.processPreparedMono(numSamples)
1265
+ };
1266
+ }
1267
+ /** Same as {@link createRealtimeMonoBuffer} but for interleaved I/O. */
1268
+ createRealtimeInterleavedBuffer(numFrames, numChannels) {
1269
+ const input = this.getInterleavedInputBuffer(numFrames, numChannels);
1270
+ const output = this.getInterleavedOutputBuffer(numFrames, numChannels);
1271
+ return {
1272
+ input,
1273
+ output,
1274
+ channels: numChannels,
1275
+ process: () => this.processPreparedInterleaved(numFrames, numChannels)
1276
+ };
1277
+ }
1278
+ /**
1279
+ * Convenience factory for the planar zero-copy path. Acquires one
1280
+ * heap-backed Float32Array per channel and returns a `process()` thunk
1281
+ * wired to the same `numFrames`. Buffers are reused across calls and
1282
+ * become invalid after {@link delete}.
1283
+ */
1284
+ createRealtimePlanarBuffer(numFrames, numChannels) {
1285
+ const channels = [];
1286
+ for (let ch = 0; ch < numChannels; ch++) {
1287
+ channels.push(this.getPlanarChannelBuffer(ch, numFrames));
1288
+ }
1289
+ return {
1290
+ channels,
1291
+ process: () => this.processPreparedPlanar(numFrames)
1292
+ };
1293
+ }
1294
+ delete() {
1295
+ this.changer.delete();
1296
+ }
1297
+ };
1298
+ function realtimeVoiceChangerPresetNames() {
1299
+ if (!module) {
1300
+ throw new Error("Module not initialized. Call init() first.");
1301
+ }
1302
+ return module.realtimeVoiceChangerPresetNames();
1303
+ }
1304
+ function realtimeVoiceChangerPresetJson(name) {
983
1305
  if (!module) {
984
1306
  throw new Error("Module not initialized. Call init() first.");
985
1307
  }
986
- return module.mixerPresetJson(preset);
1308
+ return module.realtimeVoiceChangerPresetJson(name);
1309
+ }
1310
+ function validateRealtimeVoiceChangerPresetJson(json) {
1311
+ if (!module) {
1312
+ throw new Error("Module not initialized. Call init() first.");
1313
+ }
1314
+ return module.validateRealtimeVoiceChangerPresetJson(json);
987
1315
  }
988
1316
  var Mixer = class _Mixer {
989
1317
  constructor(mixer) {
@@ -1128,6 +1456,26 @@ var Mixer = class _Mixer {
1128
1456
  vcaGroupCount() {
1129
1457
  return this.mixer.vcaGroupCount();
1130
1458
  }
1459
+ /** Set the strip's input trim in dB. */
1460
+ setInputTrimDb(stripIndex, db) {
1461
+ this.mixer.setInputTrimDb(stripIndex, db);
1462
+ }
1463
+ /** Set the strip's fader level in dB. */
1464
+ setFaderDb(stripIndex, db) {
1465
+ this.mixer.setFaderDb(stripIndex, db);
1466
+ }
1467
+ /** Set the strip's pan position. */
1468
+ setPan(stripIndex, pan, panMode = 0) {
1469
+ this.mixer.setPan(stripIndex, pan, panModeCode(panMode));
1470
+ }
1471
+ /** Set the strip's stereo width. */
1472
+ setWidth(stripIndex, width) {
1473
+ this.mixer.setWidth(stripIndex, width);
1474
+ }
1475
+ /** Set the strip's mute state. */
1476
+ setMuted(stripIndex, muted) {
1477
+ this.mixer.setMuted(stripIndex, muted);
1478
+ }
1131
1479
  /**
1132
1480
  * Set a strip's solo state. Takes effect on the next process without a
1133
1481
  * graph recompile.
@@ -1278,37 +1626,37 @@ function trim(samples, sampleRate, thresholdDb = -60) {
1278
1626
  }
1279
1627
  return module.trim(samples, sampleRate, thresholdDb);
1280
1628
  }
1281
- function stft(samples, sampleRate, nFft = 2048, hopLength = 512) {
1629
+ function stft(samples, sampleRate = 22050, nFft = 2048, hopLength = 512) {
1282
1630
  if (!module) {
1283
1631
  throw new Error("Module not initialized. Call init() first.");
1284
1632
  }
1285
1633
  return module.stft(samples, sampleRate, nFft, hopLength);
1286
1634
  }
1287
- function stftDb(samples, sampleRate, nFft = 2048, hopLength = 512) {
1635
+ function stftDb(samples, sampleRate = 22050, nFft = 2048, hopLength = 512) {
1288
1636
  if (!module) {
1289
1637
  throw new Error("Module not initialized. Call init() first.");
1290
1638
  }
1291
1639
  return module.stftDb(samples, sampleRate, nFft, hopLength);
1292
1640
  }
1293
- function melSpectrogram(samples, sampleRate, nFft = 2048, hopLength = 512, nMels = 128) {
1641
+ function melSpectrogram(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, nMels = 128) {
1294
1642
  if (!module) {
1295
1643
  throw new Error("Module not initialized. Call init() first.");
1296
1644
  }
1297
1645
  return module.melSpectrogram(samples, sampleRate, nFft, hopLength, nMels);
1298
1646
  }
1299
- function mfcc(samples, sampleRate, nFft = 2048, hopLength = 512, nMels = 128, nMfcc = 13) {
1647
+ function mfcc(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, nMels = 128, nMfcc = 20) {
1300
1648
  if (!module) {
1301
1649
  throw new Error("Module not initialized. Call init() first.");
1302
1650
  }
1303
1651
  return module.mfcc(samples, sampleRate, nFft, hopLength, nMels, nMfcc);
1304
1652
  }
1305
- function melToStft(melPower, nMels, nFrames, sampleRate, nFft = 2048, hopLength = 512, fmin = 0, fmax = 0) {
1653
+ function melToStft(melPower, nMels, nFrames, sampleRate = 22050, nFft = 2048, fmin = 0, fmax = 0) {
1306
1654
  if (!module) {
1307
1655
  throw new Error("Module not initialized. Call init() first.");
1308
1656
  }
1309
- return module.melToStft(melPower, nMels, nFrames, sampleRate, nFft, hopLength, fmin, fmax);
1657
+ return module.melToStft(melPower, nMels, nFrames, sampleRate, nFft, fmin, fmax);
1310
1658
  }
1311
- function melToAudio(melPower, nMels, nFrames, sampleRate, nFft = 2048, hopLength = 512, nIter = 32, fmin = 0, fmax = 0) {
1659
+ function melToAudio(melPower, nMels, nFrames, sampleRate = 22050, nFft = 2048, hopLength = 512, fmin = 0, fmax = 0, nIter = 32) {
1312
1660
  if (!module) {
1313
1661
  throw new Error("Module not initialized. Call init() first.");
1314
1662
  }
@@ -1319,9 +1667,9 @@ function melToAudio(melPower, nMels, nFrames, sampleRate, nFft = 2048, hopLength
1319
1667
  sampleRate,
1320
1668
  nFft,
1321
1669
  hopLength,
1322
- nIter,
1323
1670
  fmin,
1324
- fmax
1671
+ fmax,
1672
+ nIter
1325
1673
  );
1326
1674
  }
1327
1675
  function mfccToMel(mfccCoefficients, nMfcc, nFrames, nMels = 128) {
@@ -1330,7 +1678,7 @@ function mfccToMel(mfccCoefficients, nMfcc, nFrames, nMels = 128) {
1330
1678
  }
1331
1679
  return module.mfccToMel(mfccCoefficients, nMfcc, nFrames, nMels);
1332
1680
  }
1333
- function mfccToAudio(mfccCoefficients, nMfcc, nFrames, nMels, sampleRate, nFft = 2048, hopLength = 512, nIter = 32, fmin = 0, fmax = 0) {
1681
+ function mfccToAudio(mfccCoefficients, nMfcc, nFrames, nMels = 128, sampleRate = 22050, nFft = 2048, hopLength = 512, fmin = 0, fmax = 0, nIter = 32) {
1334
1682
  if (!module) {
1335
1683
  throw new Error("Module not initialized. Call init() first.");
1336
1684
  }
@@ -1342,64 +1690,155 @@ function mfccToAudio(mfccCoefficients, nMfcc, nFrames, nMels, sampleRate, nFft =
1342
1690
  sampleRate,
1343
1691
  nFft,
1344
1692
  hopLength,
1345
- nIter,
1346
1693
  fmin,
1347
- fmax
1694
+ fmax,
1695
+ nIter
1348
1696
  );
1349
1697
  }
1350
- function chroma(samples, sampleRate, nFft = 2048, hopLength = 512) {
1698
+ function chroma(samples, sampleRate = 22050, nFft = 2048, hopLength = 512) {
1351
1699
  if (!module) {
1352
1700
  throw new Error("Module not initialized. Call init() first.");
1353
1701
  }
1354
1702
  return module.chroma(samples, sampleRate, nFft, hopLength);
1355
1703
  }
1356
- function spectralCentroid(samples, sampleRate, nFft = 2048, hopLength = 512) {
1704
+ function spectralCentroid(samples, sampleRate = 22050, nFft = 2048, hopLength = 512) {
1357
1705
  if (!module) {
1358
1706
  throw new Error("Module not initialized. Call init() first.");
1359
1707
  }
1360
1708
  return module.spectralCentroid(samples, sampleRate, nFft, hopLength);
1361
1709
  }
1362
- function spectralBandwidth(samples, sampleRate, nFft = 2048, hopLength = 512) {
1710
+ function spectralContrast(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, nBands = 6, fmin = 200, quantile = 0.02) {
1711
+ if (!module) {
1712
+ throw new Error("Module not initialized. Call init() first.");
1713
+ }
1714
+ return module.spectralContrast(samples, sampleRate, nFft, hopLength, nBands, fmin, quantile);
1715
+ }
1716
+ function polyFeatures(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, order = 1) {
1717
+ if (!module) {
1718
+ throw new Error("Module not initialized. Call init() first.");
1719
+ }
1720
+ return module.polyFeatures(samples, sampleRate, nFft, hopLength, order);
1721
+ }
1722
+ function zeroCrossings(samples, threshold = 1e-10, refMagnitude = false, pad = true, zeroPos = true) {
1723
+ if (!module) {
1724
+ throw new Error("Module not initialized. Call init() first.");
1725
+ }
1726
+ return module.zeroCrossings(samples, threshold, refMagnitude, pad, zeroPos);
1727
+ }
1728
+ function pitchTuning(frequencies, resolution = 0.01, binsPerOctave = 12) {
1729
+ if (!module) {
1730
+ throw new Error("Module not initialized. Call init() first.");
1731
+ }
1732
+ return module.pitchTuning(frequencies, resolution, binsPerOctave);
1733
+ }
1734
+ function estimateTuning(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, resolution = 0.01, binsPerOctave = 12) {
1735
+ if (!module) {
1736
+ throw new Error("Module not initialized. Call init() first.");
1737
+ }
1738
+ return module.estimateTuning(samples, sampleRate, nFft, hopLength, resolution, binsPerOctave);
1739
+ }
1740
+ function decompose(s, nFeatures, nFrames, nComponents, nIter = 50, beta = 2) {
1741
+ if (!module) {
1742
+ throw new Error("Module not initialized. Call init() first.");
1743
+ }
1744
+ return module.decompose(s, nFeatures, nFrames, nComponents, nIter, beta);
1745
+ }
1746
+ function nnFilter(s, nFeatures, nFrames, aggregate = "mean", k = 7, width = 1) {
1747
+ if (!module) {
1748
+ throw new Error("Module not initialized. Call init() first.");
1749
+ }
1750
+ return module.nnFilter(s, nFeatures, nFrames, aggregate, k, width);
1751
+ }
1752
+ function remix(samples, intervals, sampleRate = 22050, alignZeros = false) {
1753
+ if (!module) {
1754
+ throw new Error("Module not initialized. Call init() first.");
1755
+ }
1756
+ const intervalsI32 = intervals instanceof Int32Array ? intervals : Int32Array.from(intervals, (v) => Math.trunc(v));
1757
+ return module.remix(samples, intervalsI32, sampleRate, alignZeros);
1758
+ }
1759
+ function phaseVocoder(samples, rate, sampleRate = 22050, nFft = 2048, hopLength = 512) {
1760
+ if (!module) {
1761
+ throw new Error("Module not initialized. Call init() first.");
1762
+ }
1763
+ return module.phaseVocoder(samples, sampleRate, rate, nFft, hopLength);
1764
+ }
1765
+ function hpssWithResidual(samples, sampleRate = 22050, kernelHarmonic = 31, kernelPercussive = 31) {
1766
+ if (!module) {
1767
+ throw new Error("Module not initialized. Call init() first.");
1768
+ }
1769
+ return module.hpssWithResidual(samples, sampleRate, kernelHarmonic, kernelPercussive);
1770
+ }
1771
+ function lufsInterleaved(samples, channels, sampleRate = 22050) {
1772
+ if (!module) {
1773
+ throw new Error("Module not initialized. Call init() first.");
1774
+ }
1775
+ return module.lufsInterleaved(samples, channels, sampleRate);
1776
+ }
1777
+ function ebur128LoudnessRange(samples, sampleRate = 22050) {
1778
+ if (!module) {
1779
+ throw new Error("Module not initialized. Call init() first.");
1780
+ }
1781
+ return module.ebur128LoudnessRange(samples, sampleRate);
1782
+ }
1783
+ function spectralBandwidth(samples, sampleRate = 22050, nFft = 2048, hopLength = 512) {
1363
1784
  if (!module) {
1364
1785
  throw new Error("Module not initialized. Call init() first.");
1365
1786
  }
1366
1787
  return module.spectralBandwidth(samples, sampleRate, nFft, hopLength);
1367
1788
  }
1368
- function spectralRolloff(samples, sampleRate, nFft = 2048, hopLength = 512, rollPercent = 0.85) {
1789
+ function spectralRolloff(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, rollPercent = 0.85) {
1369
1790
  if (!module) {
1370
1791
  throw new Error("Module not initialized. Call init() first.");
1371
1792
  }
1372
1793
  return module.spectralRolloff(samples, sampleRate, nFft, hopLength, rollPercent);
1373
1794
  }
1374
- function spectralFlatness(samples, sampleRate, nFft = 2048, hopLength = 512) {
1795
+ function spectralFlatness(samples, sampleRate = 22050, nFft = 2048, hopLength = 512) {
1375
1796
  if (!module) {
1376
1797
  throw new Error("Module not initialized. Call init() first.");
1377
1798
  }
1378
1799
  return module.spectralFlatness(samples, sampleRate, nFft, hopLength);
1379
1800
  }
1380
- function zeroCrossingRate(samples, sampleRate, frameLength = 2048, hopLength = 512) {
1801
+ function zeroCrossingRate(samples, sampleRate = 22050, frameLength = 2048, hopLength = 512) {
1381
1802
  if (!module) {
1382
1803
  throw new Error("Module not initialized. Call init() first.");
1383
1804
  }
1384
1805
  return module.zeroCrossingRate(samples, sampleRate, frameLength, hopLength);
1385
1806
  }
1386
- function rmsEnergy(samples, sampleRate, frameLength = 2048, hopLength = 512) {
1807
+ function rmsEnergy(samples, sampleRate = 22050, frameLength = 2048, hopLength = 512) {
1387
1808
  if (!module) {
1388
1809
  throw new Error("Module not initialized. Call init() first.");
1389
1810
  }
1390
1811
  return module.rmsEnergy(samples, sampleRate, frameLength, hopLength);
1391
1812
  }
1392
- function pitchYin(samples, sampleRate, frameLength = 2048, hopLength = 512, fmin = 65, fmax = 2093, threshold = 0.3) {
1813
+ function pitchYin(samples, sampleRate = 22050, frameLength = 2048, hopLength = 512, fmin = 65, fmax = 2093, threshold = 0.3, fillNa = false) {
1393
1814
  if (!module) {
1394
1815
  throw new Error("Module not initialized. Call init() first.");
1395
1816
  }
1396
- return module.pitchYin(samples, sampleRate, frameLength, hopLength, fmin, fmax, threshold);
1817
+ return module.pitchYin(
1818
+ samples,
1819
+ sampleRate,
1820
+ frameLength,
1821
+ hopLength,
1822
+ fmin,
1823
+ fmax,
1824
+ threshold,
1825
+ fillNa
1826
+ );
1397
1827
  }
1398
- function pitchPyin(samples, sampleRate, frameLength = 2048, hopLength = 512, fmin = 65, fmax = 2093, threshold = 0.3) {
1828
+ function pitchPyin(samples, sampleRate = 22050, frameLength = 2048, hopLength = 512, fmin = 65, fmax = 2093, threshold = 0.3, fillNa = false) {
1399
1829
  if (!module) {
1400
1830
  throw new Error("Module not initialized. Call init() first.");
1401
1831
  }
1402
- return module.pitchPyin(samples, sampleRate, frameLength, hopLength, fmin, fmax, threshold);
1832
+ return module.pitchPyin(
1833
+ samples,
1834
+ sampleRate,
1835
+ frameLength,
1836
+ hopLength,
1837
+ fmin,
1838
+ fmax,
1839
+ threshold,
1840
+ fillNa
1841
+ );
1403
1842
  }
1404
1843
  function hzToMel(hz) {
1405
1844
  if (!module) {
@@ -1437,13 +1876,13 @@ function noteToHz(note) {
1437
1876
  }
1438
1877
  return module.noteToHz(note);
1439
1878
  }
1440
- function framesToTime(frames, sr, hopLength) {
1879
+ function framesToTime(frames, sr = 22050, hopLength = 512) {
1441
1880
  if (!module) {
1442
1881
  throw new Error("Module not initialized. Call init() first.");
1443
1882
  }
1444
1883
  return module.framesToTime(frames, sr, hopLength);
1445
1884
  }
1446
- function timeToFrames(time, sr, hopLength) {
1885
+ function timeToFrames(time, sr = 22050, hopLength = 512) {
1447
1886
  if (!module) {
1448
1887
  throw new Error("Module not initialized. Call init() first.");
1449
1888
  }
@@ -1515,17 +1954,17 @@ function frameSignal(samples, frameLength, hopLength) {
1515
1954
  }
1516
1955
  return module.frameSignal(samples, frameLength, hopLength);
1517
1956
  }
1518
- function padCenter(values, size, padValue = 0) {
1957
+ function padCenter(values, targetSize, padValue = 0) {
1519
1958
  if (!module) {
1520
1959
  throw new Error("Module not initialized. Call init() first.");
1521
1960
  }
1522
- return module.padCenter(values, size, padValue);
1961
+ return module.padCenter(values, targetSize, padValue);
1523
1962
  }
1524
- function fixLength(values, size, padValue = 0) {
1963
+ function fixLength(values, targetSize, padValue = 0) {
1525
1964
  if (!module) {
1526
1965
  throw new Error("Module not initialized. Call init() first.");
1527
1966
  }
1528
- return module.fixLength(values, size, padValue);
1967
+ return module.fixLength(values, targetSize, padValue);
1529
1968
  }
1530
1969
  function fixFrames(frames, xMin = 0, xMax = -1, pad = true) {
1531
1970
  if (!module) {
@@ -1539,7 +1978,7 @@ function peakPick(values, preMax, postMax, preAvg, postAvg, delta, wait) {
1539
1978
  }
1540
1979
  return module.peakPick(values, preMax, postMax, preAvg, postAvg, delta, wait);
1541
1980
  }
1542
- function vectorNormalize(values, normType = 0, threshold = 1e-12) {
1981
+ function vectorNormalize(values, normType = 0, threshold = 0) {
1543
1982
  if (!module) {
1544
1983
  throw new Error("Module not initialized. Call init() first.");
1545
1984
  }
@@ -1557,19 +1996,19 @@ function tonnetz(chromagram, nChroma, nFrames) {
1557
1996
  }
1558
1997
  return module.tonnetz(chromagram, nChroma, nFrames);
1559
1998
  }
1560
- function tempogram(onsetEnvelope2, sampleRate, hopLength = 512, winLength = 384, mode = "autocorrelation") {
1999
+ function tempogram(onsetEnvelope2, sampleRate = 22050, hopLength = 512, winLength = 384, mode = "autocorrelation") {
1561
2000
  if (!module) {
1562
2001
  throw new Error("Module not initialized. Call init() first.");
1563
2002
  }
1564
2003
  return module.tempogram(onsetEnvelope2, sampleRate, hopLength, winLength, mode);
1565
2004
  }
1566
- function cyclicTempogram(onsetEnvelope2, sampleRate, hopLength = 512, winLength = 384, bpmMin = 60, nBins = 60) {
2005
+ function cyclicTempogram(onsetEnvelope2, sampleRate = 22050, hopLength = 512, winLength = 384, bpmMin = 60, nBins = 60) {
1567
2006
  if (!module) {
1568
2007
  throw new Error("Module not initialized. Call init() first.");
1569
2008
  }
1570
2009
  return module.cyclicTempogram(onsetEnvelope2, sampleRate, hopLength, winLength, bpmMin, nBins);
1571
2010
  }
1572
- function plp(onsetEnvelope2, sampleRate, hopLength = 512, tempoMin = 30, tempoMax = 300, winLength = 384) {
2011
+ function plp(onsetEnvelope2, sampleRate = 22050, hopLength = 512, tempoMin = 30, tempoMax = 300, winLength = 384) {
1573
2012
  if (!module) {
1574
2013
  throw new Error("Module not initialized. Call init() first.");
1575
2014
  }
@@ -1593,13 +2032,13 @@ function vqt(samples, sampleRate = 22050, hopLength = 512, fmin = 32.70319566257
1593
2032
  }
1594
2033
  return module.vqt(samples, sampleRate, hopLength, fmin, nBins, binsPerOctave, gamma);
1595
2034
  }
1596
- function analyzeSections(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, minSectionSec = 8) {
2035
+ function analyzeSections(samples, sampleRate = 22050, nFft = 2048, hopLength = 512, minSectionSec = 4) {
1597
2036
  if (!module) {
1598
2037
  throw new Error("Module not initialized. Call init() first.");
1599
2038
  }
1600
2039
  return module.analyzeSections(samples, sampleRate, nFft, hopLength, minSectionSec).map((s) => ({ ...s, type: s.type }));
1601
2040
  }
1602
- function analyzeMelody(samples, sampleRate = 22050, fmin = 65, fmax = 2093, frameLength = 2048, hopLength = 512, threshold = 0.1) {
2041
+ function analyzeMelody(samples, sampleRate = 22050, fmin = 65, fmax = 2093, frameLength = 2048, hopLength = 256, threshold = 0.1) {
1603
2042
  if (!module) {
1604
2043
  throw new Error("Module not initialized. Call init() first.");
1605
2044
  }
@@ -1623,24 +2062,110 @@ function tempogramRatio(tempogramData, winLength = 384, sampleRate = 22050, hopL
1623
2062
  }
1624
2063
  return module.tempogramRatio(tempogramData, winLength, sampleRate, hopLength);
1625
2064
  }
1626
- function lufs(samples, sampleRate = 22050) {
2065
+ function lufs(samples, sampleRate = 22050, options = {}) {
1627
2066
  if (!module) {
1628
2067
  throw new Error("Module not initialized. Call init() first.");
1629
2068
  }
2069
+ assertSamples("lufs", samples, options.validate !== false);
1630
2070
  return module.lufs(samples, sampleRate);
1631
2071
  }
1632
- function momentaryLufs(samples, sampleRate = 22050) {
2072
+ function momentaryLufs(samples, sampleRate = 22050, options = {}) {
1633
2073
  if (!module) {
1634
2074
  throw new Error("Module not initialized. Call init() first.");
1635
2075
  }
2076
+ assertSamples("momentaryLufs", samples, options.validate !== false);
1636
2077
  return module.momentaryLufs(samples, sampleRate);
1637
2078
  }
1638
- function shortTermLufs(samples, sampleRate = 22050) {
2079
+ function shortTermLufs(samples, sampleRate = 22050, options = {}) {
1639
2080
  if (!module) {
1640
2081
  throw new Error("Module not initialized. Call init() first.");
1641
2082
  }
2083
+ assertSamples("shortTermLufs", samples, options.validate !== false);
1642
2084
  return module.shortTermLufs(samples, sampleRate);
1643
2085
  }
2086
+ function requireModule() {
2087
+ if (!module) {
2088
+ throw new Error("Module not initialized. Call init() first.");
2089
+ }
2090
+ return module;
2091
+ }
2092
+ function meteringPeakDb(samples, sampleRate = 22050, options = {}) {
2093
+ assertSamples("meteringPeakDb", samples, options.validate !== false);
2094
+ return requireModule().meteringPeakDb(samples, sampleRate);
2095
+ }
2096
+ function meteringRmsDb(samples, sampleRate = 22050, options = {}) {
2097
+ assertSamples("meteringRmsDb", samples, options.validate !== false);
2098
+ return requireModule().meteringRmsDb(samples, sampleRate);
2099
+ }
2100
+ function meteringCrestFactorDb(samples, sampleRate = 22050, options = {}) {
2101
+ assertSamples("meteringCrestFactorDb", samples, options.validate !== false);
2102
+ return requireModule().meteringCrestFactorDb(samples, sampleRate);
2103
+ }
2104
+ function meteringDcOffset(samples, sampleRate = 22050, options = {}) {
2105
+ assertSamples("meteringDcOffset", samples, options.validate !== false);
2106
+ return requireModule().meteringDcOffset(samples, sampleRate);
2107
+ }
2108
+ function meteringTruePeakDb(samples, sampleRate = 22050, oversampleFactor = 4, options = {}) {
2109
+ assertSamples("meteringTruePeakDb", samples, options.validate !== false);
2110
+ return requireModule().meteringTruePeakDb(samples, sampleRate, oversampleFactor);
2111
+ }
2112
+ function meteringDetectClipping(samples, sampleRate = 22050, threshold = 0.999, minRegionSamples = 1, options = {}) {
2113
+ assertSamples("meteringDetectClipping", samples, options.validate !== false);
2114
+ return requireModule().meteringDetectClipping(samples, sampleRate, threshold, minRegionSamples);
2115
+ }
2116
+ function meteringDynamicRange(samples, sampleRate = 22050, windowSec = 0, hopSec = 0, lowPercentile = 0, highPercentile = 0, options = {}) {
2117
+ assertSamples("meteringDynamicRange", samples, options.validate !== false);
2118
+ return requireModule().meteringDynamicRange(
2119
+ samples,
2120
+ sampleRate,
2121
+ windowSec,
2122
+ hopSec,
2123
+ lowPercentile,
2124
+ highPercentile
2125
+ );
2126
+ }
2127
+ function meteringStereoCorrelation(left, right, sampleRate = 22050, options = {}) {
2128
+ const validate = options.validate !== false;
2129
+ assertSamples("meteringStereoCorrelation", left, validate, "left");
2130
+ assertSamples("meteringStereoCorrelation", right, validate, "right");
2131
+ return requireModule().meteringStereoCorrelation(left, right, sampleRate);
2132
+ }
2133
+ function meteringStereoWidth(left, right, sampleRate = 22050, options = {}) {
2134
+ const validate = options.validate !== false;
2135
+ assertSamples("meteringStereoWidth", left, validate, "left");
2136
+ assertSamples("meteringStereoWidth", right, validate, "right");
2137
+ return requireModule().meteringStereoWidth(left, right, sampleRate);
2138
+ }
2139
+ function meteringVectorscope(left, right, sampleRate = 22050, options = {}) {
2140
+ const validate = options.validate !== false;
2141
+ assertSamples("meteringVectorscope", left, validate, "left");
2142
+ assertSamples("meteringVectorscope", right, validate, "right");
2143
+ return requireModule().meteringVectorscope(left, right, sampleRate);
2144
+ }
2145
+ function meteringPhaseScope(left, right, sampleRate = 22050, options = {}) {
2146
+ const validate = options.validate !== false;
2147
+ assertSamples("meteringPhaseScope", left, validate, "left");
2148
+ assertSamples("meteringPhaseScope", right, validate, "right");
2149
+ return requireModule().meteringPhaseScope(left, right, sampleRate);
2150
+ }
2151
+ function meteringSpectrum(samples, sampleRate = 22050, options) {
2152
+ const validate = options?.validate !== false;
2153
+ assertSamples("meteringSpectrum", samples, validate);
2154
+ return requireModule().meteringSpectrum(samples, sampleRate, options ?? {});
2155
+ }
2156
+ function scaleQuantizeMidi(root, modeMask, midi, referenceMidi = 0) {
2157
+ assertFiniteScalar("scaleQuantizeMidi", midi, "midi");
2158
+ assertFiniteScalar("scaleQuantizeMidi", referenceMidi, "referenceMidi");
2159
+ return requireModule().scaleQuantizeMidi(root, modeMask, midi, referenceMidi);
2160
+ }
2161
+ function scaleCorrectionSemitones(root, modeMask, midi, referenceMidi = 0) {
2162
+ assertFiniteScalar("scaleCorrectionSemitones", midi, "midi");
2163
+ assertFiniteScalar("scaleCorrectionSemitones", referenceMidi, "referenceMidi");
2164
+ return requireModule().scaleCorrectionSemitones(root, modeMask, midi, referenceMidi);
2165
+ }
2166
+ function scalePitchClassEnabled(root, modeMask, pitchClass) {
2167
+ return requireModule().scalePitchClassEnabled(root, modeMask, pitchClass);
2168
+ }
1644
2169
  function resample(samples, srcSr, targetSr) {
1645
2170
  if (!module) {
1646
2171
  throw new Error("Module not initialized. Call init() first.");
@@ -1716,13 +2241,13 @@ var Audio = class _Audio {
1716
2241
  pitchShift(semitones) {
1717
2242
  return pitchShift(this._samples, this._sampleRate, semitones);
1718
2243
  }
1719
- pitchCorrectToMidi(currentMidi, targetMidi) {
2244
+ pitchCorrectToMidi(currentMidi = 69, targetMidi = 69) {
1720
2245
  return pitchCorrectToMidi(this._samples, this._sampleRate, currentMidi, targetMidi);
1721
2246
  }
1722
- noteStretch(onsetSample, offsetSample, stretchRatio) {
2247
+ noteStretch(onsetSample = 0, offsetSample = 0, stretchRatio = 1) {
1723
2248
  return noteStretch(this._samples, this._sampleRate, onsetSample, offsetSample, stretchRatio);
1724
2249
  }
1725
- voiceChange(pitchSemitones, formantFactor) {
2250
+ voiceChange(pitchSemitones = 0, formantFactor = 1) {
1726
2251
  return voiceChange(this._samples, this._sampleRate, pitchSemitones, formantFactor);
1727
2252
  }
1728
2253
  normalize(targetDb = 0) {
@@ -1753,7 +2278,7 @@ var Audio = class _Audio {
1753
2278
  melSpectrogram(nFft = 2048, hopLength = 512, nMels = 128) {
1754
2279
  return melSpectrogram(this._samples, this._sampleRate, nFft, hopLength, nMels);
1755
2280
  }
1756
- mfcc(nFft = 2048, hopLength = 512, nMels = 128, nMfcc = 13) {
2281
+ mfcc(nFft = 2048, hopLength = 512, nMels = 128, nMfcc = 20) {
1757
2282
  return mfcc(this._samples, this._sampleRate, nFft, hopLength, nMels, nMfcc);
1758
2283
  }
1759
2284
  chroma(nFft = 2048, hopLength = 512) {
@@ -1792,10 +2317,19 @@ var Audio = class _Audio {
1792
2317
  rmsEnergy(frameLength = 2048, hopLength = 512) {
1793
2318
  return rmsEnergy(this._samples, this._sampleRate, frameLength, hopLength);
1794
2319
  }
1795
- pitchYin(frameLength = 2048, hopLength = 512, fmin = 65, fmax = 2093, threshold = 0.3) {
1796
- return pitchYin(this._samples, this._sampleRate, frameLength, hopLength, fmin, fmax, threshold);
2320
+ pitchYin(frameLength = 2048, hopLength = 512, fmin = 65, fmax = 2093, threshold = 0.3, fillNa = false) {
2321
+ return pitchYin(
2322
+ this._samples,
2323
+ this._sampleRate,
2324
+ frameLength,
2325
+ hopLength,
2326
+ fmin,
2327
+ fmax,
2328
+ threshold,
2329
+ fillNa
2330
+ );
1797
2331
  }
1798
- pitchPyin(frameLength = 2048, hopLength = 512, fmin = 65, fmax = 2093, threshold = 0.3) {
2332
+ pitchPyin(frameLength = 2048, hopLength = 512, fmin = 65, fmax = 2093, threshold = 0.3, fillNa = false) {
1799
2333
  return pitchPyin(
1800
2334
  this._samples,
1801
2335
  this._sampleRate,
@@ -1803,7 +2337,8 @@ var Audio = class _Audio {
1803
2337
  hopLength,
1804
2338
  fmin,
1805
2339
  fmax,
1806
- threshold
2340
+ threshold,
2341
+ fillNa
1807
2342
  );
1808
2343
  }
1809
2344
  resample(targetSr) {
@@ -1820,8 +2355,7 @@ var StreamAnalyzer = class {
1820
2355
  if (!module) {
1821
2356
  throw new Error("Module not initialized. Call init() first.");
1822
2357
  }
1823
- const wasmModule = module;
1824
- const args = [
2358
+ this.analyzer = new module.StreamAnalyzer(
1825
2359
  config.sampleRate,
1826
2360
  config.nFft ?? 2048,
1827
2361
  config.hopLength ?? 512,
@@ -1840,44 +2374,7 @@ var StreamAnalyzer = class {
1840
2374
  config.bpmUpdateIntervalSec ?? 10,
1841
2375
  config.window ?? 0,
1842
2376
  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
- }
2377
+ );
1881
2378
  }
1882
2379
  /**
1883
2380
  * Process audio samples.
@@ -2046,6 +2543,7 @@ export {
2046
2543
  PitchClass as Pitch,
2047
2544
  PitchClass,
2048
2545
  RealtimeEngine,
2546
+ RealtimeVoiceChanger,
2049
2547
  SectionType,
2050
2548
  StreamAnalyzer,
2051
2549
  StreamingEqualizer,
@@ -2053,15 +2551,20 @@ export {
2053
2551
  StreamingRetune,
2054
2552
  amplitudeToDb,
2055
2553
  analyze,
2554
+ analyzeBpm,
2555
+ analyzeDynamics,
2056
2556
  analyzeImpulseResponse,
2057
2557
  analyzeMelody,
2558
+ analyzeRhythm,
2058
2559
  analyzeSections,
2560
+ analyzeTimbre,
2059
2561
  analyzeWithProgress,
2060
2562
  chroma,
2061
2563
  cqt,
2062
2564
  cyclicTempogram,
2063
2565
  dbToAmplitude,
2064
2566
  dbToPower,
2567
+ decompose,
2065
2568
  deemphasis,
2066
2569
  detectAcoustic,
2067
2570
  detectBeats,
@@ -2071,8 +2574,10 @@ export {
2071
2574
  detectKey,
2072
2575
  detectKeyCandidates,
2073
2576
  detectOnsets,
2577
+ ebur128LoudnessRange,
2074
2578
  engineAbiVersion,
2075
2579
  engineCapabilities,
2580
+ estimateTuning,
2076
2581
  fixFrames,
2077
2582
  fixLength,
2078
2583
  fourierTempogram,
@@ -2080,15 +2585,20 @@ export {
2080
2585
  framesToSamples,
2081
2586
  framesToTime,
2082
2587
  harmonic,
2588
+ hasFfmpegSupport,
2083
2589
  hpss,
2590
+ hpssWithResidual,
2084
2591
  hzToMel,
2085
2592
  hzToMidi,
2086
2593
  hzToNote,
2087
2594
  init,
2088
2595
  isInitialized,
2089
2596
  lufs,
2597
+ lufsInterleaved,
2090
2598
  masterAudio,
2091
2599
  masterAudioStereo,
2600
+ masterAudioStereoWithProgress,
2601
+ masterAudioWithProgress,
2092
2602
  mastering,
2093
2603
  masteringAssistantSuggest,
2094
2604
  masteringAudioProfile,
@@ -2096,6 +2606,9 @@ export {
2096
2606
  masteringChainStereo,
2097
2607
  masteringChainStereoWithProgress,
2098
2608
  masteringChainWithProgress,
2609
+ masteringDynamicsCompressor,
2610
+ masteringDynamicsGate,
2611
+ masteringDynamicsTransientShaper,
2099
2612
  masteringPairAnalysisNames,
2100
2613
  masteringPairAnalyze,
2101
2614
  masteringPairProcess,
@@ -2104,6 +2617,13 @@ export {
2104
2617
  masteringProcess,
2105
2618
  masteringProcessStereo,
2106
2619
  masteringProcessorNames,
2620
+ masteringRepairDeclick,
2621
+ masteringRepairDeclip,
2622
+ masteringRepairDecrackle,
2623
+ masteringRepairDehum,
2624
+ masteringRepairDenoiseClassical,
2625
+ masteringRepairDereverbClassical,
2626
+ masteringRepairTrimSilence,
2107
2627
  masteringStereoAnalysisNames,
2108
2628
  masteringStereoAnalyze,
2109
2629
  masteringStreamingPreview,
@@ -2111,15 +2631,27 @@ export {
2111
2631
  melToAudio,
2112
2632
  melToHz,
2113
2633
  melToStft,
2634
+ meteringCrestFactorDb,
2635
+ meteringDcOffset,
2636
+ meteringDetectClipping,
2637
+ meteringDynamicRange,
2638
+ meteringPeakDb,
2639
+ meteringPhaseScope,
2640
+ meteringRmsDb,
2641
+ meteringSpectrum,
2642
+ meteringStereoCorrelation,
2643
+ meteringStereoWidth,
2644
+ meteringTruePeakDb,
2645
+ meteringVectorscope,
2114
2646
  mfcc,
2115
2647
  mfccToAudio,
2116
2648
  mfccToMel,
2117
2649
  midiToHz,
2118
2650
  mixStereo,
2119
- mixerScenePresetJson,
2120
2651
  mixingScenePresetJson,
2121
2652
  mixingScenePresetNames,
2122
2653
  momentaryLufs,
2654
+ nnFilter,
2123
2655
  nnlsChroma,
2124
2656
  normalize,
2125
2657
  noteStretch,
@@ -2129,19 +2661,30 @@ export {
2129
2661
  pcen,
2130
2662
  peakPick,
2131
2663
  percussive,
2664
+ phaseVocoder,
2132
2665
  pitchCorrectToMidi,
2133
2666
  pitchPyin,
2134
2667
  pitchShift,
2668
+ pitchTuning,
2135
2669
  pitchYin,
2136
2670
  plp,
2671
+ polyFeatures,
2137
2672
  powerToDb,
2138
2673
  preemphasis,
2674
+ realtimeVoiceChangerPresetConfig,
2675
+ realtimeVoiceChangerPresetJson,
2676
+ realtimeVoiceChangerPresetNames,
2677
+ remix,
2139
2678
  resample,
2140
2679
  rmsEnergy,
2141
2680
  samplesToFrames,
2681
+ scaleCorrectionSemitones,
2682
+ scalePitchClassEnabled,
2683
+ scaleQuantizeMidi,
2142
2684
  shortTermLufs,
2143
2685
  spectralBandwidth,
2144
2686
  spectralCentroid,
2687
+ spectralContrast,
2145
2688
  spectralFlatness,
2146
2689
  spectralRolloff,
2147
2690
  splitSilence,
@@ -2154,10 +2697,14 @@ export {
2154
2697
  tonnetz,
2155
2698
  trim,
2156
2699
  trimSilence,
2700
+ validateRealtimeVoiceChangerPresetJson,
2157
2701
  vectorNormalize,
2158
2702
  version,
2159
2703
  voiceChange,
2704
+ voiceChangerAbiVersion,
2705
+ voiceCharacterPresetId,
2160
2706
  vqt,
2161
- zeroCrossingRate
2707
+ zeroCrossingRate,
2708
+ zeroCrossings
2162
2709
  };
2163
2710
  //# sourceMappingURL=index.js.map