@waveform-playlist/playout 11.0.1 → 11.2.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 +21 -1
- package/dist/index.d.ts +21 -1
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -489,6 +489,26 @@ declare class TonePlayout {
|
|
|
489
489
|
* cross-browser compatibility (fixes Firefox AudioListener issues).
|
|
490
490
|
*/
|
|
491
491
|
|
|
492
|
+
interface AudioContextOptions {
|
|
493
|
+
/** Desired sample rate. Creates a standardized-audio-context AudioContext
|
|
494
|
+
* at this rate, bypassing Tone.js 15.1.22's limitation. Cross-browser safe. */
|
|
495
|
+
sampleRate?: number;
|
|
496
|
+
/** Latency hint passed to the AudioContext constructor. */
|
|
497
|
+
latencyHint?: AudioContextLatencyCategory | number;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Configure the global AudioContext with sample rate and latency hints.
|
|
501
|
+
* Creates a standardized-audio-context AudioContext (cross-browser, fixes
|
|
502
|
+
* Firefox AudioListener bug) and wraps it in Tone.js Context.
|
|
503
|
+
*
|
|
504
|
+
* Should be called BEFORE getGlobalContext(). If the context already exists
|
|
505
|
+
* (e.g., from resumeGlobalAudioContext), warns and returns the existing rate.
|
|
506
|
+
*
|
|
507
|
+
* ```ts
|
|
508
|
+
* configureGlobalContext({ sampleRate: 48000, latencyHint: 0 })
|
|
509
|
+
* ```
|
|
510
|
+
*/
|
|
511
|
+
declare function configureGlobalContext(options: AudioContextOptions): number;
|
|
492
512
|
/**
|
|
493
513
|
* Get the global Tone.js Context
|
|
494
514
|
* This is the main context for cross-browser audio operations.
|
|
@@ -588,4 +608,4 @@ interface ToneAdapterOptions {
|
|
|
588
608
|
}
|
|
589
609
|
declare function createToneAdapter(options?: ToneAdapterOptions): PlayoutAdapter;
|
|
590
610
|
|
|
591
|
-
export { type EffectsFunction, type LoopAndEnvelopeParams, type MidiClipInfo, MidiToneTrack, type MidiToneTrackOptions, type PlayableTrack, type PlaybackRateParams, SoundFontCache, type SoundFontSample, SoundFontToneTrack, type SoundFontToneTrackOptions, type ToneAdapterOptions, TonePlayout, type TonePlayoutOptions, ToneTrack, type ToneTrackOptions, type TrackEffectsFunction, calculatePlaybackRate, closeGlobalAudioContext, createToneAdapter, extractLoopAndEnvelope, getGeneratorValue, getGlobalAudioContext, getGlobalAudioContextState, getGlobalContext, getGlobalToneContext, getMediaStreamSource, getUnderlyingAudioParam, hasMediaStreamSource, int16ToFloat32, releaseMediaStreamSource, resumeGlobalAudioContext, timecentsToSeconds };
|
|
611
|
+
export { type AudioContextOptions, type EffectsFunction, type LoopAndEnvelopeParams, type MidiClipInfo, MidiToneTrack, type MidiToneTrackOptions, type PlayableTrack, type PlaybackRateParams, SoundFontCache, type SoundFontSample, SoundFontToneTrack, type SoundFontToneTrackOptions, type ToneAdapterOptions, TonePlayout, type TonePlayoutOptions, ToneTrack, type ToneTrackOptions, type TrackEffectsFunction, calculatePlaybackRate, closeGlobalAudioContext, configureGlobalContext, createToneAdapter, extractLoopAndEnvelope, getGeneratorValue, getGlobalAudioContext, getGlobalAudioContextState, getGlobalContext, getGlobalToneContext, getMediaStreamSource, getUnderlyingAudioParam, hasMediaStreamSource, int16ToFloat32, releaseMediaStreamSource, resumeGlobalAudioContext, timecentsToSeconds };
|
package/dist/index.d.ts
CHANGED
|
@@ -489,6 +489,26 @@ declare class TonePlayout {
|
|
|
489
489
|
* cross-browser compatibility (fixes Firefox AudioListener issues).
|
|
490
490
|
*/
|
|
491
491
|
|
|
492
|
+
interface AudioContextOptions {
|
|
493
|
+
/** Desired sample rate. Creates a standardized-audio-context AudioContext
|
|
494
|
+
* at this rate, bypassing Tone.js 15.1.22's limitation. Cross-browser safe. */
|
|
495
|
+
sampleRate?: number;
|
|
496
|
+
/** Latency hint passed to the AudioContext constructor. */
|
|
497
|
+
latencyHint?: AudioContextLatencyCategory | number;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Configure the global AudioContext with sample rate and latency hints.
|
|
501
|
+
* Creates a standardized-audio-context AudioContext (cross-browser, fixes
|
|
502
|
+
* Firefox AudioListener bug) and wraps it in Tone.js Context.
|
|
503
|
+
*
|
|
504
|
+
* Should be called BEFORE getGlobalContext(). If the context already exists
|
|
505
|
+
* (e.g., from resumeGlobalAudioContext), warns and returns the existing rate.
|
|
506
|
+
*
|
|
507
|
+
* ```ts
|
|
508
|
+
* configureGlobalContext({ sampleRate: 48000, latencyHint: 0 })
|
|
509
|
+
* ```
|
|
510
|
+
*/
|
|
511
|
+
declare function configureGlobalContext(options: AudioContextOptions): number;
|
|
492
512
|
/**
|
|
493
513
|
* Get the global Tone.js Context
|
|
494
514
|
* This is the main context for cross-browser audio operations.
|
|
@@ -588,4 +608,4 @@ interface ToneAdapterOptions {
|
|
|
588
608
|
}
|
|
589
609
|
declare function createToneAdapter(options?: ToneAdapterOptions): PlayoutAdapter;
|
|
590
610
|
|
|
591
|
-
export { type EffectsFunction, type LoopAndEnvelopeParams, type MidiClipInfo, MidiToneTrack, type MidiToneTrackOptions, type PlayableTrack, type PlaybackRateParams, SoundFontCache, type SoundFontSample, SoundFontToneTrack, type SoundFontToneTrackOptions, type ToneAdapterOptions, TonePlayout, type TonePlayoutOptions, ToneTrack, type ToneTrackOptions, type TrackEffectsFunction, calculatePlaybackRate, closeGlobalAudioContext, createToneAdapter, extractLoopAndEnvelope, getGeneratorValue, getGlobalAudioContext, getGlobalAudioContextState, getGlobalContext, getGlobalToneContext, getMediaStreamSource, getUnderlyingAudioParam, hasMediaStreamSource, int16ToFloat32, releaseMediaStreamSource, resumeGlobalAudioContext, timecentsToSeconds };
|
|
611
|
+
export { type AudioContextOptions, type EffectsFunction, type LoopAndEnvelopeParams, type MidiClipInfo, MidiToneTrack, type MidiToneTrackOptions, type PlayableTrack, type PlaybackRateParams, SoundFontCache, type SoundFontSample, SoundFontToneTrack, type SoundFontToneTrackOptions, type ToneAdapterOptions, TonePlayout, type TonePlayoutOptions, ToneTrack, type ToneTrackOptions, type TrackEffectsFunction, calculatePlaybackRate, closeGlobalAudioContext, configureGlobalContext, createToneAdapter, extractLoopAndEnvelope, getGeneratorValue, getGlobalAudioContext, getGlobalAudioContextState, getGlobalContext, getGlobalToneContext, getMediaStreamSource, getUnderlyingAudioParam, hasMediaStreamSource, int16ToFloat32, releaseMediaStreamSource, resumeGlobalAudioContext, timecentsToSeconds };
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,7 @@ __export(index_exports, {
|
|
|
29
29
|
applyFadeOut: () => import_core.applyFadeOut,
|
|
30
30
|
calculatePlaybackRate: () => calculatePlaybackRate,
|
|
31
31
|
closeGlobalAudioContext: () => closeGlobalAudioContext,
|
|
32
|
+
configureGlobalContext: () => configureGlobalContext,
|
|
32
33
|
createToneAdapter: () => createToneAdapter,
|
|
33
34
|
extractLoopAndEnvelope: () => extractLoopAndEnvelope,
|
|
34
35
|
getGeneratorValue: () => getGeneratorValue,
|
|
@@ -1546,6 +1547,26 @@ var SoundFontCache = class {
|
|
|
1546
1547
|
// src/audioContext.ts
|
|
1547
1548
|
var import_tone5 = require("tone");
|
|
1548
1549
|
var globalToneContext = null;
|
|
1550
|
+
function configureGlobalContext(options) {
|
|
1551
|
+
if (globalToneContext) {
|
|
1552
|
+
const existingRate = globalToneContext.rawContext.sampleRate;
|
|
1553
|
+
if (options.sampleRate !== void 0 && options.sampleRate !== existingRate) {
|
|
1554
|
+
console.warn(
|
|
1555
|
+
"[playout] configureGlobalContext: context already created at " + existingRate + " Hz (requested " + options.sampleRate + " Hz). Call configureGlobalContext before any audio operations for sample rate control."
|
|
1556
|
+
);
|
|
1557
|
+
}
|
|
1558
|
+
return existingRate;
|
|
1559
|
+
}
|
|
1560
|
+
globalToneContext = new import_tone5.Context();
|
|
1561
|
+
(0, import_tone5.setContext)(globalToneContext);
|
|
1562
|
+
const actualRate = globalToneContext.rawContext.sampleRate;
|
|
1563
|
+
if (options.sampleRate !== void 0 && options.sampleRate !== actualRate) {
|
|
1564
|
+
console.warn(
|
|
1565
|
+
"[playout] Requested sampleRate " + options.sampleRate + " but AudioContext is running at " + actualRate + " \u2014 pre-computed peaks at " + options.sampleRate + " Hz will fall back to worker"
|
|
1566
|
+
);
|
|
1567
|
+
}
|
|
1568
|
+
return actualRate;
|
|
1569
|
+
}
|
|
1549
1570
|
function getGlobalContext() {
|
|
1550
1571
|
if (!globalToneContext) {
|
|
1551
1572
|
globalToneContext = new import_tone5.Context();
|
|
@@ -1894,6 +1915,7 @@ function createToneAdapter(options) {
|
|
|
1894
1915
|
applyFadeOut,
|
|
1895
1916
|
calculatePlaybackRate,
|
|
1896
1917
|
closeGlobalAudioContext,
|
|
1918
|
+
configureGlobalContext,
|
|
1897
1919
|
createToneAdapter,
|
|
1898
1920
|
extractLoopAndEnvelope,
|
|
1899
1921
|
getGeneratorValue,
|