@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.mjs CHANGED
@@ -42,7 +42,7 @@ var ToneTrack = class {
42
42
  this.panStage = createPanStage(
43
43
  getContext().rawContext,
44
44
  options.track.stereoPan,
45
- options.channelCount ?? 1
45
+ options.panLaw ?? "mono"
46
46
  );
47
47
  this.muteGain = new Gain(options.track.muted ? 0 : 1);
48
48
  this.volumeNode.connect(this.panStage.input);
@@ -188,13 +188,11 @@ var ToneTrack = class {
188
188
  this.scheduledClips.splice(index, 1);
189
189
  }
190
190
  /**
191
- * Select the pan law from the track's source material: 1 = mono law,
192
- * 2+ = stereo law. Call when the track's clips change — a stereo clip
193
- * joining a mono track moves it to the stereo law (same rule as the
194
- * native transport and the offline export).
191
+ * Switch the track's pan law (the gains ramp). The law is the track's own
192
+ * (#684): its clips do not change it, on any renderer.
195
193
  */
196
- setSourceChannelCount(sourceChannelCount) {
197
- this.panStage.setSourceChannelCount(sourceChannelCount);
194
+ setPanLaw(panLaw) {
195
+ this.panStage.setPanLaw(panLaw);
198
196
  }
199
197
  /**
200
198
  * Replace clips on this track. Diffs old vs new by buffer + timing —
@@ -575,7 +573,7 @@ var MidiToneTrack = class {
575
573
  this.panStage = createPanStage2(
576
574
  getContext2().rawContext,
577
575
  options.track.stereoPan,
578
- 1
576
+ "mono"
579
577
  );
580
578
  this.muteGain = new Gain2(options.track.muted ? 0 : 1);
581
579
  this.volumeNode.connect(this.panStage.input);
@@ -911,7 +909,7 @@ var SoundFontToneTrack = class {
911
909
  this.panStage = createPanStage3(
912
910
  getContext3().rawContext,
913
911
  options.track.stereoPan,
914
- 1
912
+ "mono"
915
913
  );
916
914
  this.muteGain = new Gain3(options.track.muted ? 0 : 1);
917
915
  this.volumeNode.connect(this.panStage.input);
@@ -1293,16 +1291,16 @@ var TonePlayout = class {
1293
1291
  /**
1294
1292
  * Replace clips on a track, preserving the track's audio graph.
1295
1293
  * Only works for ToneTrack (audio clips), not MidiToneTrack.
1296
- * `sourceChannelCount` (max channel count across the new clips) re-selects
1297
- * the track's pan law; omit to leave it unchanged.
1294
+ * `panLaw` is the track's pan law (core's trackPanLaw); omit to leave it
1295
+ * unchanged.
1298
1296
  */
1299
- replaceTrackClips(trackId, newClips, newStartTime, sourceChannelCount) {
1297
+ replaceTrackClips(trackId, newClips, newStartTime, panLaw) {
1300
1298
  const track = this.tracks.get(trackId);
1301
1299
  if (!track || !("replaceClips" in track)) return false;
1302
1300
  const toneTrack = track;
1303
1301
  toneTrack.replaceClips(newClips, newStartTime);
1304
- if (sourceChannelCount !== void 0) {
1305
- toneTrack.setSourceChannelCount(sourceChannelCount);
1302
+ if (panLaw !== void 0) {
1303
+ toneTrack.setPanLaw(panLaw);
1306
1304
  }
1307
1305
  return true;
1308
1306
  }
@@ -1922,7 +1920,7 @@ import {
1922
1920
  clipEndTime,
1923
1921
  clipOffsetTime,
1924
1922
  clipDurationTime,
1925
- trackChannelCount,
1923
+ trackPanLaw,
1926
1924
  trackKind
1927
1925
  } from "@waveform-playlist/core";
1928
1926
  import { now as now2 } from "tone";
@@ -1984,7 +1982,7 @@ function createToneAdapter(options) {
1984
1982
  clips: clipInfos,
1985
1983
  track: trackObj,
1986
1984
  effects: options?.trackEffects?.(track.id),
1987
- channelCount: trackChannelCount(track)
1985
+ panLaw: trackPanLaw(track)
1988
1986
  });
1989
1987
  }
1990
1988
  function addMidiTrackToPlayout(p, track) {
@@ -2162,7 +2160,7 @@ function createToneAdapter(options) {
2162
2160
  trackId,
2163
2161
  clipInfos,
2164
2162
  startTime,
2165
- trackChannelCount(track)
2163
+ trackPanLaw(track)
2166
2164
  );
2167
2165
  if (audioUpdated) {
2168
2166
  playout.applyInitialSoloState();
@@ -2249,6 +2247,15 @@ function createToneAdapter(options) {
2249
2247
  if (existing) _currentTracks.set(trackId, { ...existing, pan });
2250
2248
  playout?.getTrack(trackId)?.setPan(pan);
2251
2249
  },
2250
+ // A track's pan law changed (#684). 'auto': from the clips of the track
2251
+ // last sent. The clips are not replaced; the pan stage ramps. A MIDI or
2252
+ // SoundFont track has no law to set.
2253
+ setTrackPanLaw(trackId, panLaw) {
2254
+ const existing = _currentTracks.get(trackId);
2255
+ const track = playout?.getTrack(trackId);
2256
+ if (!existing || !track || !("setPanLaw" in track)) return;
2257
+ track.setPanLaw(trackPanLaw({ ...existing, panLaw }));
2258
+ },
2252
2259
  setLoop(enabled, start2, end) {
2253
2260
  _loopEnabled = enabled;
2254
2261
  _loopStart = start2;