@waveform-playlist/playout 12.5.0 → 12.5.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/README.md +28 -1
- package/dist/index.d.mts +14 -16
- package/dist/index.d.ts +14 -16
- package/dist/index.js +204 -134
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +175 -113
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -19,21 +19,12 @@ import {
|
|
|
19
19
|
getTransport,
|
|
20
20
|
getContext
|
|
21
21
|
} from "tone";
|
|
22
|
-
import { gainToDb } from "@waveform-playlist/core";
|
|
22
|
+
import { gainToDb, applyFadeIn, applyFadeOut } from "@waveform-playlist/core";
|
|
23
23
|
|
|
24
24
|
// src/fades.ts
|
|
25
|
-
import {
|
|
26
|
-
linearCurve,
|
|
27
|
-
exponentialCurve,
|
|
28
|
-
sCurveCurve,
|
|
29
|
-
logarithmicCurve,
|
|
30
|
-
generateCurve,
|
|
31
|
-
applyFadeIn,
|
|
32
|
-
applyFadeOut
|
|
33
|
-
} from "@waveform-playlist/core";
|
|
34
25
|
var hasWarned = false;
|
|
35
26
|
function getUnderlyingAudioParam(signal) {
|
|
36
|
-
const param = signal
|
|
27
|
+
const param = signal?._param;
|
|
37
28
|
if (!param && !hasWarned) {
|
|
38
29
|
hasWarned = true;
|
|
39
30
|
console.warn(
|
|
@@ -116,8 +107,7 @@ var ToneTrack = class {
|
|
|
116
107
|
source.start(audioContextTime, offset, duration);
|
|
117
108
|
} catch (err) {
|
|
118
109
|
console.warn(
|
|
119
|
-
`[waveform-playlist] Failed to start source on track "${this.id}" (time=${audioContextTime}, offset=${offset}, duration=${duration})
|
|
120
|
-
err
|
|
110
|
+
`[waveform-playlist] Failed to start source on track "${this.id}" (time=${audioContextTime}, offset=${offset}, duration=${duration}): ` + String(err)
|
|
121
111
|
);
|
|
122
112
|
source.disconnect();
|
|
123
113
|
return;
|
|
@@ -276,6 +266,10 @@ var ToneTrack = class {
|
|
|
276
266
|
clipInfo.offset + Math.max(0, elapsed),
|
|
277
267
|
clipInfo.duration - Math.max(0, elapsed)
|
|
278
268
|
);
|
|
269
|
+
this.scheduleFades(scheduled, audioContextTime, clipInfo.offset + Math.max(0, elapsed));
|
|
270
|
+
} else if (absClipStart >= transportOffset) {
|
|
271
|
+
const delay = absClipStart - transportOffset;
|
|
272
|
+
this.scheduleFades(scheduled, audioContextTime + delay, clipInfo.offset);
|
|
279
273
|
}
|
|
280
274
|
}
|
|
281
275
|
}
|
|
@@ -294,7 +288,9 @@ var ToneTrack = class {
|
|
|
294
288
|
try {
|
|
295
289
|
source.stop();
|
|
296
290
|
} catch (err) {
|
|
297
|
-
console.warn(
|
|
291
|
+
console.warn(
|
|
292
|
+
`[waveform-playlist] Error stopping source on track "${this.id}": ` + String(err)
|
|
293
|
+
);
|
|
298
294
|
}
|
|
299
295
|
});
|
|
300
296
|
this.activeSources.clear();
|
|
@@ -423,10 +419,16 @@ var ToneTrack = class {
|
|
|
423
419
|
'[waveform-playlist] Track "' + this.track.id + '" was built with a TrackEffectsFunction closure \u2014 transport effects hooks and closure effects are mutually exclusive.'
|
|
424
420
|
);
|
|
425
421
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
422
|
+
try {
|
|
423
|
+
if (this._effectsChainNode) {
|
|
424
|
+
this.muteGain.disconnect(this._effectsChainNode);
|
|
425
|
+
} else {
|
|
426
|
+
this.muteGain.disconnect(this._destination);
|
|
427
|
+
}
|
|
428
|
+
} catch (err) {
|
|
429
|
+
console.warn(
|
|
430
|
+
'[waveform-playlist] connectEffects disconnect on track "' + this.track.id + '": ' + String(err)
|
|
431
|
+
);
|
|
430
432
|
}
|
|
431
433
|
this.muteGain.connect(node);
|
|
432
434
|
this._effectsChainNode = node;
|
|
@@ -450,7 +452,9 @@ var ToneTrack = class {
|
|
|
450
452
|
try {
|
|
451
453
|
this.effectsCleanup();
|
|
452
454
|
} catch (err) {
|
|
453
|
-
console.warn(
|
|
455
|
+
console.warn(
|
|
456
|
+
`[waveform-playlist] Error during track "${this.id}" effects cleanup: ` + String(err)
|
|
457
|
+
);
|
|
454
458
|
}
|
|
455
459
|
}
|
|
456
460
|
this.stopAllSources();
|
|
@@ -459,42 +463,49 @@ var ToneTrack = class {
|
|
|
459
463
|
transport.clear(scheduled.scheduleId);
|
|
460
464
|
} catch (err) {
|
|
461
465
|
console.warn(
|
|
462
|
-
`[waveform-playlist] Error clearing schedule ${index} on track "${this.id}"
|
|
463
|
-
err
|
|
466
|
+
`[waveform-playlist] Error clearing schedule ${index} on track "${this.id}": ` + String(err)
|
|
464
467
|
);
|
|
465
468
|
}
|
|
466
469
|
try {
|
|
467
470
|
scheduled.fadeGainNode.disconnect();
|
|
468
471
|
} catch (err) {
|
|
469
472
|
console.warn(
|
|
470
|
-
`[waveform-playlist] Error disconnecting fadeGain ${index} on track "${this.id}"
|
|
471
|
-
err
|
|
473
|
+
`[waveform-playlist] Error disconnecting fadeGain ${index} on track "${this.id}": ` + String(err)
|
|
472
474
|
);
|
|
473
475
|
}
|
|
474
476
|
});
|
|
475
477
|
try {
|
|
476
478
|
this.volumeNode.dispose();
|
|
477
479
|
} catch (err) {
|
|
478
|
-
console.warn(
|
|
480
|
+
console.warn(
|
|
481
|
+
`[waveform-playlist] Error disposing volumeNode on track "${this.id}": ` + String(err)
|
|
482
|
+
);
|
|
479
483
|
}
|
|
480
484
|
try {
|
|
481
485
|
this.panNode.dispose();
|
|
482
486
|
} catch (err) {
|
|
483
|
-
console.warn(
|
|
487
|
+
console.warn(
|
|
488
|
+
`[waveform-playlist] Error disposing panNode on track "${this.id}": ` + String(err)
|
|
489
|
+
);
|
|
484
490
|
}
|
|
485
491
|
try {
|
|
486
492
|
this.muteGain.dispose();
|
|
487
493
|
} catch (err) {
|
|
488
|
-
console.warn(
|
|
494
|
+
console.warn(
|
|
495
|
+
`[waveform-playlist] Error disposing muteGain on track "${this.id}": ` + String(err)
|
|
496
|
+
);
|
|
489
497
|
}
|
|
490
498
|
}
|
|
491
499
|
get id() {
|
|
492
500
|
return this.track.id;
|
|
493
501
|
}
|
|
494
502
|
get duration() {
|
|
495
|
-
|
|
496
|
-
const
|
|
497
|
-
|
|
503
|
+
let max = 0;
|
|
504
|
+
for (const { clipInfo } of this.scheduledClips) {
|
|
505
|
+
const end = clipInfo.startTime + clipInfo.duration;
|
|
506
|
+
if (end > max) max = end;
|
|
507
|
+
}
|
|
508
|
+
return max;
|
|
498
509
|
}
|
|
499
510
|
get buffer() {
|
|
500
511
|
return this.scheduledClips[0]?.clipInfo.buffer;
|
|
@@ -635,8 +646,7 @@ var MidiToneTrack = class {
|
|
|
635
646
|
this.snareSynth.triggerAttackRelease(duration, time, velocity);
|
|
636
647
|
} catch (err) {
|
|
637
648
|
console.warn(
|
|
638
|
-
"[waveform-playlist] Snare overlap \u2014 previous hit still decaying, skipped:"
|
|
639
|
-
err
|
|
649
|
+
"[waveform-playlist] Snare overlap \u2014 previous hit still decaying, skipped: " + String(err)
|
|
640
650
|
);
|
|
641
651
|
}
|
|
642
652
|
break;
|
|
@@ -697,8 +707,7 @@ var MidiToneTrack = class {
|
|
|
697
707
|
);
|
|
698
708
|
} catch (err) {
|
|
699
709
|
console.warn(
|
|
700
|
-
`[waveform-playlist] Failed to start mid-clip MIDI note "${note.name}" on track "${this.id}"
|
|
701
|
-
err
|
|
710
|
+
`[waveform-playlist] Failed to start mid-clip MIDI note "${note.name}" on track "${this.id}": ` + String(err)
|
|
702
711
|
);
|
|
703
712
|
}
|
|
704
713
|
}
|
|
@@ -711,14 +720,19 @@ var MidiToneTrack = class {
|
|
|
711
720
|
*/
|
|
712
721
|
stopAllSources() {
|
|
713
722
|
const now3 = getContext2().rawContext.currentTime;
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
723
|
+
const release = (label, fn) => {
|
|
724
|
+
try {
|
|
725
|
+
fn();
|
|
726
|
+
} catch (err) {
|
|
727
|
+
console.warn(
|
|
728
|
+
`[waveform-playlist] Error releasing ${label} synth on track "${this.id}": ` + String(err)
|
|
729
|
+
);
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
release("melodic", () => this.synth.releaseAll(now3));
|
|
733
|
+
release("kick", () => this.kickSynth.releaseAll(now3));
|
|
734
|
+
release("cymbal", () => this.cymbalSynth.releaseAll(now3));
|
|
735
|
+
release("tom", () => this.tomSynth.releaseAll(now3));
|
|
722
736
|
}
|
|
723
737
|
/**
|
|
724
738
|
* No-op for MIDI — MIDI uses note velocity, not gain fades.
|
|
@@ -754,8 +768,7 @@ var MidiToneTrack = class {
|
|
|
754
768
|
this.effectsCleanup();
|
|
755
769
|
} catch (err) {
|
|
756
770
|
console.warn(
|
|
757
|
-
`[waveform-playlist] Error during MIDI track "${this.id}" effects cleanup
|
|
758
|
-
err
|
|
771
|
+
`[waveform-playlist] Error during MIDI track "${this.id}" effects cleanup: ` + String(err)
|
|
759
772
|
);
|
|
760
773
|
}
|
|
761
774
|
}
|
|
@@ -765,8 +778,7 @@ var MidiToneTrack = class {
|
|
|
765
778
|
part.dispose();
|
|
766
779
|
} catch (err) {
|
|
767
780
|
console.warn(
|
|
768
|
-
`[waveform-playlist] Error disposing Part ${index} on MIDI track "${this.id}"
|
|
769
|
-
err
|
|
781
|
+
`[waveform-playlist] Error disposing Part ${index} on MIDI track "${this.id}": ` + String(err)
|
|
770
782
|
);
|
|
771
783
|
}
|
|
772
784
|
});
|
|
@@ -781,35 +793,43 @@ var MidiToneTrack = class {
|
|
|
781
793
|
try {
|
|
782
794
|
s?.dispose();
|
|
783
795
|
} catch (err) {
|
|
784
|
-
console.warn(
|
|
796
|
+
console.warn(
|
|
797
|
+
`[waveform-playlist] Error disposing synth on MIDI track "${this.id}": ` + String(err)
|
|
798
|
+
);
|
|
785
799
|
}
|
|
786
800
|
}
|
|
787
801
|
try {
|
|
788
802
|
this.volumeNode.dispose();
|
|
789
803
|
} catch (err) {
|
|
790
804
|
console.warn(
|
|
791
|
-
`[waveform-playlist] Error disposing volumeNode on MIDI track "${this.id}"
|
|
792
|
-
err
|
|
805
|
+
`[waveform-playlist] Error disposing volumeNode on MIDI track "${this.id}": ` + String(err)
|
|
793
806
|
);
|
|
794
807
|
}
|
|
795
808
|
try {
|
|
796
809
|
this.panNode.dispose();
|
|
797
810
|
} catch (err) {
|
|
798
|
-
console.warn(
|
|
811
|
+
console.warn(
|
|
812
|
+
`[waveform-playlist] Error disposing panNode on MIDI track "${this.id}": ` + String(err)
|
|
813
|
+
);
|
|
799
814
|
}
|
|
800
815
|
try {
|
|
801
816
|
this.muteGain.dispose();
|
|
802
817
|
} catch (err) {
|
|
803
|
-
console.warn(
|
|
818
|
+
console.warn(
|
|
819
|
+
`[waveform-playlist] Error disposing muteGain on MIDI track "${this.id}": ` + String(err)
|
|
820
|
+
);
|
|
804
821
|
}
|
|
805
822
|
}
|
|
806
823
|
get id() {
|
|
807
824
|
return this.track.id;
|
|
808
825
|
}
|
|
809
826
|
get duration() {
|
|
810
|
-
|
|
811
|
-
const
|
|
812
|
-
|
|
827
|
+
let max = 0;
|
|
828
|
+
for (const { clipInfo } of this.scheduledClips) {
|
|
829
|
+
const end = clipInfo.startTime + clipInfo.duration;
|
|
830
|
+
if (end > max) max = end;
|
|
831
|
+
}
|
|
832
|
+
return max;
|
|
813
833
|
}
|
|
814
834
|
get muted() {
|
|
815
835
|
return this.track.muted;
|
|
@@ -822,8 +842,12 @@ var MidiToneTrack = class {
|
|
|
822
842
|
// src/SoundFontToneTrack.ts
|
|
823
843
|
import { Volume as Volume3, Gain as Gain3, Panner as Panner3, Part as Part2, getDestination as getDestination3, getContext as getContext3 } from "tone";
|
|
824
844
|
import { gainToDb as gainToDb3 } from "@waveform-playlist/core";
|
|
825
|
-
var
|
|
845
|
+
var SoundFontToneTrack = class {
|
|
826
846
|
constructor(options) {
|
|
847
|
+
/** Rate-limit missing sample warnings — one per track instance (a page-
|
|
848
|
+
* lifetime static would silence diagnostics for unrelated later tracks
|
|
849
|
+
* and soundfont swaps). */
|
|
850
|
+
this._missingSampleWarned = false;
|
|
827
851
|
this.activeSources = /* @__PURE__ */ new Set();
|
|
828
852
|
this.track = options.track;
|
|
829
853
|
this.soundFontCache = options.soundFontCache;
|
|
@@ -866,7 +890,13 @@ var _SoundFontToneTrack = class _SoundFontToneTrack {
|
|
|
866
890
|
});
|
|
867
891
|
const part = new Part2((time, event) => {
|
|
868
892
|
if (event.duration > 0) {
|
|
869
|
-
|
|
893
|
+
try {
|
|
894
|
+
this.triggerNote(event.midi, event.duration, time, event.velocity, event.channel);
|
|
895
|
+
} catch (err) {
|
|
896
|
+
console.warn(
|
|
897
|
+
`[waveform-playlist] Failed to trigger SoundFont note on track "${this.id}": ` + String(err)
|
|
898
|
+
);
|
|
899
|
+
}
|
|
870
900
|
}
|
|
871
901
|
}, partEvents);
|
|
872
902
|
part.start(0);
|
|
@@ -883,11 +913,11 @@ var _SoundFontToneTrack = class _SoundFontToneTrack {
|
|
|
883
913
|
const preset = channel === 9 ? 0 : this.programNumber;
|
|
884
914
|
const sfSample = this.soundFontCache.getAudioBuffer(midiNote, bank, preset);
|
|
885
915
|
if (!sfSample) {
|
|
886
|
-
if (!
|
|
916
|
+
if (!this._missingSampleWarned) {
|
|
887
917
|
console.warn(
|
|
888
|
-
`[waveform-playlist] SoundFont sample not found for MIDI note ${midiNote} (bank ${bank}, preset ${preset}). Subsequent missing samples will be silent.`
|
|
918
|
+
`[waveform-playlist] SoundFont sample not found for MIDI note ${midiNote} (bank ${bank}, preset ${preset}) on track "${this.id}". Subsequent missing samples on this track will be silent.`
|
|
889
919
|
);
|
|
890
|
-
|
|
920
|
+
this._missingSampleWarned = true;
|
|
891
921
|
}
|
|
892
922
|
return;
|
|
893
923
|
}
|
|
@@ -923,7 +953,7 @@ var _SoundFontToneTrack = class _SoundFontToneTrack {
|
|
|
923
953
|
try {
|
|
924
954
|
gainNode.disconnect();
|
|
925
955
|
} catch (err) {
|
|
926
|
-
console.warn("[waveform-playlist] GainNode already disconnected:"
|
|
956
|
+
console.warn("[waveform-playlist] GainNode already disconnected: " + String(err));
|
|
927
957
|
}
|
|
928
958
|
};
|
|
929
959
|
source.start(time);
|
|
@@ -958,8 +988,7 @@ var _SoundFontToneTrack = class _SoundFontToneTrack {
|
|
|
958
988
|
);
|
|
959
989
|
} catch (err) {
|
|
960
990
|
console.warn(
|
|
961
|
-
`[waveform-playlist] Failed to start mid-clip SoundFont note on track "${this.id}"
|
|
962
|
-
err
|
|
991
|
+
`[waveform-playlist] Failed to start mid-clip SoundFont note on track "${this.id}": ` + String(err)
|
|
963
992
|
);
|
|
964
993
|
}
|
|
965
994
|
}
|
|
@@ -975,7 +1004,9 @@ var _SoundFontToneTrack = class _SoundFontToneTrack {
|
|
|
975
1004
|
try {
|
|
976
1005
|
source.stop();
|
|
977
1006
|
} catch (err) {
|
|
978
|
-
console.warn(
|
|
1007
|
+
console.warn(
|
|
1008
|
+
"[waveform-playlist] Error stopping AudioBufferSourceNode: " + String(err)
|
|
1009
|
+
);
|
|
979
1010
|
}
|
|
980
1011
|
}
|
|
981
1012
|
this.activeSources.clear();
|
|
@@ -1010,8 +1041,7 @@ var _SoundFontToneTrack = class _SoundFontToneTrack {
|
|
|
1010
1041
|
this.effectsCleanup();
|
|
1011
1042
|
} catch (err) {
|
|
1012
1043
|
console.warn(
|
|
1013
|
-
`[waveform-playlist] Error during SoundFont track "${this.id}" effects cleanup
|
|
1014
|
-
err
|
|
1044
|
+
`[waveform-playlist] Error during SoundFont track "${this.id}" effects cleanup: ` + String(err)
|
|
1015
1045
|
);
|
|
1016
1046
|
}
|
|
1017
1047
|
}
|
|
@@ -1021,8 +1051,7 @@ var _SoundFontToneTrack = class _SoundFontToneTrack {
|
|
|
1021
1051
|
part.dispose();
|
|
1022
1052
|
} catch (err) {
|
|
1023
1053
|
console.warn(
|
|
1024
|
-
`[waveform-playlist] Error disposing Part ${index} on SoundFont track "${this.id}"
|
|
1025
|
-
err
|
|
1054
|
+
`[waveform-playlist] Error disposing Part ${index} on SoundFont track "${this.id}": ` + String(err)
|
|
1026
1055
|
);
|
|
1027
1056
|
}
|
|
1028
1057
|
});
|
|
@@ -1030,24 +1059,21 @@ var _SoundFontToneTrack = class _SoundFontToneTrack {
|
|
|
1030
1059
|
this.volumeNode.dispose();
|
|
1031
1060
|
} catch (err) {
|
|
1032
1061
|
console.warn(
|
|
1033
|
-
`[waveform-playlist] Error disposing volumeNode on SoundFont track "${this.id}"
|
|
1034
|
-
err
|
|
1062
|
+
`[waveform-playlist] Error disposing volumeNode on SoundFont track "${this.id}": ` + String(err)
|
|
1035
1063
|
);
|
|
1036
1064
|
}
|
|
1037
1065
|
try {
|
|
1038
1066
|
this.panNode.dispose();
|
|
1039
1067
|
} catch (err) {
|
|
1040
1068
|
console.warn(
|
|
1041
|
-
`[waveform-playlist] Error disposing panNode on SoundFont track "${this.id}"
|
|
1042
|
-
err
|
|
1069
|
+
`[waveform-playlist] Error disposing panNode on SoundFont track "${this.id}": ` + String(err)
|
|
1043
1070
|
);
|
|
1044
1071
|
}
|
|
1045
1072
|
try {
|
|
1046
1073
|
this.muteGain.dispose();
|
|
1047
1074
|
} catch (err) {
|
|
1048
1075
|
console.warn(
|
|
1049
|
-
`[waveform-playlist] Error disposing muteGain on SoundFont track "${this.id}"
|
|
1050
|
-
err
|
|
1076
|
+
`[waveform-playlist] Error disposing muteGain on SoundFont track "${this.id}": ` + String(err)
|
|
1051
1077
|
);
|
|
1052
1078
|
}
|
|
1053
1079
|
}
|
|
@@ -1055,9 +1081,12 @@ var _SoundFontToneTrack = class _SoundFontToneTrack {
|
|
|
1055
1081
|
return this.track.id;
|
|
1056
1082
|
}
|
|
1057
1083
|
get duration() {
|
|
1058
|
-
|
|
1059
|
-
const
|
|
1060
|
-
|
|
1084
|
+
let max = 0;
|
|
1085
|
+
for (const { clipInfo } of this.scheduledClips) {
|
|
1086
|
+
const end = clipInfo.startTime + clipInfo.duration;
|
|
1087
|
+
if (end > max) max = end;
|
|
1088
|
+
}
|
|
1089
|
+
return max;
|
|
1061
1090
|
}
|
|
1062
1091
|
get muted() {
|
|
1063
1092
|
return this.track.muted;
|
|
@@ -1066,9 +1095,6 @@ var _SoundFontToneTrack = class _SoundFontToneTrack {
|
|
|
1066
1095
|
return this.track.startTime;
|
|
1067
1096
|
}
|
|
1068
1097
|
};
|
|
1069
|
-
/** Rate-limit missing sample warnings — one per class lifetime */
|
|
1070
|
-
_SoundFontToneTrack._missingSampleWarned = false;
|
|
1071
|
-
var SoundFontToneTrack = _SoundFontToneTrack;
|
|
1072
1098
|
|
|
1073
1099
|
// src/TonePlayout.ts
|
|
1074
1100
|
var TonePlayout = class {
|
|
@@ -1106,7 +1132,9 @@ var TonePlayout = class {
|
|
|
1106
1132
|
try {
|
|
1107
1133
|
getTransport2().clear(this._completionEventId);
|
|
1108
1134
|
} catch (err) {
|
|
1109
|
-
console.warn(
|
|
1135
|
+
console.warn(
|
|
1136
|
+
"[waveform-playlist] Error clearing Transport completion event: " + String(err)
|
|
1137
|
+
);
|
|
1110
1138
|
}
|
|
1111
1139
|
this._completionEventId = null;
|
|
1112
1140
|
}
|
|
@@ -1201,6 +1229,7 @@ var TonePlayout = class {
|
|
|
1201
1229
|
const lookAhead = context.lookAhead ?? 0;
|
|
1202
1230
|
const audibleOffset = Math.max(0, transport.seconds - lookAhead);
|
|
1203
1231
|
track.startMidClipSources(audibleOffset, context.currentTime);
|
|
1232
|
+
track.prepareFades(context.currentTime, audibleOffset);
|
|
1204
1233
|
}
|
|
1205
1234
|
play(when, offset, duration) {
|
|
1206
1235
|
if (!this.isInitialized) {
|
|
@@ -1220,7 +1249,9 @@ var TonePlayout = class {
|
|
|
1220
1249
|
try {
|
|
1221
1250
|
this.onPlaybackCompleteCallback?.();
|
|
1222
1251
|
} catch (err) {
|
|
1223
|
-
console.warn(
|
|
1252
|
+
console.warn(
|
|
1253
|
+
"[waveform-playlist] Error in playback completion callback: " + String(err)
|
|
1254
|
+
);
|
|
1224
1255
|
}
|
|
1225
1256
|
}, transportOffset + duration);
|
|
1226
1257
|
}
|
|
@@ -1246,8 +1277,7 @@ var TonePlayout = class {
|
|
|
1246
1277
|
this.clearCompletionEvent();
|
|
1247
1278
|
this.tracks.forEach((track) => track.cancelFades());
|
|
1248
1279
|
console.warn(
|
|
1249
|
-
"[waveform-playlist] Transport.start() failed. Audio playback could not begin."
|
|
1250
|
-
err
|
|
1280
|
+
"[waveform-playlist] Transport.start() failed. Audio playback could not begin. " + String(err)
|
|
1251
1281
|
);
|
|
1252
1282
|
throw err;
|
|
1253
1283
|
}
|
|
@@ -1257,7 +1287,7 @@ var TonePlayout = class {
|
|
|
1257
1287
|
try {
|
|
1258
1288
|
transport.pause();
|
|
1259
1289
|
} catch (err) {
|
|
1260
|
-
console.warn("[waveform-playlist] Transport.pause() failed:"
|
|
1290
|
+
console.warn("[waveform-playlist] Transport.pause() failed: " + String(err));
|
|
1261
1291
|
}
|
|
1262
1292
|
this.tracks.forEach((track) => track.stopAllSources());
|
|
1263
1293
|
this.tracks.forEach((track) => track.cancelFades());
|
|
@@ -1268,13 +1298,13 @@ var TonePlayout = class {
|
|
|
1268
1298
|
try {
|
|
1269
1299
|
transport.stop();
|
|
1270
1300
|
} catch (err) {
|
|
1271
|
-
console.warn("[waveform-playlist] Transport.stop() failed:"
|
|
1301
|
+
console.warn("[waveform-playlist] Transport.stop() failed: " + String(err));
|
|
1272
1302
|
}
|
|
1273
1303
|
if (this._loopHandler) {
|
|
1274
1304
|
try {
|
|
1275
1305
|
transport.off("loop", this._loopHandler);
|
|
1276
1306
|
} catch (err) {
|
|
1277
|
-
console.warn("[waveform-playlist] Error removing loop handler:"
|
|
1307
|
+
console.warn("[waveform-playlist] Error removing loop handler: " + String(err));
|
|
1278
1308
|
}
|
|
1279
1309
|
this._loopHandler = null;
|
|
1280
1310
|
}
|
|
@@ -1282,14 +1312,18 @@ var TonePlayout = class {
|
|
|
1282
1312
|
try {
|
|
1283
1313
|
track.stopAllSources();
|
|
1284
1314
|
} catch (err) {
|
|
1285
|
-
console.warn(
|
|
1315
|
+
console.warn(
|
|
1316
|
+
`[waveform-playlist] Error stopping sources for track "${track.id}": ` + String(err)
|
|
1317
|
+
);
|
|
1286
1318
|
}
|
|
1287
1319
|
});
|
|
1288
1320
|
this.tracks.forEach((track) => {
|
|
1289
1321
|
try {
|
|
1290
1322
|
track.cancelFades();
|
|
1291
1323
|
} catch (err) {
|
|
1292
|
-
console.warn(
|
|
1324
|
+
console.warn(
|
|
1325
|
+
`[waveform-playlist] Error canceling fades for track "${track.id}": ` + String(err)
|
|
1326
|
+
);
|
|
1293
1327
|
}
|
|
1294
1328
|
});
|
|
1295
1329
|
this.clearCompletionEvent();
|
|
@@ -1336,10 +1370,14 @@ var TonePlayout = class {
|
|
|
1336
1370
|
* effects] → tap → node (caller wires node.output → ctx.destination).
|
|
1337
1371
|
*/
|
|
1338
1372
|
connectMasterOutput(node) {
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1373
|
+
try {
|
|
1374
|
+
if (this._masterChainNode) {
|
|
1375
|
+
this._masterTap.disconnect(this._masterChainNode);
|
|
1376
|
+
} else {
|
|
1377
|
+
this._masterTap.disconnect(getDestination4());
|
|
1378
|
+
}
|
|
1379
|
+
} catch (err) {
|
|
1380
|
+
console.warn("[waveform-playlist] connectMasterOutput disconnect: " + String(err));
|
|
1343
1381
|
}
|
|
1344
1382
|
this._masterTap.connect(node);
|
|
1345
1383
|
this._masterChainNode = node;
|
|
@@ -1389,7 +1427,7 @@ var TonePlayout = class {
|
|
|
1389
1427
|
const track = this.tracks.get(trackId);
|
|
1390
1428
|
if (track) {
|
|
1391
1429
|
this.manualMuteState.set(trackId, muted);
|
|
1392
|
-
|
|
1430
|
+
this.updateSoloMuting();
|
|
1393
1431
|
}
|
|
1394
1432
|
}
|
|
1395
1433
|
setLoop(enabled, loopStart, loopEnd) {
|
|
@@ -1402,7 +1440,7 @@ var TonePlayout = class {
|
|
|
1402
1440
|
transport.loopEnd = loopEnd;
|
|
1403
1441
|
transport.loop = enabled;
|
|
1404
1442
|
} catch (err) {
|
|
1405
|
-
console.warn("[waveform-playlist] Error configuring Transport loop:"
|
|
1443
|
+
console.warn("[waveform-playlist] Error configuring Transport loop: " + String(err));
|
|
1406
1444
|
return;
|
|
1407
1445
|
}
|
|
1408
1446
|
if (enabled && !this._loopHandler) {
|
|
@@ -1417,8 +1455,7 @@ var TonePlayout = class {
|
|
|
1417
1455
|
track.prepareFades(currentTime, this._loopStart);
|
|
1418
1456
|
} catch (err) {
|
|
1419
1457
|
console.warn(
|
|
1420
|
-
`[waveform-playlist] Error re-scheduling track "${track.id}" on loop
|
|
1421
|
-
err
|
|
1458
|
+
`[waveform-playlist] Error re-scheduling track "${track.id}" on loop: ` + String(err)
|
|
1422
1459
|
);
|
|
1423
1460
|
}
|
|
1424
1461
|
});
|
|
@@ -1439,13 +1476,17 @@ var TonePlayout = class {
|
|
|
1439
1476
|
try {
|
|
1440
1477
|
this.stop();
|
|
1441
1478
|
} catch (err) {
|
|
1442
|
-
console.warn(
|
|
1479
|
+
console.warn(
|
|
1480
|
+
"[waveform-playlist] Error stopping Transport during dispose: " + String(err)
|
|
1481
|
+
);
|
|
1443
1482
|
}
|
|
1444
1483
|
this.tracks.forEach((track) => {
|
|
1445
1484
|
try {
|
|
1446
1485
|
track.dispose();
|
|
1447
1486
|
} catch (err) {
|
|
1448
|
-
console.warn(
|
|
1487
|
+
console.warn(
|
|
1488
|
+
`[waveform-playlist] Error disposing track "${track.id}": ` + String(err)
|
|
1489
|
+
);
|
|
1449
1490
|
}
|
|
1450
1491
|
});
|
|
1451
1492
|
this.tracks.clear();
|
|
@@ -1453,7 +1494,9 @@ var TonePlayout = class {
|
|
|
1453
1494
|
try {
|
|
1454
1495
|
this.effectsCleanup();
|
|
1455
1496
|
} catch (err) {
|
|
1456
|
-
console.warn(
|
|
1497
|
+
console.warn(
|
|
1498
|
+
"[waveform-playlist] Error during master effects cleanup: " + String(err)
|
|
1499
|
+
);
|
|
1457
1500
|
}
|
|
1458
1501
|
}
|
|
1459
1502
|
try {
|
|
@@ -1561,7 +1604,9 @@ var SoundFontCache = class _SoundFontCache {
|
|
|
1561
1604
|
async load(url, signal) {
|
|
1562
1605
|
const response = await fetch(url, { signal });
|
|
1563
1606
|
if (!response.ok) {
|
|
1564
|
-
throw new Error(
|
|
1607
|
+
throw new Error(
|
|
1608
|
+
`Failed to fetch SoundFont ${url}: ${response.status}${response.statusText ? ` ${response.statusText}` : ""}`
|
|
1609
|
+
);
|
|
1565
1610
|
}
|
|
1566
1611
|
const arrayBuffer = await response.arrayBuffer();
|
|
1567
1612
|
try {
|
|
@@ -1571,6 +1616,7 @@ var SoundFontCache = class _SoundFontCache {
|
|
|
1571
1616
|
`Failed to parse SoundFont ${url}: ${err instanceof Error ? err.message : String(err)}`
|
|
1572
1617
|
);
|
|
1573
1618
|
}
|
|
1619
|
+
this.audioBufferCache.clear();
|
|
1574
1620
|
}
|
|
1575
1621
|
/**
|
|
1576
1622
|
* Load from an already-fetched ArrayBuffer.
|
|
@@ -1583,6 +1629,7 @@ var SoundFontCache = class _SoundFontCache {
|
|
|
1583
1629
|
`Failed to parse SoundFont from buffer: ${err instanceof Error ? err.message : String(err)}`
|
|
1584
1630
|
);
|
|
1585
1631
|
}
|
|
1632
|
+
this.audioBufferCache.clear();
|
|
1586
1633
|
}
|
|
1587
1634
|
get isLoaded() {
|
|
1588
1635
|
return this.sf2 !== null;
|
|
@@ -1681,7 +1728,7 @@ function configureGlobalContext(options) {
|
|
|
1681
1728
|
"[playout] nativeAudioContext requested but this browser does not implement the AudioListener AudioParams Tone.js needs on a native context (Firefox). Falling back to the standardized-audio-context default \u2014 WAM plugin hosting is unavailable."
|
|
1682
1729
|
);
|
|
1683
1730
|
}
|
|
1684
|
-
globalToneContext = new Context();
|
|
1731
|
+
globalToneContext = options.latencyHint !== void 0 ? new Context({ latencyHint: options.latencyHint }) : new Context();
|
|
1685
1732
|
setContext(globalToneContext);
|
|
1686
1733
|
const actualRate = globalToneContext.rawContext.sampleRate;
|
|
1687
1734
|
if (options.sampleRate !== void 0 && options.sampleRate !== actualRate) {
|
|
@@ -1714,34 +1761,38 @@ function getGlobalAudioContextState() {
|
|
|
1714
1761
|
return globalToneContext?.rawContext.state || "suspended";
|
|
1715
1762
|
}
|
|
1716
1763
|
async function closeGlobalAudioContext() {
|
|
1717
|
-
if (globalToneContext
|
|
1764
|
+
if (!globalToneContext) return;
|
|
1765
|
+
if (globalToneContext.rawContext.state !== "closed") {
|
|
1718
1766
|
await globalToneContext.close();
|
|
1719
|
-
globalToneContext = null;
|
|
1720
|
-
_nativeMode = false;
|
|
1721
1767
|
}
|
|
1768
|
+
globalToneContext = null;
|
|
1769
|
+
_nativeMode = false;
|
|
1722
1770
|
}
|
|
1723
1771
|
|
|
1724
1772
|
// src/mediaStreamSourceManager.ts
|
|
1725
|
-
import { getContext as getContext5 } from "tone";
|
|
1726
1773
|
var streamSources = /* @__PURE__ */ new Map();
|
|
1727
1774
|
var streamCleanupHandlers = /* @__PURE__ */ new Map();
|
|
1728
1775
|
function getMediaStreamSource(stream) {
|
|
1729
1776
|
if (streamSources.has(stream)) {
|
|
1730
1777
|
return streamSources.get(stream);
|
|
1731
1778
|
}
|
|
1732
|
-
const context =
|
|
1779
|
+
const context = getGlobalContext();
|
|
1733
1780
|
const source = context.createMediaStreamSource(stream);
|
|
1734
1781
|
streamSources.set(stream, source);
|
|
1782
|
+
const tracks = stream.getTracks();
|
|
1783
|
+
const onTrackEnded = () => {
|
|
1784
|
+
if (!stream.active) {
|
|
1785
|
+
cleanup();
|
|
1786
|
+
}
|
|
1787
|
+
};
|
|
1735
1788
|
const cleanup = () => {
|
|
1736
1789
|
source.disconnect();
|
|
1737
1790
|
streamSources.delete(stream);
|
|
1738
1791
|
streamCleanupHandlers.delete(stream);
|
|
1739
|
-
|
|
1740
|
-
stream.removeEventListener("inactive", cleanup);
|
|
1792
|
+
tracks.forEach((track) => track.removeEventListener("ended", onTrackEnded));
|
|
1741
1793
|
};
|
|
1742
1794
|
streamCleanupHandlers.set(stream, cleanup);
|
|
1743
|
-
|
|
1744
|
-
stream.addEventListener("inactive", cleanup);
|
|
1795
|
+
tracks.forEach((track) => track.addEventListener("ended", onTrackEnded));
|
|
1745
1796
|
return source;
|
|
1746
1797
|
}
|
|
1747
1798
|
function releaseMediaStreamSource(stream) {
|
|
@@ -1880,7 +1931,7 @@ function createToneAdapter(options) {
|
|
|
1880
1931
|
try {
|
|
1881
1932
|
playout.dispose();
|
|
1882
1933
|
} catch (err) {
|
|
1883
|
-
console.warn("[waveform-playlist] Error disposing previous playout:"
|
|
1934
|
+
console.warn("[waveform-playlist] Error disposing previous playout: " + String(err));
|
|
1884
1935
|
}
|
|
1885
1936
|
playout = null;
|
|
1886
1937
|
}
|
|
@@ -1892,8 +1943,7 @@ function createToneAdapter(options) {
|
|
|
1892
1943
|
if (_audioInitialized) {
|
|
1893
1944
|
_pendingInit = playout.init().catch((err) => {
|
|
1894
1945
|
console.warn(
|
|
1895
|
-
"[waveform-playlist] Failed to initialize playout. Audio playback will require another user gesture."
|
|
1896
|
-
err
|
|
1946
|
+
"[waveform-playlist] Failed to initialize playout. Audio playback will require another user gesture. " + String(err)
|
|
1897
1947
|
);
|
|
1898
1948
|
_audioInitialized = false;
|
|
1899
1949
|
});
|
|
@@ -1990,13 +2040,16 @@ function createToneAdapter(options) {
|
|
|
1990
2040
|
}));
|
|
1991
2041
|
const audioUpdated = playout.replaceTrackClips(trackId, clipInfos, startTime);
|
|
1992
2042
|
const midiClips = track.clips.filter((c) => c.midiNotes && c.midiNotes.length > 0);
|
|
2043
|
+
const midiTrackId = trackId + ":midi";
|
|
1993
2044
|
if (midiClips.length > 0) {
|
|
1994
|
-
const midiTrackId = trackId + ":midi";
|
|
1995
2045
|
playout.removeTrack(midiTrackId);
|
|
1996
2046
|
addMidiTrackToPlayout(playout, track);
|
|
1997
2047
|
if (_isPlaying) {
|
|
1998
2048
|
playout.resumeTrackMidPlayback(midiTrackId);
|
|
1999
2049
|
}
|
|
2050
|
+
} else {
|
|
2051
|
+
playout.removeTrack(midiTrackId);
|
|
2052
|
+
_midiTrackBuild.delete(midiTrackId);
|
|
2000
2053
|
}
|
|
2001
2054
|
if (audioUpdated) {
|
|
2002
2055
|
playout.applyInitialSoloState();
|
|
@@ -2065,25 +2118,34 @@ function createToneAdapter(options) {
|
|
|
2065
2118
|
setMasterVolume(volume) {
|
|
2066
2119
|
playout?.setMasterGain(volume);
|
|
2067
2120
|
},
|
|
2121
|
+
// Runtime controls must reach BOTH playout halves of a mixed audio+MIDI
|
|
2122
|
+
// track (trackId + trackId:midi) — otherwise muting a mixed track leaves
|
|
2123
|
+
// its MIDI playing and soloing it silences its own MIDI half. The :midi
|
|
2124
|
+
// calls no-op for audio-only and MIDI-only tracks (unknown playout id),
|
|
2125
|
+
// same blind-forwarding pattern as removeTrack.
|
|
2068
2126
|
setTrackVolume(trackId, volume) {
|
|
2069
2127
|
const existing = _currentTracks.get(trackId);
|
|
2070
2128
|
if (existing) _currentTracks.set(trackId, { ...existing, volume });
|
|
2071
2129
|
playout?.getTrack(trackId)?.setVolume(volume);
|
|
2130
|
+
playout?.getTrack(trackId + ":midi")?.setVolume(volume);
|
|
2072
2131
|
},
|
|
2073
2132
|
setTrackMute(trackId, muted) {
|
|
2074
2133
|
const existing = _currentTracks.get(trackId);
|
|
2075
2134
|
if (existing) _currentTracks.set(trackId, { ...existing, muted });
|
|
2076
2135
|
playout?.setMute(trackId, muted);
|
|
2136
|
+
playout?.setMute(trackId + ":midi", muted);
|
|
2077
2137
|
},
|
|
2078
2138
|
setTrackSolo(trackId, soloed) {
|
|
2079
2139
|
const existing = _currentTracks.get(trackId);
|
|
2080
2140
|
if (existing) _currentTracks.set(trackId, { ...existing, soloed });
|
|
2081
2141
|
playout?.setSolo(trackId, soloed);
|
|
2142
|
+
playout?.setSolo(trackId + ":midi", soloed);
|
|
2082
2143
|
},
|
|
2083
2144
|
setTrackPan(trackId, pan) {
|
|
2084
2145
|
const existing = _currentTracks.get(trackId);
|
|
2085
2146
|
if (existing) _currentTracks.set(trackId, { ...existing, pan });
|
|
2086
2147
|
playout?.getTrack(trackId)?.setPan(pan);
|
|
2148
|
+
playout?.getTrack(trackId + ":midi")?.setPan(pan);
|
|
2087
2149
|
},
|
|
2088
2150
|
setLoop(enabled, start2, end) {
|
|
2089
2151
|
_loopEnabled = enabled;
|