@waveform-playlist/playout 13.0.0-next.7 → 13.0.0-next.9

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.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
- /** Max channel count across clips — selects the pan law (core's createPanStage). Default: 1 */
38
- channelCount?: number;
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
- * Select the pan law from the track's source material: 1 = mono law,
92
- * 2+ = stereo law. Call when the track's clips change — a stereo clip
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
- setSourceChannelCount(sourceChannelCount: number): void;
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
- * `sourceChannelCount` (max channel count across the new clips) re-selects
515
- * the track's pan law; omit to leave it unchanged.
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, sourceChannelCount?: number): boolean;
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
- /** Max channel count across clips — selects the pan law (core's createPanStage). Default: 1 */
38
- channelCount?: number;
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
- * Select the pan law from the track's source material: 1 = mono law,
92
- * 2+ = stereo law. Call when the track's clips change — a stereo clip
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
- setSourceChannelCount(sourceChannelCount: number): void;
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
- * `sourceChannelCount` (max channel count across the new clips) re-selects
515
- * the track's pan law; omit to leave it unchanged.
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, sourceChannelCount?: number): boolean;
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.channelCount ?? 1
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
- * Select the pan law from the track's source material: 1 = mono law,
222
- * 2+ = stereo law. Call when the track's clips change — a stereo clip
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
- setSourceChannelCount(sourceChannelCount) {
227
- this.panStage.setSourceChannelCount(sourceChannelCount);
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 —
@@ -590,7 +588,7 @@ var MidiToneTrack = class {
590
588
  this.panStage = (0, import_core2.createPanStage)(
591
589
  (0, import_tone2.getContext)().rawContext,
592
590
  options.track.stereoPan,
593
- 1
591
+ "mono"
594
592
  );
595
593
  this.muteGain = new import_tone2.Gain(options.track.muted ? 0 : 1);
596
594
  this.volumeNode.connect(this.panStage.input);
@@ -926,7 +924,7 @@ var SoundFontToneTrack = class {
926
924
  this.panStage = (0, import_core3.createPanStage)(
927
925
  (0, import_tone3.getContext)().rawContext,
928
926
  options.track.stereoPan,
929
- 1
927
+ "mono"
930
928
  );
931
929
  this.muteGain = new import_tone3.Gain(options.track.muted ? 0 : 1);
932
930
  this.volumeNode.connect(this.panStage.input);
@@ -1308,16 +1306,16 @@ var TonePlayout = class {
1308
1306
  /**
1309
1307
  * Replace clips on a track, preserving the track's audio graph.
1310
1308
  * Only works for ToneTrack (audio clips), not MidiToneTrack.
1311
- * `sourceChannelCount` (max channel count across the new clips) re-selects
1312
- * the track's pan law; omit to leave it unchanged.
1309
+ * `panLaw` is the track's pan law (core's trackPanLaw); omit to leave it
1310
+ * unchanged.
1313
1311
  */
1314
- replaceTrackClips(trackId, newClips, newStartTime, sourceChannelCount) {
1312
+ replaceTrackClips(trackId, newClips, newStartTime, panLaw) {
1315
1313
  const track = this.tracks.get(trackId);
1316
1314
  if (!track || !("replaceClips" in track)) return false;
1317
1315
  const toneTrack = track;
1318
1316
  toneTrack.replaceClips(newClips, newStartTime);
1319
- if (sourceChannelCount !== void 0) {
1320
- toneTrack.setSourceChannelCount(sourceChannelCount);
1317
+ if (panLaw !== void 0) {
1318
+ toneTrack.setPanLaw(panLaw);
1321
1319
  }
1322
1320
  return true;
1323
1321
  }
@@ -1992,7 +1990,7 @@ function createToneAdapter(options) {
1992
1990
  clips: clipInfos,
1993
1991
  track: trackObj,
1994
1992
  effects: options?.trackEffects?.(track.id),
1995
- channelCount: (0, import_core5.trackChannelCount)(track)
1993
+ panLaw: (0, import_core5.trackPanLaw)(track)
1996
1994
  });
1997
1995
  }
1998
1996
  function addMidiTrackToPlayout(p, track) {
@@ -2170,7 +2168,7 @@ function createToneAdapter(options) {
2170
2168
  trackId,
2171
2169
  clipInfos,
2172
2170
  startTime,
2173
- (0, import_core5.trackChannelCount)(track)
2171
+ (0, import_core5.trackPanLaw)(track)
2174
2172
  );
2175
2173
  if (audioUpdated) {
2176
2174
  playout.applyInitialSoloState();
@@ -2257,6 +2255,15 @@ function createToneAdapter(options) {
2257
2255
  if (existing) _currentTracks.set(trackId, { ...existing, pan });
2258
2256
  playout?.getTrack(trackId)?.setPan(pan);
2259
2257
  },
2258
+ // A track's pan law changed (#684). 'auto': from the clips of the track
2259
+ // last sent. The clips are not replaced; the pan stage ramps. A MIDI or
2260
+ // SoundFont track has no law to set.
2261
+ setTrackPanLaw(trackId, panLaw) {
2262
+ const existing = _currentTracks.get(trackId);
2263
+ const track = playout?.getTrack(trackId);
2264
+ if (!existing || !track || !("setPanLaw" in track)) return;
2265
+ track.setPanLaw((0, import_core5.trackPanLaw)({ ...existing, panLaw }));
2266
+ },
2260
2267
  setLoop(enabled, start2, end) {
2261
2268
  _loopEnabled = enabled;
2262
2269
  _loopStart = start2;