@waveform-playlist/browser 5.2.0 → 5.3.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.ts +149 -0
- package/dist/index.js +179 -145
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3191 -2584
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { Fade as Fade_2 } from '@waveform-playlist/core';
|
|
|
6
6
|
import { Gain } from 'tone';
|
|
7
7
|
import { MediaElementPlayout } from '@waveform-playlist/media-element-playout';
|
|
8
8
|
import { MutableRefObject } from 'react';
|
|
9
|
+
import { Provider } from 'react';
|
|
9
10
|
import react__default from 'react';
|
|
10
11
|
import { ReactNode } from 'react';
|
|
11
12
|
import { RefObject } from 'react';
|
|
@@ -166,6 +167,12 @@ export declare interface AudioTrackConfig {
|
|
|
166
167
|
fadeIn?: Fade;
|
|
167
168
|
fadeOut?: Fade;
|
|
168
169
|
waveformData?: WaveformDataObject;
|
|
170
|
+
/** Visualization render mode: 'waveform' | 'spectrogram' | 'both'. Default: 'waveform' */
|
|
171
|
+
renderMode?: RenderMode;
|
|
172
|
+
/** Spectrogram configuration (FFT size, window, frequency scale, etc.) */
|
|
173
|
+
spectrogramConfig?: SpectrogramConfig;
|
|
174
|
+
/** Spectrogram color map name or custom color array */
|
|
175
|
+
spectrogramColorMap?: ColorMapValue;
|
|
169
176
|
}
|
|
170
177
|
|
|
171
178
|
/**
|
|
@@ -225,8 +232,23 @@ export declare interface ClipTrack {
|
|
|
225
232
|
height?: number;
|
|
226
233
|
/** Optional effects function for this track */
|
|
227
234
|
effects?: TrackEffectsFunction_2;
|
|
235
|
+
/** Visualization render mode. Default: 'waveform' */
|
|
236
|
+
renderMode?: RenderMode;
|
|
237
|
+
/** Per-track spectrogram configuration (FFT size, window, frequency scale, etc.) */
|
|
238
|
+
spectrogramConfig?: SpectrogramConfig;
|
|
239
|
+
/** Per-track spectrogram color map name or custom color array */
|
|
240
|
+
spectrogramColorMap?: ColorMapValue;
|
|
228
241
|
}
|
|
229
242
|
|
|
243
|
+
/** A single color map entry: [r, g, b] or [r, g, b, a] */
|
|
244
|
+
declare type ColorMapEntry = [number, number, number] | [number, number, number, number];
|
|
245
|
+
|
|
246
|
+
/** Built-in color map names */
|
|
247
|
+
declare type ColorMapName = 'viridis' | 'magma' | 'inferno' | 'grayscale' | 'igray' | 'roseus';
|
|
248
|
+
|
|
249
|
+
/** Color map can be a named preset or a custom array of [r, g, b, a?] entries */
|
|
250
|
+
declare type ColorMapValue = ColorMapName | ColorMapEntry[];
|
|
251
|
+
|
|
230
252
|
/**
|
|
231
253
|
* Continuous play checkbox that uses the playlist context
|
|
232
254
|
* Uses split contexts to avoid re-rendering during animation
|
|
@@ -424,6 +446,14 @@ export declare const FastForwardButton: default_2.FC<{
|
|
|
424
446
|
className?: string;
|
|
425
447
|
}>;
|
|
426
448
|
|
|
449
|
+
/**
|
|
450
|
+
* Spectrogram Types
|
|
451
|
+
*
|
|
452
|
+
* Types for frequency-domain visualization of audio data.
|
|
453
|
+
*/
|
|
454
|
+
/** Valid FFT sizes (must be power of 2, 256–8192) */
|
|
455
|
+
declare type FFTSize = 256 | 512 | 1024 | 2048 | 4096 | 8192;
|
|
456
|
+
|
|
427
457
|
/**
|
|
428
458
|
* Custom function to generate the label shown on annotation boxes in the waveform.
|
|
429
459
|
* Receives the annotation data and its index in the list, returns a string label.
|
|
@@ -949,6 +979,8 @@ declare interface PlaylistDataContextValue {
|
|
|
949
979
|
progressBarWidth: number;
|
|
950
980
|
/** Whether the playlist has finished loading all tracks */
|
|
951
981
|
isReady: boolean;
|
|
982
|
+
/** Whether tracks are rendered in mono mode */
|
|
983
|
+
mono: boolean;
|
|
952
984
|
}
|
|
953
985
|
|
|
954
986
|
declare interface PlaylistStateContextValue {
|
|
@@ -1000,6 +1032,8 @@ export declare interface PlaylistVisualizationProps {
|
|
|
1000
1032
|
* Use with useDragSensors({ touchOptimized: true }) for best results.
|
|
1001
1033
|
*/
|
|
1002
1034
|
touchOptimized?: boolean;
|
|
1035
|
+
/** Callback when a track's close button is clicked. Only renders close button when provided. */
|
|
1036
|
+
onRemoveTrack?: (trackIndex: number) => void;
|
|
1003
1037
|
recordingState?: {
|
|
1004
1038
|
isRecording: boolean;
|
|
1005
1039
|
trackId: string;
|
|
@@ -1020,6 +1054,9 @@ export declare interface RenderAnnotationItemProps {
|
|
|
1020
1054
|
formatTime: (seconds: number) => string;
|
|
1021
1055
|
}
|
|
1022
1056
|
|
|
1057
|
+
/** Render mode for a track's visualization */
|
|
1058
|
+
declare type RenderMode = 'waveform' | 'spectrogram' | 'both';
|
|
1059
|
+
|
|
1023
1060
|
/**
|
|
1024
1061
|
* Type for custom playhead render functions.
|
|
1025
1062
|
* Receives position, color, and animation refs for smooth 60fps animation.
|
|
@@ -1052,6 +1089,101 @@ export declare const SkipForwardButton: default_2.FC<{
|
|
|
1052
1089
|
className?: string;
|
|
1053
1090
|
}>;
|
|
1054
1091
|
|
|
1092
|
+
/**
|
|
1093
|
+
* Configuration for spectrogram computation and rendering.
|
|
1094
|
+
*/
|
|
1095
|
+
declare interface SpectrogramConfig {
|
|
1096
|
+
/** FFT size: 256–8192, must be power of 2. Default: 2048 */
|
|
1097
|
+
fftSize?: FFTSize;
|
|
1098
|
+
/** Hop size between frames in samples. Default: fftSize / 4 */
|
|
1099
|
+
hopSize?: number;
|
|
1100
|
+
/** Window function applied before FFT. Default: 'hann' */
|
|
1101
|
+
windowFunction?: 'hann' | 'hamming' | 'blackman' | 'rectangular' | 'bartlett' | 'blackman-harris';
|
|
1102
|
+
/** Window function parameter (0-1), used by some window functions */
|
|
1103
|
+
alpha?: number;
|
|
1104
|
+
/** Frequency axis scale. Default: 'mel' */
|
|
1105
|
+
frequencyScale?: 'linear' | 'logarithmic' | 'mel' | 'bark' | 'erb';
|
|
1106
|
+
/** Minimum frequency in Hz. Default: 0 */
|
|
1107
|
+
minFrequency?: number;
|
|
1108
|
+
/** Maximum frequency in Hz. Default: sampleRate / 2 */
|
|
1109
|
+
maxFrequency?: number;
|
|
1110
|
+
/** Display brightness boost in dB. Default: 20 */
|
|
1111
|
+
gainDb?: number;
|
|
1112
|
+
/** Signal range in dB. Default: 80 */
|
|
1113
|
+
rangeDb?: number;
|
|
1114
|
+
/** Zero padding factor: actual FFT length = fftSize * zeroPaddingFactor. Default: 2 */
|
|
1115
|
+
zeroPaddingFactor?: number;
|
|
1116
|
+
/** Show frequency axis labels. Default: false */
|
|
1117
|
+
labels?: boolean;
|
|
1118
|
+
/** Label text color */
|
|
1119
|
+
labelsColor?: string;
|
|
1120
|
+
/** Label background color */
|
|
1121
|
+
labelsBackground?: string;
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
/**
|
|
1125
|
+
* Computed spectrogram data ready for rendering.
|
|
1126
|
+
*/
|
|
1127
|
+
declare interface SpectrogramData {
|
|
1128
|
+
/** Actual FFT length used for computation (includes zero padding) */
|
|
1129
|
+
fftSize: number;
|
|
1130
|
+
/** Original analysis window size before zero padding */
|
|
1131
|
+
windowSize: number;
|
|
1132
|
+
/** Number of frequency bins (fftSize / 2) */
|
|
1133
|
+
frequencyBinCount: number;
|
|
1134
|
+
/** Sample rate of the source audio */
|
|
1135
|
+
sampleRate: number;
|
|
1136
|
+
/** Hop size between FFT frames (in samples) */
|
|
1137
|
+
hopSize: number;
|
|
1138
|
+
/** Number of time frames */
|
|
1139
|
+
frameCount: number;
|
|
1140
|
+
/** dB values: frameCount * frequencyBinCount Float32Array (row-major, frame × bin) */
|
|
1141
|
+
data: Float32Array;
|
|
1142
|
+
/** Display brightness boost in dB */
|
|
1143
|
+
gainDb: number;
|
|
1144
|
+
/** Signal range in dB */
|
|
1145
|
+
rangeDb: number;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
export declare interface SpectrogramIntegration {
|
|
1149
|
+
spectrogramDataMap: Map<string, SpectrogramData[]>;
|
|
1150
|
+
trackSpectrogramOverrides: Map<string, TrackSpectrogramOverrides>;
|
|
1151
|
+
spectrogramWorkerApi: SpectrogramWorkerApi | null;
|
|
1152
|
+
spectrogramConfig?: SpectrogramConfig;
|
|
1153
|
+
spectrogramColorMap?: ColorMapValue;
|
|
1154
|
+
setTrackRenderMode: (trackId: string, mode: RenderMode) => void;
|
|
1155
|
+
setTrackSpectrogramConfig: (trackId: string, config: SpectrogramConfig, colorMap?: ColorMapValue) => void;
|
|
1156
|
+
registerSpectrogramCanvases: (clipId: string, channelIndex: number, canvasIds: string[], canvasWidths: number[]) => void;
|
|
1157
|
+
unregisterSpectrogramCanvases: (clipId: string, channelIndex: number) => void;
|
|
1158
|
+
/** Render spectrogram menu items for a track's context menu */
|
|
1159
|
+
renderMenuItems?: (props: {
|
|
1160
|
+
renderMode: string;
|
|
1161
|
+
onRenderModeChange: (mode: RenderMode) => void;
|
|
1162
|
+
onOpenSettings: () => void;
|
|
1163
|
+
onClose?: () => void;
|
|
1164
|
+
}) => TrackMenuItem[];
|
|
1165
|
+
/** Settings modal component provided by the spectrogram package */
|
|
1166
|
+
SettingsModal?: React.ComponentType<{
|
|
1167
|
+
open: boolean;
|
|
1168
|
+
onClose: () => void;
|
|
1169
|
+
config: SpectrogramConfig;
|
|
1170
|
+
colorMap: ColorMapValue;
|
|
1171
|
+
onApply: (config: SpectrogramConfig, colorMap: ColorMapValue) => void;
|
|
1172
|
+
}>;
|
|
1173
|
+
/** Get color lookup table for a color map name */
|
|
1174
|
+
getColorMap: (name: ColorMapValue) => Uint8Array;
|
|
1175
|
+
/** Get frequency scale function for a scale name */
|
|
1176
|
+
getFrequencyScale: (name: string) => (f: number, minF: number, maxF: number) => number;
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
export declare const SpectrogramIntegrationProvider: Provider<SpectrogramIntegration | null>;
|
|
1180
|
+
|
|
1181
|
+
/** Minimal type for the worker API surface used by browser components */
|
|
1182
|
+
declare interface SpectrogramWorkerApi {
|
|
1183
|
+
registerCanvas: (canvasId: string, canvas: OffscreenCanvas) => void;
|
|
1184
|
+
unregisterCanvas: (canvasId: string) => void;
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1055
1187
|
export declare const StopButton: default_2.FC<{
|
|
1056
1188
|
className?: string;
|
|
1057
1189
|
}>;
|
|
@@ -1205,6 +1337,19 @@ export declare interface TrackEffectsState {
|
|
|
1205
1337
|
activeEffects: TrackActiveEffect[];
|
|
1206
1338
|
}
|
|
1207
1339
|
|
|
1340
|
+
declare interface TrackMenuItem {
|
|
1341
|
+
id: string;
|
|
1342
|
+
label?: string;
|
|
1343
|
+
content: ReactNode;
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
/** Per-track overrides for spectrogram rendering (render mode, config, color map) */
|
|
1347
|
+
declare interface TrackSpectrogramOverrides {
|
|
1348
|
+
renderMode: RenderMode;
|
|
1349
|
+
config?: SpectrogramConfig;
|
|
1350
|
+
colorMap?: ColorMapValue;
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1208
1353
|
export declare interface TrackState {
|
|
1209
1354
|
name: string;
|
|
1210
1355
|
muted: boolean;
|
|
@@ -1722,6 +1867,8 @@ export declare const usePlaylistData: () => PlaylistDataContextValue;
|
|
|
1722
1867
|
|
|
1723
1868
|
export declare const usePlaylistState: () => PlaylistStateContextValue;
|
|
1724
1869
|
|
|
1870
|
+
export declare function useSpectrogramIntegration(): SpectrogramIntegration | null;
|
|
1871
|
+
|
|
1725
1872
|
/**
|
|
1726
1873
|
* Hook to manage time format state
|
|
1727
1874
|
*
|
|
@@ -2039,6 +2186,8 @@ export declare interface WaveformProps {
|
|
|
2039
2186
|
* Use with useDragSensors({ touchOptimized: true }) for best results.
|
|
2040
2187
|
*/
|
|
2041
2188
|
touchOptimized?: boolean;
|
|
2189
|
+
/** Callback when a track's close button is clicked. Only renders close button when provided. */
|
|
2190
|
+
onRemoveTrack?: (trackIndex: number) => void;
|
|
2042
2191
|
recordingState?: {
|
|
2043
2192
|
isRecording: boolean;
|
|
2044
2193
|
trackId: string;
|