@waveform-playlist/browser 5.2.0-next.4 → 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 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.
@@ -588,10 +618,16 @@ export declare interface MediaElementAnnotationListProps {
588
618
  onAnnotationUpdate?: OnAnnotationUpdateFn;
589
619
  /** Whether annotation text can be edited. Defaults to false. */
590
620
  editable?: boolean;
591
- /** Whether dragging one annotation boundary also moves the adjacent annotation's boundary. Defaults to false. */
592
- linkEndpoints?: boolean;
593
- /** Override continuousPlay from context. Falls back to context value if not provided. */
594
- continuousPlay?: boolean;
621
+ /**
622
+ * Action controls to show on each annotation item (e.g., delete, split).
623
+ * Only rendered when `editable` is true.
624
+ */
625
+ controls?: AnnotationAction[];
626
+ /**
627
+ * Override annotation list config. Falls back to context values
628
+ * `{ linkEndpoints: false, continuousPlay }` if not provided.
629
+ */
630
+ annotationListConfig?: AnnotationActionOptions;
595
631
  /** Where to position the active annotation when auto-scrolling. Defaults to 'center'. */
596
632
  scrollActivePosition?: ScrollLogicalPosition;
597
633
  /** Which scrollable containers to scroll: 'nearest' or 'all'. Defaults to 'nearest'. */
@@ -943,6 +979,8 @@ declare interface PlaylistDataContextValue {
943
979
  progressBarWidth: number;
944
980
  /** Whether the playlist has finished loading all tracks */
945
981
  isReady: boolean;
982
+ /** Whether tracks are rendered in mono mode */
983
+ mono: boolean;
946
984
  }
947
985
 
948
986
  declare interface PlaylistStateContextValue {
@@ -994,6 +1032,8 @@ export declare interface PlaylistVisualizationProps {
994
1032
  * Use with useDragSensors({ touchOptimized: true }) for best results.
995
1033
  */
996
1034
  touchOptimized?: boolean;
1035
+ /** Callback when a track's close button is clicked. Only renders close button when provided. */
1036
+ onRemoveTrack?: (trackIndex: number) => void;
997
1037
  recordingState?: {
998
1038
  isRecording: boolean;
999
1039
  trackId: string;
@@ -1014,6 +1054,9 @@ export declare interface RenderAnnotationItemProps {
1014
1054
  formatTime: (seconds: number) => string;
1015
1055
  }
1016
1056
 
1057
+ /** Render mode for a track's visualization */
1058
+ declare type RenderMode = 'waveform' | 'spectrogram' | 'both';
1059
+
1017
1060
  /**
1018
1061
  * Type for custom playhead render functions.
1019
1062
  * Receives position, color, and animation refs for smooth 60fps animation.
@@ -1046,6 +1089,101 @@ export declare const SkipForwardButton: default_2.FC<{
1046
1089
  className?: string;
1047
1090
  }>;
1048
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
+
1049
1187
  export declare const StopButton: default_2.FC<{
1050
1188
  className?: string;
1051
1189
  }>;
@@ -1199,6 +1337,19 @@ export declare interface TrackEffectsState {
1199
1337
  activeEffects: TrackActiveEffect[];
1200
1338
  }
1201
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
+
1202
1353
  export declare interface TrackState {
1203
1354
  name: string;
1204
1355
  muted: boolean;
@@ -1716,6 +1867,8 @@ export declare const usePlaylistData: () => PlaylistDataContextValue;
1716
1867
 
1717
1868
  export declare const usePlaylistState: () => PlaylistStateContextValue;
1718
1869
 
1870
+ export declare function useSpectrogramIntegration(): SpectrogramIntegration | null;
1871
+
1719
1872
  /**
1720
1873
  * Hook to manage time format state
1721
1874
  *
@@ -2033,6 +2186,8 @@ export declare interface WaveformProps {
2033
2186
  * Use with useDragSensors({ touchOptimized: true }) for best results.
2034
2187
  */
2035
2188
  touchOptimized?: boolean;
2189
+ /** Callback when a track's close button is clicked. Only renders close button when provided. */
2190
+ onRemoveTrack?: (trackIndex: number) => void;
2036
2191
  recordingState?: {
2037
2192
  isRecording: boolean;
2038
2193
  trackId: string;