@waveform-playlist/browser 16.0.0 → 17.0.0-next.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/README.md +69 -33
- package/dist/index.d.mts +1272 -704
- package/dist/index.d.ts +1272 -704
- package/dist/index.js +5232 -3744
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5183 -3726
- package/dist/index.mjs.map +1 -1
- package/dist/tone.d.mts +162 -210
- package/dist/tone.d.ts +162 -210
- package/dist/tone.js +719 -1000
- package/dist/tone.js.map +1 -1
- package/dist/tone.mjs +702 -985
- package/dist/tone.mjs.map +1 -1
- package/package.json +20 -18
package/dist/tone.d.mts
CHANGED
|
@@ -1,116 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { EffectsFunction, TrackEffectsFunction as TrackEffectsFunction$1 } from '@waveform-playlist/playout';
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import react__default from 'react';
|
|
3
|
+
import { EffectsFunction, TrackEffectsFunction } from '@waveform-playlist/playout';
|
|
5
4
|
import { Analyser, Volume, ToneAudioNode, Gain, InputNode } from 'tone';
|
|
5
|
+
import { ClipTrack, ValueSource, MeterSource, NativeEffectInstance } from '@waveform-playlist/core';
|
|
6
6
|
import * as _dawcore_wam from '@dawcore/wam';
|
|
7
7
|
import { WamPluginInstance } from '@dawcore/wam';
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* Configuration for a single audio track to load
|
|
11
|
-
*
|
|
12
|
-
* Audio can be provided in three ways:
|
|
13
|
-
* 1. `src` - URL to fetch and decode (standard loading)
|
|
14
|
-
* 2. `audioBuffer` - Pre-loaded AudioBuffer (skip fetch/decode)
|
|
15
|
-
* 3. `waveformData` only - Peaks-first rendering (audio loads later)
|
|
16
|
-
*
|
|
17
|
-
* For peaks-first rendering, just provide `waveformData` - the sample rate
|
|
18
|
-
* and duration are derived from the waveform data automatically.
|
|
19
|
-
*/
|
|
20
|
-
interface AudioTrackConfig {
|
|
21
|
-
/** URL to audio file - used if audioBuffer not provided */
|
|
22
|
-
src?: string;
|
|
23
|
-
/** Pre-loaded AudioBuffer - skips fetch/decode if provided */
|
|
24
|
-
audioBuffer?: AudioBuffer;
|
|
25
|
-
name?: string;
|
|
26
|
-
muted?: boolean;
|
|
27
|
-
soloed?: boolean;
|
|
28
|
-
volume?: number;
|
|
29
|
-
pan?: number;
|
|
30
|
-
color?: string;
|
|
31
|
-
effects?: TrackEffectsFunction;
|
|
32
|
-
startTime?: number;
|
|
33
|
-
duration?: number;
|
|
34
|
-
offset?: number;
|
|
35
|
-
fadeIn?: Fade;
|
|
36
|
-
fadeOut?: Fade;
|
|
37
|
-
waveformData?: WaveformDataObject;
|
|
38
|
-
/** Visualization render mode: 'waveform' | 'spectrogram' | 'both'. Default: 'waveform' */
|
|
39
|
-
renderMode?: RenderMode;
|
|
40
|
-
/** Spectrogram configuration (FFT size, window, frequency scale, etc.) */
|
|
41
|
-
spectrogramConfig?: SpectrogramConfig;
|
|
42
|
-
/** Spectrogram color map name or custom color array */
|
|
43
|
-
spectrogramColorMap?: ColorMapValue;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Options for useAudioTracks hook
|
|
47
|
-
*/
|
|
48
|
-
interface UseAudioTracksOptions {
|
|
49
|
-
/**
|
|
50
|
-
* When true, all tracks render immediately as placeholders with clip geometry
|
|
51
|
-
* from the config. Audio fills in progressively as files decode, and peaks
|
|
52
|
-
* render as each buffer becomes available. Use with `deferEngineRebuild={loading}`
|
|
53
|
-
* on the provider for a single engine build when all tracks are ready.
|
|
54
|
-
*
|
|
55
|
-
* Requires `duration` or `waveformData` in each config so clip dimensions are known upfront.
|
|
56
|
-
* Default: false
|
|
57
|
-
*/
|
|
58
|
-
immediate?: boolean;
|
|
59
|
-
/** @deprecated Use `immediate` instead. */
|
|
60
|
-
progressive?: boolean;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Hook to load audio from URLs and convert to ClipTrack format
|
|
64
|
-
*
|
|
65
|
-
* This hook fetches audio files, decodes them, and creates ClipTrack objects
|
|
66
|
-
* with a single clip per track. Supports custom positioning for multi-clip arrangements.
|
|
67
|
-
*
|
|
68
|
-
* @param configs - Array of audio track configurations
|
|
69
|
-
* @param options - Optional configuration for loading behavior
|
|
70
|
-
* @returns Object with tracks array, loading state, and progress info
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* ```typescript
|
|
74
|
-
* // Basic usage (clips positioned at start)
|
|
75
|
-
* const { tracks, loading, error } = useAudioTracks([
|
|
76
|
-
* { src: 'audio/vocals.mp3', name: 'Vocals' },
|
|
77
|
-
* { src: 'audio/drums.mp3', name: 'Drums' },
|
|
78
|
-
* ]);
|
|
79
|
-
*
|
|
80
|
-
* // Immediate rendering with deferred engine build (recommended for multi-track)
|
|
81
|
-
* const { tracks, loading } = useAudioTracks(
|
|
82
|
-
* [
|
|
83
|
-
* { src: 'audio/vocals.mp3', name: 'Vocals', duration: 30 },
|
|
84
|
-
* { src: 'audio/drums.mp3', name: 'Drums', duration: 30 },
|
|
85
|
-
* ],
|
|
86
|
-
* { immediate: true }
|
|
87
|
-
* );
|
|
88
|
-
* // All tracks render instantly as placeholders, peaks fill in as files load
|
|
89
|
-
* return (
|
|
90
|
-
* <WaveformPlaylistProvider tracks={tracks} deferEngineRebuild={loading}>
|
|
91
|
-
* ...
|
|
92
|
-
* </WaveformPlaylistProvider>
|
|
93
|
-
* );
|
|
94
|
-
*
|
|
95
|
-
* // Pre-loaded AudioBuffer (skip fetch/decode)
|
|
96
|
-
* const { tracks } = useAudioTracks([
|
|
97
|
-
* { audioBuffer: myPreloadedBuffer, name: 'Pre-loaded' },
|
|
98
|
-
* ]);
|
|
99
|
-
*
|
|
100
|
-
* // Peaks-first rendering (instant visual, audio loads later)
|
|
101
|
-
* const { tracks } = useAudioTracks([
|
|
102
|
-
* { waveformData: preloadedPeaks, name: 'Peaks Only' }, // Renders immediately
|
|
103
|
-
* ]);
|
|
104
|
-
* ```
|
|
105
|
-
*/
|
|
106
|
-
declare function useAudioTracks(configs: AudioTrackConfig[], options?: UseAudioTracksOptions): {
|
|
107
|
-
tracks: ClipTrack[];
|
|
108
|
-
loading: boolean;
|
|
109
|
-
error: string | null;
|
|
110
|
-
loadedCount: number;
|
|
111
|
-
totalCount: number;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
9
|
/**
|
|
115
10
|
* Hook for master effects with frequency analyzer
|
|
116
11
|
* Returns the analyser ref and the effects function to pass to WaveformPlaylistProvider
|
|
@@ -118,7 +13,7 @@ declare function useAudioTracks(configs: AudioTrackConfig[], options?: UseAudioT
|
|
|
118
13
|
* For more advanced effects (reverb, delay, filters, etc.), use useDynamicEffects instead.
|
|
119
14
|
*/
|
|
120
15
|
declare const useMasterAnalyser: (fftSize?: number) => {
|
|
121
|
-
analyserRef:
|
|
16
|
+
analyserRef: react.RefObject<Analyser | null>;
|
|
122
17
|
masterEffects: EffectsFunction;
|
|
123
18
|
};
|
|
124
19
|
|
|
@@ -141,10 +36,17 @@ interface EffectParameter {
|
|
|
141
36
|
label: string;
|
|
142
37
|
}[];
|
|
143
38
|
}
|
|
39
|
+
/** The categories the built-in effects use. */
|
|
40
|
+
type BuiltInEffectCategory = 'delay' | 'reverb' | 'modulation' | 'distortion' | 'filter' | 'dynamics' | 'spatial' | 'wam';
|
|
41
|
+
type EffectCategory = BuiltInEffectCategory | (string & {});
|
|
144
42
|
interface EffectDefinition {
|
|
145
43
|
id: string;
|
|
146
44
|
name: string;
|
|
147
|
-
|
|
45
|
+
/**
|
|
46
|
+
* The built-in effects use the listed categories and WAM plugins use
|
|
47
|
+
* `'wam'`; a registered custom effect may name any category of its own.
|
|
48
|
+
*/
|
|
49
|
+
category: EffectCategory;
|
|
148
50
|
description: string;
|
|
149
51
|
parameters: EffectParameter[];
|
|
150
52
|
}
|
|
@@ -156,6 +58,29 @@ declare const effectCategories: {
|
|
|
156
58
|
name: string;
|
|
157
59
|
}[];
|
|
158
60
|
|
|
61
|
+
type EffectParameterValue = number | string | boolean;
|
|
62
|
+
interface ActiveEffect {
|
|
63
|
+
instanceId: string;
|
|
64
|
+
effectId: string;
|
|
65
|
+
/**
|
|
66
|
+
* 'tone' = built-in Tone.js effect; 'wam' = hosted WAM plugin;
|
|
67
|
+
* 'custom' = a type registered with `registerEffect()` from
|
|
68
|
+
* `@waveform-playlist/core`.
|
|
69
|
+
*/
|
|
70
|
+
kind: 'tone' | 'wam' | 'custom';
|
|
71
|
+
/** Module URL for wam entries. */
|
|
72
|
+
url?: string;
|
|
73
|
+
definition: EffectDefinition;
|
|
74
|
+
params: Record<string, EffectParameterValue>;
|
|
75
|
+
bypassed: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* The effect's wet/dry parameter, when it has one. Bypass sets it to 0 and
|
|
78
|
+
* leaves the effect in the chain; an effect without one is bypassed by
|
|
79
|
+
* disconnecting it.
|
|
80
|
+
*/
|
|
81
|
+
wetParam?: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
159
84
|
/**
|
|
160
85
|
* WAV file encoder
|
|
161
86
|
* Converts AudioBuffer to WAV format Blob
|
|
@@ -173,8 +98,12 @@ type OfflineEffectsCleanup = void | (() => void);
|
|
|
173
98
|
* Every live EffectsFunction is assignable to this type.
|
|
174
99
|
*/
|
|
175
100
|
type OfflineEffectsFunction = (masterVolume: Volume, destination: ToneAudioNode, isOffline: boolean) => OfflineEffectsCleanup | Promise<OfflineEffectsCleanup>;
|
|
176
|
-
/**
|
|
177
|
-
|
|
101
|
+
/**
|
|
102
|
+
* Per-track variant of OfflineEffectsFunction. Pre-fader, like the live
|
|
103
|
+
* TrackEffectsFunction: wire `trackInput` through the effects into
|
|
104
|
+
* `faderInput` (the track's volume stage) — never straight to the master.
|
|
105
|
+
*/
|
|
106
|
+
type OfflineTrackEffectsFunction = (trackInput: Gain, faderInput: ToneAudioNode, isOffline: boolean) => OfflineEffectsCleanup | Promise<OfflineEffectsCleanup>;
|
|
178
107
|
interface ExportOptions extends WavEncoderOptions {
|
|
179
108
|
/** Filename for download (without extension) */
|
|
180
109
|
filename?: string;
|
|
@@ -195,7 +124,7 @@ interface ExportOptions extends WavEncoderOptions {
|
|
|
195
124
|
/**
|
|
196
125
|
* Optional function to create offline track effects.
|
|
197
126
|
* Takes a trackId and returns an offline effects function for that track.
|
|
198
|
-
*
|
|
127
|
+
* The live chain cannot be used: its nodes belong to the live AudioContext.
|
|
199
128
|
*/
|
|
200
129
|
createOfflineTrackEffects?: (trackId: string) => OfflineTrackEffectsFunction | undefined;
|
|
201
130
|
/** Progress callback (0-1) */
|
|
@@ -211,7 +140,7 @@ interface ExportResult {
|
|
|
211
140
|
}
|
|
212
141
|
interface UseExportWavReturn {
|
|
213
142
|
/** Export the playlist to WAV */
|
|
214
|
-
exportWav: (tracks: ClipTrack[], trackStates: TrackState[], options?: ExportOptions) => Promise<ExportResult>;
|
|
143
|
+
exportWav: (tracks: readonly ClipTrack[], trackStates: readonly TrackState[], options?: ExportOptions) => Promise<ExportResult>;
|
|
215
144
|
/** Whether export is in progress */
|
|
216
145
|
isExporting: boolean;
|
|
217
146
|
/** Export progress (0-1) */
|
|
@@ -232,21 +161,27 @@ interface TrackState {
|
|
|
232
161
|
*/
|
|
233
162
|
declare function useExportWav(): UseExportWavReturn;
|
|
234
163
|
|
|
235
|
-
interface ActiveEffect {
|
|
236
|
-
instanceId: string;
|
|
237
|
-
effectId: string;
|
|
238
|
-
/** 'native' = built-in Tone effect; 'wam' = hosted WAM plugin. */
|
|
239
|
-
kind: 'native' | 'wam';
|
|
240
|
-
/** Module URL for wam entries. */
|
|
241
|
-
url?: string;
|
|
242
|
-
definition: EffectDefinition;
|
|
243
|
-
params: Record<string, number | string | boolean>;
|
|
244
|
-
bypassed: boolean;
|
|
245
|
-
}
|
|
246
164
|
interface UseDynamicEffectsReturn {
|
|
247
|
-
|
|
165
|
+
/**
|
|
166
|
+
* The master chain, in order. Read it with `useActiveEffects(effects)` in
|
|
167
|
+
* the component that draws the rack: this hook does not re-render when the
|
|
168
|
+
* list changes, so a slider step re-renders that component only.
|
|
169
|
+
*/
|
|
170
|
+
effects: ValueSource<ActiveEffect[]>;
|
|
171
|
+
/**
|
|
172
|
+
* The effects that can be added: the built-ins, then (in native-context
|
|
173
|
+
* mode) every type registered with `registerEffect()`. Read when the calling
|
|
174
|
+
* component renders, so register custom effects before it does.
|
|
175
|
+
*/
|
|
248
176
|
availableEffects: EffectDefinition[];
|
|
249
|
-
|
|
177
|
+
/**
|
|
178
|
+
* Adds a built-in effect or a registered custom effect by id. A built-in is
|
|
179
|
+
* in the chain before this returns. A registered type is added once its
|
|
180
|
+
* `prepare` hook has run on the audio context, and requires native-context
|
|
181
|
+
* mode (`configureGlobalContext({ nativeAudioContext: true })`).
|
|
182
|
+
* Resolves with the new entry's instanceId; rejects for an unknown id.
|
|
183
|
+
*/
|
|
184
|
+
addEffect: (effectId: string) => Promise<string>;
|
|
250
185
|
/**
|
|
251
186
|
* Hosts a WAM plugin from a module URL and appends it to the master chain.
|
|
252
187
|
* Requires native-context mode — call configureGlobalContext({ nativeAudioContext: true })
|
|
@@ -258,112 +193,101 @@ interface UseDynamicEffectsReturn {
|
|
|
258
193
|
/** Live plugin handle for a hosted WAM entry (for GUI mounting via WamEffectGui). */
|
|
259
194
|
getWamPlugin: (instanceId: string) => WamPluginInstance | undefined;
|
|
260
195
|
removeEffect: (instanceId: string) => void;
|
|
261
|
-
updateParameter: (instanceId: string, paramName: string, value:
|
|
196
|
+
updateParameter: (instanceId: string, paramName: string, value: EffectParameterValue) => void;
|
|
262
197
|
toggleBypass: (instanceId: string) => void;
|
|
263
198
|
reorderEffects: (fromIndex: number, toIndex: number) => void;
|
|
264
199
|
clearAllEffects: () => void;
|
|
265
200
|
masterEffects: EffectsFunction;
|
|
266
201
|
/**
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
*
|
|
202
|
+
* Returns the effects function for offline rendering (the same function on
|
|
203
|
+
* every call). It rebuilds the chain as it is when the export runs:
|
|
204
|
+
* built-in effects are re-created on the offline context, WAM entries
|
|
205
|
+
* re-instantiated with the live instance's state, registered custom effects
|
|
206
|
+
* prepared and created there; with no active effect it passes the audio
|
|
207
|
+
* straight through. It is async and may reject — a WAV export never
|
|
271
208
|
* silently renders without an effect the live chain has.
|
|
272
209
|
*/
|
|
273
|
-
createOfflineEffectsFunction: () => OfflineEffectsFunction
|
|
210
|
+
createOfflineEffectsFunction: () => OfflineEffectsFunction;
|
|
274
211
|
analyserRef: React.RefObject<Analyser | null>;
|
|
275
212
|
}
|
|
276
213
|
/**
|
|
277
|
-
* Hook for managing a dynamic chain of audio effects with real-time parameter
|
|
214
|
+
* Hook for managing a dynamic chain of audio effects with real-time parameter
|
|
215
|
+
* updates. Everything it returns keeps its identity for the life of the
|
|
216
|
+
* component (`masterEffects` follows `fftSize`; `availableEffects` is read from the
|
|
217
|
+
* registry on each render of the caller).
|
|
278
218
|
*/
|
|
279
219
|
declare function useDynamicEffects(fftSize?: number): UseDynamicEffectsReturn;
|
|
280
220
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
effectId: string;
|
|
284
|
-
/** 'native' = built-in Tone effect; 'wam' = hosted WAM plugin. */
|
|
285
|
-
kind: 'native' | 'wam';
|
|
286
|
-
/** Module URL for wam entries. */
|
|
287
|
-
url?: string;
|
|
288
|
-
definition: EffectDefinition;
|
|
289
|
-
params: Record<string, number | string | boolean>;
|
|
290
|
-
bypassed: boolean;
|
|
291
|
-
}
|
|
292
|
-
interface TrackEffectsState {
|
|
293
|
-
trackId: string;
|
|
294
|
-
activeEffects: TrackActiveEffect[];
|
|
295
|
-
}
|
|
221
|
+
/** An entry of a track's chain. The same shape as a master-chain entry. */
|
|
222
|
+
type TrackActiveEffect = ActiveEffect;
|
|
296
223
|
interface UseTrackDynamicEffectsReturn {
|
|
297
|
-
trackEffectsState: Map<string, TrackActiveEffect[]>;
|
|
298
|
-
addEffectToTrack: (trackId: string, effectId: string) => void;
|
|
299
224
|
/**
|
|
300
|
-
*
|
|
225
|
+
* One track's chain, in order. The same source is returned for the same
|
|
226
|
+
* track id. Read it with `useActiveEffects(getTrackEffects(trackId))` in
|
|
227
|
+
* the component that draws that track's effects: this hook does not
|
|
228
|
+
* re-render when a chain changes.
|
|
229
|
+
*/
|
|
230
|
+
getTrackEffects: (trackId: string) => ValueSource<TrackActiveEffect[]>;
|
|
231
|
+
/**
|
|
232
|
+
* Adds a built-in effect or a registered custom effect to a track by id. A
|
|
233
|
+
* built-in is in the chain before this returns. A registered type is added
|
|
234
|
+
* once its `prepare` hook has run on the audio context, and requires
|
|
235
|
+
* native-context mode. Resolves with the new entry's instanceId; rejects
|
|
236
|
+
* for an unknown id.
|
|
237
|
+
*/
|
|
238
|
+
addEffectToTrack: (trackId: string, effectId: string) => Promise<string>;
|
|
239
|
+
/**
|
|
240
|
+
* Hosts a WAM plugin from a module URL and appends it to a track's chain.
|
|
301
241
|
* Requires native-context mode — call configureGlobalContext({ nativeAudioContext: true })
|
|
302
242
|
* from @waveform-playlist/playout before any audio initialization.
|
|
303
243
|
* WAM entries render in offline WAV export (re-instantiated on the offline context).
|
|
304
244
|
* Resolves with the new entry's instanceId.
|
|
305
245
|
*/
|
|
306
246
|
addWamEffectToTrack: (trackId: string, url: string, initialState?: unknown) => Promise<string>;
|
|
307
|
-
/** Live plugin handle for a hosted WAM entry
|
|
247
|
+
/** Live plugin handle for a hosted WAM entry (for GUI mounting via WamEffectGui). */
|
|
308
248
|
getTrackWamPlugin: (trackId: string, instanceId: string) => WamPluginInstance | undefined;
|
|
309
249
|
removeEffectFromTrack: (trackId: string, instanceId: string) => void;
|
|
310
|
-
updateTrackEffectParameter: (trackId: string, instanceId: string, paramName: string, value:
|
|
250
|
+
updateTrackEffectParameter: (trackId: string, instanceId: string, paramName: string, value: EffectParameterValue) => void;
|
|
311
251
|
toggleBypass: (trackId: string, instanceId: string) => void;
|
|
252
|
+
reorderTrackEffects: (trackId: string, fromIndex: number, toIndex: number) => void;
|
|
312
253
|
clearTrackEffects: (trackId: string) => void;
|
|
313
|
-
getTrackEffectsFunction: (trackId: string) => TrackEffectsFunction$1 | undefined;
|
|
314
254
|
/**
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
|
|
255
|
+
* The effects function of a track. The same function is returned for the
|
|
256
|
+
* same track id. Pass this function itself to the provider:
|
|
257
|
+
* `<WaveformPlaylistProvider trackEffects={getTrackEffectsFunction}>`.
|
|
258
|
+
*/
|
|
259
|
+
getTrackEffectsFunction: (trackId: string) => TrackEffectsFunction;
|
|
260
|
+
/**
|
|
261
|
+
* Returns a track's effects function for offline rendering (the same
|
|
262
|
+
* function for the same track id). It rebuilds the chain as it is when the
|
|
263
|
+
* export runs; with no active effect it passes the audio straight through.
|
|
264
|
+
* It is async and may reject — a WAV export never silently renders without
|
|
265
|
+
* an effect the live chain has.
|
|
266
|
+
*/
|
|
267
|
+
createOfflineTrackEffectsFunction: (trackId: string) => OfflineTrackEffectsFunction;
|
|
268
|
+
/**
|
|
269
|
+
* The effects that can be added: the built-ins, then (in native-context
|
|
270
|
+
* mode) every type registered with `registerEffect()`. Read when the calling
|
|
271
|
+
* component renders, so register custom effects before it does.
|
|
319
272
|
*/
|
|
320
|
-
createOfflineTrackEffectsFunction: (trackId: string) => OfflineTrackEffectsFunction | undefined;
|
|
321
273
|
availableEffects: EffectDefinition[];
|
|
322
274
|
}
|
|
323
275
|
/**
|
|
324
|
-
* Hook for managing
|
|
276
|
+
* Hook for managing effects per track. Each track has its own chain.
|
|
277
|
+
* Everything it returns keeps its identity for the life of the component
|
|
278
|
+
* (`availableEffects` is read from the registry on each render of the caller).
|
|
325
279
|
*/
|
|
326
280
|
declare function useTrackDynamicEffects(): UseTrackDynamicEffectsReturn;
|
|
327
281
|
|
|
328
282
|
/**
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
283
|
+
* The effects of one chain, as React state: `effects` from
|
|
284
|
+
* `useDynamicEffects()`, or `getTrackEffects(trackId)` from
|
|
285
|
+
* `useTrackDynamicEffects()`. The calling component re-renders when that
|
|
286
|
+
* chain changes (an effect added, removed, moved, bypassed, or a parameter
|
|
287
|
+
* set), so call it in the component that draws the chain, not at the root of
|
|
288
|
+
* the page.
|
|
335
289
|
*/
|
|
336
|
-
|
|
337
|
-
/** A source that can be decoded into a track. */
|
|
338
|
-
type TrackSource = File | Blob | string | {
|
|
339
|
-
src: string;
|
|
340
|
-
name?: string;
|
|
341
|
-
};
|
|
342
|
-
/** Info about a track that failed to load. */
|
|
343
|
-
interface TrackLoadError {
|
|
344
|
-
/** Display name of the source that failed. */
|
|
345
|
-
name: string;
|
|
346
|
-
/** The underlying error. */
|
|
347
|
-
error: Error;
|
|
348
|
-
}
|
|
349
|
-
interface UseDynamicTracksReturn {
|
|
350
|
-
/**
|
|
351
|
-
* Current tracks array (placeholders + loaded). Pass to WaveformPlaylistProvider.
|
|
352
|
-
* Placeholder tracks have `clips: []` and names ending with " (loading...)".
|
|
353
|
-
*/
|
|
354
|
-
tracks: ClipTrack[];
|
|
355
|
-
/** Add one or more sources — creates placeholder tracks immediately. */
|
|
356
|
-
addTracks: (sources: TrackSource[]) => void;
|
|
357
|
-
/** Remove a track by its id. Aborts in-flight fetch/decode if still loading. */
|
|
358
|
-
removeTrack: (trackId: string) => void;
|
|
359
|
-
/** Number of sources currently decoding. */
|
|
360
|
-
loadingCount: number;
|
|
361
|
-
/** True when any source is still decoding. */
|
|
362
|
-
isLoading: boolean;
|
|
363
|
-
/** Tracks that failed to load (removed from `tracks` automatically). */
|
|
364
|
-
errors: TrackLoadError[];
|
|
365
|
-
}
|
|
366
|
-
declare function useDynamicTracks(): UseDynamicTracksReturn;
|
|
290
|
+
declare function useActiveEffects(effects: ValueSource<ActiveEffect[]>): ActiveEffect[];
|
|
367
291
|
|
|
368
292
|
/**
|
|
369
293
|
* Hook for monitoring master output levels
|
|
@@ -377,6 +301,7 @@ declare function useDynamicTracks(): UseDynamicTracksReturn;
|
|
|
377
301
|
* getContext()/getDestination() return the DEFAULT context, which is
|
|
378
302
|
* replaced when getGlobalContext() calls setContext() on first audio init.
|
|
379
303
|
*/
|
|
304
|
+
|
|
380
305
|
interface UseOutputMeterOptions {
|
|
381
306
|
/**
|
|
382
307
|
* Number of channels to meter.
|
|
@@ -393,18 +318,19 @@ interface UseOutputMeterOptions {
|
|
|
393
318
|
* all levels (current, peak, RMS) and smoothed state are reset to zero.
|
|
394
319
|
* Without this, the browser's tail-time optimization stops calling the
|
|
395
320
|
* worklet's process() when no audio flows, leaving the last non-zero
|
|
396
|
-
* levels frozen
|
|
321
|
+
* levels frozen.
|
|
397
322
|
* Default: false
|
|
398
323
|
*/
|
|
399
324
|
isPlaying?: boolean;
|
|
400
325
|
}
|
|
401
326
|
interface UseOutputMeterReturn {
|
|
402
|
-
/**
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
327
|
+
/**
|
|
328
|
+
* The live output levels, one entry per channel. Its identity is stable for
|
|
329
|
+
* the life of the hook, and the hook does NOT re-render when levels change:
|
|
330
|
+
* pass it to `<SegmentedVUMeter meter={meter} />`, call `meter.subscribe()`,
|
|
331
|
+
* or use `useMeterLevels(meter)` for throttled React state.
|
|
332
|
+
*/
|
|
333
|
+
meter: MeterSource;
|
|
408
334
|
/** Reset all held peak levels to 0 */
|
|
409
335
|
resetPeak: () => void;
|
|
410
336
|
/** Error from meter setup (worklet load failure, context issues, etc.) */
|
|
@@ -417,7 +343,11 @@ declare function useOutputMeter(options?: UseOutputMeterOptions): UseOutputMeter
|
|
|
417
343
|
*/
|
|
418
344
|
|
|
419
345
|
interface EffectInstance {
|
|
420
|
-
|
|
346
|
+
/** Where the chain connects into the effect. */
|
|
347
|
+
input: ToneAudioNode | AudioNode;
|
|
348
|
+
/** Where the chain continues from. The same node as `input` for a Tone.js
|
|
349
|
+
* effect or a WAM plugin; a registered custom effect may have two. */
|
|
350
|
+
output: ToneAudioNode | AudioNode;
|
|
421
351
|
id: string;
|
|
422
352
|
instanceId: string;
|
|
423
353
|
dispose: () => void;
|
|
@@ -439,6 +369,28 @@ declare function createEffectChain(effects: EffectInstance[]): {
|
|
|
439
369
|
dispose: () => void;
|
|
440
370
|
};
|
|
441
371
|
|
|
372
|
+
interface CustomEffectInstance extends EffectInstance {
|
|
373
|
+
kind: 'custom';
|
|
374
|
+
/** What the registered definition's `create` returned. */
|
|
375
|
+
native: NativeEffectInstance;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* The effects to offer in a picker: the built-in Tone.js effects, followed by
|
|
379
|
+
* the custom effects the app registered when it is in native-context mode (a
|
|
380
|
+
* registered effect cannot be added without it). Another host library's own
|
|
381
|
+
* catalogue in the shared registry (`builtIn` definitions: dawcore's
|
|
382
|
+
* `native-*`, present when `@dawcore/components` is loaded too) is left out;
|
|
383
|
+
* those can still be added by id. Returns the same array until
|
|
384
|
+
* that set changes, so it is safe to read during render. It is a read, not a
|
|
385
|
+
* subscription: a type registered later appears the next time this is called.
|
|
386
|
+
*/
|
|
387
|
+
declare function getAvailableEffects(): EffectDefinition[];
|
|
388
|
+
/**
|
|
389
|
+
* Create a registered effect on `audioContext`. The type's `prepare` hook
|
|
390
|
+
* must already have run on that context (`ensureEffectPrepared`).
|
|
391
|
+
*/
|
|
392
|
+
declare function createCustomEffectInstance(type: string, audioContext: BaseAudioContext, params?: Record<string, number | string | boolean>): CustomEffectInstance;
|
|
393
|
+
|
|
442
394
|
interface ExportWavButtonProps {
|
|
443
395
|
/** Button label */
|
|
444
396
|
label?: string;
|
|
@@ -469,7 +421,7 @@ interface ExportWavButtonProps {
|
|
|
469
421
|
/** Callback when export fails */
|
|
470
422
|
onExportError?: (error: Error) => void;
|
|
471
423
|
}
|
|
472
|
-
declare const ExportWavButton:
|
|
424
|
+
declare const ExportWavButton: react__default.FC<ExportWavButtonProps>;
|
|
473
425
|
|
|
474
426
|
interface WamEffectGuiProps {
|
|
475
427
|
/** Live plugin handle from getWamPlugin/getTrackWamPlugin. */
|
|
@@ -482,7 +434,7 @@ interface WamEffectGuiProps {
|
|
|
482
434
|
* destroyed on unmount — GUI and audio lifecycles are independent, so this
|
|
483
435
|
* never interrupts sound.
|
|
484
436
|
*/
|
|
485
|
-
declare const WamEffectGui:
|
|
437
|
+
declare const WamEffectGui: react__default.FC<WamEffectGuiProps>;
|
|
486
438
|
|
|
487
439
|
/**
|
|
488
440
|
* Dynamic loader for the optional '@dawcore/wam' peer (the @dawcore/midi
|
|
@@ -500,4 +452,4 @@ interface WamEffectInstance extends EffectInstance {
|
|
|
500
452
|
}
|
|
501
453
|
declare function createWamEffectInstance(plugin: WamPluginInstance): WamEffectInstance;
|
|
502
454
|
|
|
503
|
-
export { type ActiveEffect, type
|
|
455
|
+
export { type ActiveEffect, type BuiltInEffectCategory, type CustomEffectInstance, type EffectCategory, type EffectDefinition, type EffectInstance, type EffectParameter, type EffectParameterValue, type ExportOptions, type ExportResult, ExportWavButton, type ExportWavButtonProps, type OfflineEffectsCleanup, type OfflineEffectsFunction, type OfflineTrackEffectsFunction, type ParameterType, type TrackActiveEffect, type UseDynamicEffectsReturn, type UseExportWavReturn, type UseOutputMeterOptions, type UseOutputMeterReturn, type UseTrackDynamicEffectsReturn, WamEffectGui, type WamEffectGuiProps, type WamEffectInstance, createCustomEffectInstance, createEffectChain, createEffectInstance, createWamEffectInstance, effectCategories, effectDefinitions, getAvailableEffects, getEffectDefinition, getEffectsByCategory, loadWamModule, useActiveEffects, useDynamicEffects, useExportWav, useMasterAnalyser, useOutputMeter, useTrackDynamicEffects };
|