@waveform-playlist/playout 11.3.1 → 12.1.0

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,6 +1,5 @@
1
1
  import { Gain, ToneAudioNode, SynthOptions, Volume, BaseContext, Context } from 'tone';
2
2
  import { Fade, Track, MidiNoteData } from '@waveform-playlist/core';
3
- export { FadeConfig, FadeType, applyFadeIn, applyFadeOut } from '@waveform-playlist/core';
4
3
  import { ZoneMap, Generator, GeneratorType } from 'soundfont2';
5
4
  import { PlayoutAdapter } from '@waveform-playlist/engine';
6
5
 
@@ -603,6 +602,8 @@ interface ToneAdapterOptions {
603
602
  effects?: EffectsFunction;
604
603
  /** When provided, MIDI clips use SoundFont sample playback instead of PolySynth */
605
604
  soundFontCache?: SoundFontCache;
605
+ /** Pulses per quarter note. Defaults to 192 (Tone.js native). */
606
+ ppqn?: number;
606
607
  }
607
608
  declare function createToneAdapter(options?: ToneAdapterOptions): PlayoutAdapter;
608
609
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Gain, ToneAudioNode, SynthOptions, Volume, BaseContext, Context } from 'tone';
2
2
  import { Fade, Track, MidiNoteData } from '@waveform-playlist/core';
3
- export { FadeConfig, FadeType, applyFadeIn, applyFadeOut } from '@waveform-playlist/core';
4
3
  import { ZoneMap, Generator, GeneratorType } from 'soundfont2';
5
4
  import { PlayoutAdapter } from '@waveform-playlist/engine';
6
5
 
@@ -603,6 +602,8 @@ interface ToneAdapterOptions {
603
602
  effects?: EffectsFunction;
604
603
  /** When provided, MIDI clips use SoundFont sample playback instead of PolySynth */
605
604
  soundFontCache?: SoundFontCache;
605
+ /** Pulses per quarter note. Defaults to 192 (Tone.js native). */
606
+ ppqn?: number;
606
607
  }
607
608
  declare function createToneAdapter(options?: ToneAdapterOptions): PlayoutAdapter;
608
609
 
package/dist/index.js CHANGED
@@ -25,8 +25,6 @@ __export(index_exports, {
25
25
  SoundFontToneTrack: () => SoundFontToneTrack,
26
26
  TonePlayout: () => TonePlayout,
27
27
  ToneTrack: () => ToneTrack,
28
- applyFadeIn: () => import_core.applyFadeIn,
29
- applyFadeOut: () => import_core.applyFadeOut,
30
28
  calculatePlaybackRate: () => calculatePlaybackRate,
31
29
  closeGlobalAudioContext: () => closeGlobalAudioContext,
32
30
  configureGlobalContext: () => configureGlobalContext,
@@ -1636,6 +1634,8 @@ function createToneAdapter(options) {
1636
1634
  let _loopEnd = 0;
1637
1635
  let _audioInitialized = false;
1638
1636
  let _pendingInit = null;
1637
+ const _ppqn = options?.ppqn ?? 192;
1638
+ let _bpm = 120;
1639
1639
  function addTrackToPlayout(p, track) {
1640
1640
  const audioClips = track.clips.filter((c) => c.audioBuffer && !c.midiNotes);
1641
1641
  const midiClips = track.clips.filter((c) => c.midiNotes && c.midiNotes.length > 0);
@@ -1889,11 +1889,50 @@ function createToneAdapter(options) {
1889
1889
  _loopEnd = end;
1890
1890
  playout?.setLoop(enabled, start2, end);
1891
1891
  },
1892
+ get audioContext() {
1893
+ return getGlobalAudioContext();
1894
+ },
1895
+ get ppqn() {
1896
+ return _ppqn;
1897
+ },
1898
+ setTempo(bpm, atTick) {
1899
+ if (atTick !== void 0) {
1900
+ throw new Error(
1901
+ "Multiple tempo changes not supported by TonePlayoutAdapter. Use NativePlayoutAdapter from @dawcore/transport for multi-tempo support."
1902
+ );
1903
+ }
1904
+ _bpm = bpm;
1905
+ },
1906
+ setMeter(_numerator, _denominator, atTick) {
1907
+ if (atTick !== void 0) {
1908
+ throw new Error(
1909
+ "Multiple meter changes not supported by TonePlayoutAdapter. Use NativePlayoutAdapter from @dawcore/transport for multi-meter support."
1910
+ );
1911
+ }
1912
+ },
1913
+ ticksToSeconds(tick) {
1914
+ return tick * 60 / (_bpm * _ppqn);
1915
+ },
1916
+ secondsToTicks(seconds) {
1917
+ return seconds * _bpm * _ppqn / 60;
1918
+ },
1919
+ // --- Cross-context worklet support ---
1920
+ // Tone.js wraps standardized-audio-context. Native AudioWorkletNode constructor
1921
+ // rejects it ("parameter 1 is not of type 'BaseAudioContext'").
1922
+ // These methods use Tone.js Context wrappers that handle both context types.
1923
+ // Note: addWorkletModule is NOT needed — rawContext.audioWorklet.addModule() works
1924
+ // identically for both native and standardized contexts. Only node/source creation differs.
1925
+ createAudioWorkletNode(name, options2) {
1926
+ return getGlobalContext().createAudioWorkletNode(name, options2);
1927
+ },
1928
+ createMediaStreamSource(stream) {
1929
+ return getGlobalContext().createMediaStreamSource(stream);
1930
+ },
1892
1931
  dispose() {
1893
1932
  try {
1894
1933
  playout?.dispose();
1895
1934
  } catch (err) {
1896
- console.warn("[waveform-playlist] Error disposing playout:", err);
1935
+ console.warn("[waveform-playlist] Error disposing playout: " + String(err));
1897
1936
  }
1898
1937
  playout = null;
1899
1938
  _isPlaying = false;
@@ -1907,8 +1946,6 @@ function createToneAdapter(options) {
1907
1946
  SoundFontToneTrack,
1908
1947
  TonePlayout,
1909
1948
  ToneTrack,
1910
- applyFadeIn,
1911
- applyFadeOut,
1912
1949
  calculatePlaybackRate,
1913
1950
  closeGlobalAudioContext,
1914
1951
  configureGlobalContext,