@waveform-playlist/browser 5.0.0-alpha.8 → 5.0.0-alpha.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.ts +65 -11
- package/dist/index.js +88 -88
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2803 -2721
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -64,18 +64,37 @@ declare interface AnnotationData {
|
|
|
64
64
|
* IMPORTANT: All positions/durations are stored as SAMPLE COUNTS (integers)
|
|
65
65
|
* to avoid floating-point precision errors. Convert to seconds only when
|
|
66
66
|
* needed for playback using: seconds = samples / sampleRate
|
|
67
|
+
*
|
|
68
|
+
* Clips can be created with just waveformData (for instant visual rendering)
|
|
69
|
+
* and have audioBuffer added later when audio finishes loading.
|
|
67
70
|
*/
|
|
68
71
|
export declare interface AudioClip {
|
|
69
72
|
/** Unique identifier for this clip */
|
|
70
73
|
id: string;
|
|
71
|
-
/**
|
|
72
|
-
|
|
74
|
+
/**
|
|
75
|
+
* The audio buffer containing the audio data.
|
|
76
|
+
* Optional for peaks-first rendering - can be added later.
|
|
77
|
+
* Required for playback and editing operations.
|
|
78
|
+
*/
|
|
79
|
+
audioBuffer?: AudioBuffer;
|
|
73
80
|
/** Position on timeline where this clip starts (in samples at timeline sampleRate) */
|
|
74
81
|
startSample: number;
|
|
75
82
|
/** Duration of this clip (in samples) - how much of the audio buffer to play */
|
|
76
83
|
durationSamples: number;
|
|
77
84
|
/** Offset into the audio buffer where playback starts (in samples) - the "trim start" point */
|
|
78
85
|
offsetSamples: number;
|
|
86
|
+
/**
|
|
87
|
+
* Sample rate for this clip's audio.
|
|
88
|
+
* Required when audioBuffer is not provided (for peaks-first rendering).
|
|
89
|
+
* When audioBuffer is present, this should match audioBuffer.sampleRate.
|
|
90
|
+
*/
|
|
91
|
+
sampleRate: number;
|
|
92
|
+
/**
|
|
93
|
+
* Total duration of the source audio in samples.
|
|
94
|
+
* Required when audioBuffer is not provided (for trim bounds calculation).
|
|
95
|
+
* When audioBuffer is present, this should equal audioBuffer.length.
|
|
96
|
+
*/
|
|
97
|
+
sourceDurationSamples: number;
|
|
79
98
|
/** Optional fade in effect */
|
|
80
99
|
fadeIn?: Fade;
|
|
81
100
|
/** Optional fade out effect */
|
|
@@ -106,9 +125,20 @@ export declare const AudioPosition: default_2.FC<{
|
|
|
106
125
|
|
|
107
126
|
/**
|
|
108
127
|
* Configuration for a single audio track to load
|
|
128
|
+
*
|
|
129
|
+
* Audio can be provided in three ways:
|
|
130
|
+
* 1. `src` - URL to fetch and decode (standard loading)
|
|
131
|
+
* 2. `audioBuffer` - Pre-loaded AudioBuffer (skip fetch/decode)
|
|
132
|
+
* 3. `waveformData` only - Peaks-first rendering (audio loads later)
|
|
133
|
+
*
|
|
134
|
+
* For peaks-first rendering, just provide `waveformData` - the sample rate
|
|
135
|
+
* and duration are derived from the waveform data automatically.
|
|
109
136
|
*/
|
|
110
137
|
export declare interface AudioTrackConfig {
|
|
111
|
-
|
|
138
|
+
/** URL to audio file - used if audioBuffer not provided */
|
|
139
|
+
src?: string;
|
|
140
|
+
/** Pre-loaded AudioBuffer - skips fetch/decode if provided */
|
|
141
|
+
audioBuffer?: AudioBuffer;
|
|
112
142
|
name?: string;
|
|
113
143
|
muted?: boolean;
|
|
114
144
|
soloed?: boolean;
|
|
@@ -968,7 +998,8 @@ declare interface UseAnnotationKeyboardControlsOptions {
|
|
|
968
998
|
* with a single clip per track. Supports custom positioning for multi-clip arrangements.
|
|
969
999
|
*
|
|
970
1000
|
* @param configs - Array of audio track configurations
|
|
971
|
-
* @
|
|
1001
|
+
* @param options - Optional configuration for loading behavior
|
|
1002
|
+
* @returns Object with tracks array, loading state, and progress info
|
|
972
1003
|
*
|
|
973
1004
|
* @example
|
|
974
1005
|
* ```typescript
|
|
@@ -978,25 +1009,48 @@ declare interface UseAnnotationKeyboardControlsOptions {
|
|
|
978
1009
|
* { src: 'audio/drums.mp3', name: 'Drums' },
|
|
979
1010
|
* ]);
|
|
980
1011
|
*
|
|
981
|
-
* //
|
|
982
|
-
* const { tracks, loading,
|
|
983
|
-
* { src: 'audio/
|
|
984
|
-
* {
|
|
985
|
-
*
|
|
1012
|
+
* // Progressive loading (tracks appear as they load)
|
|
1013
|
+
* const { tracks, loading, loadedCount, totalCount } = useAudioTracks(
|
|
1014
|
+
* [{ src: 'audio/vocals.mp3' }, { src: 'audio/drums.mp3' }],
|
|
1015
|
+
* { progressive: true }
|
|
1016
|
+
* );
|
|
1017
|
+
*
|
|
1018
|
+
* // Pre-loaded AudioBuffer (skip fetch/decode)
|
|
1019
|
+
* const { tracks } = useAudioTracks([
|
|
1020
|
+
* { audioBuffer: myPreloadedBuffer, name: 'Pre-loaded' },
|
|
986
1021
|
* ]);
|
|
987
1022
|
*
|
|
988
|
-
*
|
|
1023
|
+
* // Peaks-first rendering (instant visual, audio loads later)
|
|
1024
|
+
* const { tracks } = useAudioTracks([
|
|
1025
|
+
* { waveformData: preloadedPeaks, name: 'Peaks Only' }, // Renders immediately
|
|
1026
|
+
* ]);
|
|
1027
|
+
*
|
|
1028
|
+
* if (loading) return <div>Loading {loadedCount}/{totalCount}...</div>;
|
|
989
1029
|
* if (error) return <div>Error: {error}</div>;
|
|
990
1030
|
*
|
|
991
1031
|
* return <WaveformPlaylistProvider tracks={tracks}>...</WaveformPlaylistProvider>;
|
|
992
1032
|
* ```
|
|
993
1033
|
*/
|
|
994
|
-
export declare function useAudioTracks(configs: AudioTrackConfig[]): {
|
|
1034
|
+
export declare function useAudioTracks(configs: AudioTrackConfig[], options?: UseAudioTracksOptions): {
|
|
995
1035
|
tracks: ClipTrack[];
|
|
996
1036
|
loading: boolean;
|
|
997
1037
|
error: string | null;
|
|
1038
|
+
loadedCount: number;
|
|
1039
|
+
totalCount: number;
|
|
998
1040
|
};
|
|
999
1041
|
|
|
1042
|
+
/**
|
|
1043
|
+
* Options for useAudioTracks hook
|
|
1044
|
+
*/
|
|
1045
|
+
declare interface UseAudioTracksOptions {
|
|
1046
|
+
/**
|
|
1047
|
+
* When true, tracks are added to the playlist progressively as they load,
|
|
1048
|
+
* rather than waiting for all tracks to finish loading.
|
|
1049
|
+
* Default: false (wait for all tracks)
|
|
1050
|
+
*/
|
|
1051
|
+
progressive?: boolean;
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1000
1054
|
/**
|
|
1001
1055
|
* Custom hook for handling clip drag operations (movement and trimming)
|
|
1002
1056
|
*
|