Controls
TheControls interface defines the complete return type of the useVoiceVisualizer hook. This object contains all state, functions, and refs needed to control audio recording and playback.
Usage
State Properties
Recording State
isRecordingInProgress:boolean- Whether recording is currently activeisPausedRecording:boolean- Whether the active recording is pausedaudioData:Uint8Array- Real-time audio data for visualizationrecordingTime:number- Elapsed recording time in millisecondsmediaRecorder:MediaRecorder | null- The MediaRecorder instance
Playback State
duration:number- Total duration of recorded audio in secondscurrentAudioTime:number- Current playback position in secondsaudioSrc:string- URL of the recorded audio fileisPausedRecordedAudio:boolean- Whether playback is paused
Processing State
isProcessingRecordedAudio:boolean- Whether audio is being processedisCleared:boolean- Whether the canvas has been clearedisAvailableRecordedAudio:boolean- Whether recorded audio is readyisProcessingOnResize:boolean- Whether processing during resizeisProcessingStartRecording:boolean- Whether starting recordingisPreloadedBlob:boolean- Whether audio was preloaded
Data State
recordedBlob:Blob | null- Recorded audio as a BlobbufferFromRecordedBlob:AudioBuffer | null- Decoded audio buffererror:Error | null- Any error that occurred
Formatted Values
formattedDuration:string- Formatted duration (e.g., “09:51m”)formattedRecordingTime:string- Formatted recording time (e.g., “09:51”)formattedRecordedAudioCurrentTime:string- Formatted playback time (e.g., “09:51:1”)
useVoiceVisualizerParams
TheuseVoiceVisualizerParams interface defines the optional parameters accepted by the useVoiceVisualizer hook.
Usage
Callback Parameters
All callback functions are optional and allow you to react to different lifecycle events:Recording Callbacks
onStartRecording: Called when recording startsonStopRecording: Called when recording stopsonPausedRecording: Called when recording is pausedonResumedRecording: Called when recording is resumed
Playback Callbacks
onStartAudioPlayback: Called when playback startsonPausedAudioPlayback: Called when playback is pausedonResumedAudioPlayback: Called when playback resumesonEndAudioPlayback: Called when playback ends
Other Callbacks
onClearCanvas: Called when the canvas is clearedonErrorPlayingAudio: Called when audio playback encounters an error
Configuration
shouldHandleBeforeUnload: Whether to show a warning when leaving the page with unsaved recordings (default:true)
BarItem
TheBarItem interface represents a single bar in the waveform visualization.
Properties
startY:number- The Y coordinate where the bar startsbarHeight:number- The height of the bar in pixels
Usage
This interface is primarily used internally by the visualization engine. You typically won’t need to work with it directly unless you’re building custom visualization logic.BarsData
TheBarsData interface represents processed data for a single bar in the recorded audio visualization.
Properties
max:number- The maximum amplitude value for this bar
Usage
This interface is used internally when processing recorded audio for visualization. An array ofBarsData objects represents the complete waveform.
GetBarsDataParams
TheGetBarsDataParams interface defines parameters for the bars data calculation worker.
Properties
bufferData:Float32Array- Raw audio buffer dataheight:number- Canvas height in pixelswidth:number- Canvas width in pixelsbarWidth:number- Width of each bar in pixelsgap:number- Gap between bars in pixels
Usage
This type is used internally for calculating the waveform visualization from recorded audio data.DrawByLiveStreamParams
TheDrawByLiveStreamParams interface defines parameters for drawing live recording visualization.
Usage
This interface is used internally by the live recording visualization renderer. You typically won’t need to use it directly.DrawByBlob
TheDrawByBlob interface defines parameters for drawing recorded audio visualization.
Usage
This interface is used internally by the recorded audio visualization renderer. You typically won’t need to use it directly.PaintLineParams
ThePaintLineParams interface defines parameters for painting individual waveform bars.
Properties
context:CanvasRenderingContext2D- Canvas rendering contextcolor:string- Fill color for the barrounded:number | number[]- Border radius (single value or array)x:number- X coordinatey:number- Y coordinatew:number- Widthh:number- Height
Usage
This interface is used internally for rendering individual bars in the waveform.GetDataForCanvasParams
TheGetDataForCanvasParams interface defines parameters for canvas initialization.
Properties
canvas:HTMLCanvasElement- The canvas elementbackgroundColor:string- Background color to apply
Usage
This interface is used internally for canvas setup operations.UseWebWorkerParams
TheUseWebWorkerParams interface defines parameters for the web worker hook.
Properties
fn:AnyFunction- The function to run in the workerinitialValue:T- Initial value for the resultonMessageReceived:() => void- Optional callback when worker completes
Usage
This interface is used internally by the web worker system for processing audio data.AnyFunction
A utility type for generic function signatures.Usage
This type is used internally for flexible function typing.PaintLineFromCenterToRightParams
ThePaintLineFromCenterToRightParams interface defines parameters for fullscreen visualization.
Usage
This interface is used internally when rendering fullscreen mode visualizations.Type Safety Tips
Example: Fully Typed Component
See Also
- useVoiceVisualizer Hook - Hook that returns Controls
- VoiceVisualizer Component - Component that accepts Controls
- Customization Guide - Styling and customization patterns

