@waveform-playlist/playout 13.0.0-next.1 → 13.0.0-next.11
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 +2 -2
- package/dist/index.d.mts +9 -11
- package/dist/index.d.ts +9 -11
- package/dist/index.js +49 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -27,10 +27,10 @@ What you gain on `tone@next`: `configureGlobalContext({ sampleRate })` is honour
|
|
|
27
27
|
|
|
28
28
|
```typescript
|
|
29
29
|
import { createToneAdapter } from '@waveform-playlist/playout';
|
|
30
|
-
import {
|
|
30
|
+
import { EditorEngine } from '@waveform-playlist/engine';
|
|
31
31
|
|
|
32
32
|
const adapter = createToneAdapter();
|
|
33
|
-
const engine = new
|
|
33
|
+
const engine = new EditorEngine({ adapter });
|
|
34
34
|
|
|
35
35
|
engine.setTracks(tracks); // ClipTrack[]
|
|
36
36
|
engine.play(0);
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Gain, ToneAudioNode, SynthOptions, Volume, BaseContext, Context } from 'tone';
|
|
2
|
-
import { Fade, Track, MidiNoteData } from '@waveform-playlist/core';
|
|
2
|
+
import { Fade, Track, DecidedPanLaw, MidiNoteData } from '@waveform-playlist/core';
|
|
3
3
|
import { ZoneMap, Generator, GeneratorType } from 'soundfont2';
|
|
4
4
|
import { PlayoutAdapter } from '@waveform-playlist/engine';
|
|
5
5
|
|
|
@@ -34,8 +34,8 @@ interface ToneTrackOptions {
|
|
|
34
34
|
track: Track;
|
|
35
35
|
effects?: TrackEffectsFunction;
|
|
36
36
|
destination?: ToneAudioNode;
|
|
37
|
-
/**
|
|
38
|
-
|
|
37
|
+
/** The track's pan law (core's trackPanLaw). Default: 'mono' */
|
|
38
|
+
panLaw?: DecidedPanLaw;
|
|
39
39
|
}
|
|
40
40
|
/** Per-clip scheduling info and audio nodes */
|
|
41
41
|
interface ScheduledClip {
|
|
@@ -88,12 +88,10 @@ declare class ToneTrack {
|
|
|
88
88
|
*/
|
|
89
89
|
removeScheduledClip(index: number): void;
|
|
90
90
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* joining a mono track moves it to the stereo law (same rule as the
|
|
94
|
-
* native transport and the offline export).
|
|
91
|
+
* Switch the track's pan law (the gains ramp). The law is the track's own
|
|
92
|
+
* (#684): its clips do not change it, on any renderer.
|
|
95
93
|
*/
|
|
96
|
-
|
|
94
|
+
setPanLaw(panLaw: DecidedPanLaw): void;
|
|
97
95
|
/**
|
|
98
96
|
* Replace clips on this track. Diffs old vs new by buffer + timing —
|
|
99
97
|
* unchanged clips keep their active sources playing (no audible interruption).
|
|
@@ -511,10 +509,10 @@ declare class TonePlayout {
|
|
|
511
509
|
/**
|
|
512
510
|
* Replace clips on a track, preserving the track's audio graph.
|
|
513
511
|
* Only works for ToneTrack (audio clips), not MidiToneTrack.
|
|
514
|
-
* `
|
|
515
|
-
*
|
|
512
|
+
* `panLaw` is the track's pan law (core's trackPanLaw); omit to leave it
|
|
513
|
+
* unchanged.
|
|
516
514
|
*/
|
|
517
|
-
replaceTrackClips(trackId: string, newClips: ClipInfo[], newStartTime?: number,
|
|
515
|
+
replaceTrackClips(trackId: string, newClips: ClipInfo[], newStartTime?: number, panLaw?: DecidedPanLaw): boolean;
|
|
518
516
|
/**
|
|
519
517
|
* Start mid-clip sources for a specific track at the current Transport position.
|
|
520
518
|
* Call after adding/updating a track during active playback so clips that span
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Gain, ToneAudioNode, SynthOptions, Volume, BaseContext, Context } from 'tone';
|
|
2
|
-
import { Fade, Track, MidiNoteData } from '@waveform-playlist/core';
|
|
2
|
+
import { Fade, Track, DecidedPanLaw, MidiNoteData } from '@waveform-playlist/core';
|
|
3
3
|
import { ZoneMap, Generator, GeneratorType } from 'soundfont2';
|
|
4
4
|
import { PlayoutAdapter } from '@waveform-playlist/engine';
|
|
5
5
|
|
|
@@ -34,8 +34,8 @@ interface ToneTrackOptions {
|
|
|
34
34
|
track: Track;
|
|
35
35
|
effects?: TrackEffectsFunction;
|
|
36
36
|
destination?: ToneAudioNode;
|
|
37
|
-
/**
|
|
38
|
-
|
|
37
|
+
/** The track's pan law (core's trackPanLaw). Default: 'mono' */
|
|
38
|
+
panLaw?: DecidedPanLaw;
|
|
39
39
|
}
|
|
40
40
|
/** Per-clip scheduling info and audio nodes */
|
|
41
41
|
interface ScheduledClip {
|
|
@@ -88,12 +88,10 @@ declare class ToneTrack {
|
|
|
88
88
|
*/
|
|
89
89
|
removeScheduledClip(index: number): void;
|
|
90
90
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* joining a mono track moves it to the stereo law (same rule as the
|
|
94
|
-
* native transport and the offline export).
|
|
91
|
+
* Switch the track's pan law (the gains ramp). The law is the track's own
|
|
92
|
+
* (#684): its clips do not change it, on any renderer.
|
|
95
93
|
*/
|
|
96
|
-
|
|
94
|
+
setPanLaw(panLaw: DecidedPanLaw): void;
|
|
97
95
|
/**
|
|
98
96
|
* Replace clips on this track. Diffs old vs new by buffer + timing —
|
|
99
97
|
* unchanged clips keep their active sources playing (no audible interruption).
|
|
@@ -511,10 +509,10 @@ declare class TonePlayout {
|
|
|
511
509
|
/**
|
|
512
510
|
* Replace clips on a track, preserving the track's audio graph.
|
|
513
511
|
* Only works for ToneTrack (audio clips), not MidiToneTrack.
|
|
514
|
-
* `
|
|
515
|
-
*
|
|
512
|
+
* `panLaw` is the track's pan law (core's trackPanLaw); omit to leave it
|
|
513
|
+
* unchanged.
|
|
516
514
|
*/
|
|
517
|
-
replaceTrackClips(trackId: string, newClips: ClipInfo[], newStartTime?: number,
|
|
515
|
+
replaceTrackClips(trackId: string, newClips: ClipInfo[], newStartTime?: number, panLaw?: DecidedPanLaw): boolean;
|
|
518
516
|
/**
|
|
519
517
|
* Start mid-clip sources for a specific track at the current Transport position.
|
|
520
518
|
* Call after adding/updating a track during active playback so clips that span
|
package/dist/index.js
CHANGED
|
@@ -72,7 +72,7 @@ var ToneTrack = class {
|
|
|
72
72
|
this.panStage = (0, import_core.createPanStage)(
|
|
73
73
|
(0, import_tone.getContext)().rawContext,
|
|
74
74
|
options.track.stereoPan,
|
|
75
|
-
options.
|
|
75
|
+
options.panLaw ?? "mono"
|
|
76
76
|
);
|
|
77
77
|
this.muteGain = new import_tone.Gain(options.track.muted ? 0 : 1);
|
|
78
78
|
this.volumeNode.connect(this.panStage.input);
|
|
@@ -218,13 +218,11 @@ var ToneTrack = class {
|
|
|
218
218
|
this.scheduledClips.splice(index, 1);
|
|
219
219
|
}
|
|
220
220
|
/**
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
* joining a mono track moves it to the stereo law (same rule as the
|
|
224
|
-
* native transport and the offline export).
|
|
221
|
+
* Switch the track's pan law (the gains ramp). The law is the track's own
|
|
222
|
+
* (#684): its clips do not change it, on any renderer.
|
|
225
223
|
*/
|
|
226
|
-
|
|
227
|
-
this.panStage.
|
|
224
|
+
setPanLaw(panLaw) {
|
|
225
|
+
this.panStage.setPanLaw(panLaw);
|
|
228
226
|
}
|
|
229
227
|
/**
|
|
230
228
|
* Replace clips on this track. Diffs old vs new by buffer + timing —
|
|
@@ -575,6 +573,16 @@ var ToneTrack = class {
|
|
|
575
573
|
// src/MidiToneTrack.ts
|
|
576
574
|
var import_tone2 = require("tone");
|
|
577
575
|
var import_core2 = require("@waveform-playlist/core");
|
|
576
|
+
|
|
577
|
+
// src/midiWindow.ts
|
|
578
|
+
function noteInWindow(note, window) {
|
|
579
|
+
const start2 = Math.max(note.time, window.offset);
|
|
580
|
+
const end = Math.min(note.time + note.duration, window.offset + window.duration);
|
|
581
|
+
if (!(end > start2)) return null;
|
|
582
|
+
return { start: start2 - window.offset, duration: end - start2 };
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// src/MidiToneTrack.ts
|
|
578
586
|
function getDrumCategory(midiNote) {
|
|
579
587
|
if (midiNote === 35 || midiNote === 36) return "kick";
|
|
580
588
|
if (midiNote >= 37 && midiNote <= 40) return "snare";
|
|
@@ -590,7 +598,7 @@ var MidiToneTrack = class {
|
|
|
590
598
|
this.panStage = (0, import_core2.createPanStage)(
|
|
591
599
|
(0, import_tone2.getContext)().rawContext,
|
|
592
600
|
options.track.stereoPan,
|
|
593
|
-
|
|
601
|
+
"mono"
|
|
594
602
|
);
|
|
595
603
|
this.muteGain = new import_tone2.Gain(options.track.muted ? 0 : 1);
|
|
596
604
|
this.volumeNode.connect(this.panStage.input);
|
|
@@ -740,9 +748,10 @@ var MidiToneTrack = class {
|
|
|
740
748
|
const absClipEnd = absClipStart + clipInfo.duration;
|
|
741
749
|
if (absClipStart < transportOffset && absClipEnd > transportOffset) {
|
|
742
750
|
for (const note of clipInfo.notes) {
|
|
743
|
-
const
|
|
744
|
-
|
|
745
|
-
const
|
|
751
|
+
const sounding = noteInWindow(note, clipInfo);
|
|
752
|
+
if (!sounding) continue;
|
|
753
|
+
const noteAbsStart = absClipStart + sounding.start;
|
|
754
|
+
const noteAbsEnd = noteAbsStart + sounding.duration;
|
|
746
755
|
if (noteAbsStart < transportOffset && noteAbsEnd > transportOffset) {
|
|
747
756
|
const remainingDuration = noteAbsEnd - transportOffset;
|
|
748
757
|
try {
|
|
@@ -926,7 +935,7 @@ var SoundFontToneTrack = class {
|
|
|
926
935
|
this.panStage = (0, import_core3.createPanStage)(
|
|
927
936
|
(0, import_tone3.getContext)().rawContext,
|
|
928
937
|
options.track.stereoPan,
|
|
929
|
-
|
|
938
|
+
"mono"
|
|
930
939
|
);
|
|
931
940
|
this.muteGain = new import_tone3.Gain(options.track.muted ? 0 : 1);
|
|
932
941
|
this.volumeNode.connect(this.panStage.input);
|
|
@@ -1067,9 +1076,10 @@ var SoundFontToneTrack = class {
|
|
|
1067
1076
|
const absClipEnd = absClipStart + clipInfo.duration;
|
|
1068
1077
|
if (absClipStart < transportOffset && absClipEnd > transportOffset) {
|
|
1069
1078
|
for (const note of clipInfo.notes) {
|
|
1070
|
-
const
|
|
1071
|
-
|
|
1072
|
-
const
|
|
1079
|
+
const sounding = noteInWindow(note, clipInfo);
|
|
1080
|
+
if (!sounding) continue;
|
|
1081
|
+
const noteAbsStart = absClipStart + sounding.start;
|
|
1082
|
+
const noteAbsEnd = noteAbsStart + sounding.duration;
|
|
1073
1083
|
if (noteAbsStart < transportOffset && noteAbsEnd > transportOffset) {
|
|
1074
1084
|
const remainingDuration = noteAbsEnd - transportOffset;
|
|
1075
1085
|
try {
|
|
@@ -1308,16 +1318,16 @@ var TonePlayout = class {
|
|
|
1308
1318
|
/**
|
|
1309
1319
|
* Replace clips on a track, preserving the track's audio graph.
|
|
1310
1320
|
* Only works for ToneTrack (audio clips), not MidiToneTrack.
|
|
1311
|
-
* `
|
|
1312
|
-
*
|
|
1321
|
+
* `panLaw` is the track's pan law (core's trackPanLaw); omit to leave it
|
|
1322
|
+
* unchanged.
|
|
1313
1323
|
*/
|
|
1314
|
-
replaceTrackClips(trackId, newClips, newStartTime,
|
|
1324
|
+
replaceTrackClips(trackId, newClips, newStartTime, panLaw) {
|
|
1315
1325
|
const track = this.tracks.get(trackId);
|
|
1316
1326
|
if (!track || !("replaceClips" in track)) return false;
|
|
1317
1327
|
const toneTrack = track;
|
|
1318
1328
|
toneTrack.replaceClips(newClips, newStartTime);
|
|
1319
|
-
if (
|
|
1320
|
-
toneTrack.
|
|
1329
|
+
if (panLaw !== void 0) {
|
|
1330
|
+
toneTrack.setPanLaw(panLaw);
|
|
1321
1331
|
}
|
|
1322
1332
|
return true;
|
|
1323
1333
|
}
|
|
@@ -1969,7 +1979,9 @@ function createToneAdapter(options) {
|
|
|
1969
1979
|
const endTime = Math.max(...audioClips.map(import_core5.clipEndTime));
|
|
1970
1980
|
const trackObj = {
|
|
1971
1981
|
id: track.id,
|
|
1972
|
-
|
|
1982
|
+
// The adapter is not given the track's name (a view field, core's
|
|
1983
|
+
// TRACK_VIEW_FIELDS); nothing in TonePlayout reads this one.
|
|
1984
|
+
name: track.id,
|
|
1973
1985
|
gain: track.volume,
|
|
1974
1986
|
muted: track.muted,
|
|
1975
1987
|
soloed: track.soloed,
|
|
@@ -1990,7 +2002,7 @@ function createToneAdapter(options) {
|
|
|
1990
2002
|
clips: clipInfos,
|
|
1991
2003
|
track: trackObj,
|
|
1992
2004
|
effects: options?.trackEffects?.(track.id),
|
|
1993
|
-
|
|
2005
|
+
panLaw: (0, import_core5.trackPanLaw)(track)
|
|
1994
2006
|
});
|
|
1995
2007
|
}
|
|
1996
2008
|
function addMidiTrackToPlayout(p, track) {
|
|
@@ -2001,7 +2013,9 @@ function createToneAdapter(options) {
|
|
|
2001
2013
|
const trackId = track.id;
|
|
2002
2014
|
const trackObj = {
|
|
2003
2015
|
id: trackId,
|
|
2004
|
-
|
|
2016
|
+
// The adapter is not given the track's name (a view field, core's
|
|
2017
|
+
// TRACK_VIEW_FIELDS); nothing in TonePlayout reads this one.
|
|
2018
|
+
name: track.id,
|
|
2005
2019
|
gain: track.volume,
|
|
2006
2020
|
muted: track.muted,
|
|
2007
2021
|
soloed: track.soloed,
|
|
@@ -2033,7 +2047,7 @@ function createToneAdapter(options) {
|
|
|
2033
2047
|
} else {
|
|
2034
2048
|
if (_soundFontCache) {
|
|
2035
2049
|
console.warn(
|
|
2036
|
-
`[waveform-playlist] SoundFont not loaded for track "${track.
|
|
2050
|
+
`[waveform-playlist] SoundFont not loaded for track "${track.id}" \u2014 falling back to PolySynth.`
|
|
2037
2051
|
);
|
|
2038
2052
|
}
|
|
2039
2053
|
p.addMidiTrack({
|
|
@@ -2166,7 +2180,7 @@ function createToneAdapter(options) {
|
|
|
2166
2180
|
trackId,
|
|
2167
2181
|
clipInfos,
|
|
2168
2182
|
startTime,
|
|
2169
|
-
(0, import_core5.
|
|
2183
|
+
(0, import_core5.trackPanLaw)(track)
|
|
2170
2184
|
);
|
|
2171
2185
|
if (audioUpdated) {
|
|
2172
2186
|
playout.applyInitialSoloState();
|
|
@@ -2253,6 +2267,15 @@ function createToneAdapter(options) {
|
|
|
2253
2267
|
if (existing) _currentTracks.set(trackId, { ...existing, pan });
|
|
2254
2268
|
playout?.getTrack(trackId)?.setPan(pan);
|
|
2255
2269
|
},
|
|
2270
|
+
// A track's pan law changed (#684). 'auto': from the clips of the track
|
|
2271
|
+
// last sent. The clips are not replaced; the pan stage ramps. A MIDI or
|
|
2272
|
+
// SoundFont track has no law to set.
|
|
2273
|
+
setTrackPanLaw(trackId, panLaw) {
|
|
2274
|
+
const existing = _currentTracks.get(trackId);
|
|
2275
|
+
const track = playout?.getTrack(trackId);
|
|
2276
|
+
if (!existing || !track || !("setPanLaw" in track)) return;
|
|
2277
|
+
track.setPanLaw((0, import_core5.trackPanLaw)({ ...existing, panLaw }));
|
|
2278
|
+
},
|
|
2256
2279
|
setLoop(enabled, start2, end) {
|
|
2257
2280
|
_loopEnabled = enabled;
|
|
2258
2281
|
_loopStart = start2;
|
|
@@ -2343,7 +2366,7 @@ function createToneAdapter(options) {
|
|
|
2343
2366
|
changed = true;
|
|
2344
2367
|
} catch (err) {
|
|
2345
2368
|
console.warn(
|
|
2346
|
-
`[waveform-playlist] SoundFont swap failed for track "${track.
|
|
2369
|
+
`[waveform-playlist] SoundFont swap failed for track "${track.id}": ` + String(err)
|
|
2347
2370
|
);
|
|
2348
2371
|
}
|
|
2349
2372
|
}
|