WaveformViewer
Waveform viewer canvas controller and peak renderer.
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new WaveformViewer( canvas: HTMLCanvasElement, viewport: IViewportController, source: AudioSource, options?: Partial<WaveformConfig>): WaveformViewer;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
canvas | HTMLCanvasElement |
viewport | IViewportController |
source | AudioSource |
options? | Partial<WaveformConfig> |
Returns
Section titled “Returns”WaveformViewer
Methods
Section titled “Methods”canvasToTime()
Section titled “canvasToTime()”canvasToTime(x: number): number;Converts canvas X pixel position to time in seconds.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
x | number |
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”destroy()
Section titled “destroy()”destroy(): void;Disposes the renderer and event listeners.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”getCanvas()
Section titled “getCanvas()”getCanvas(): HTMLCanvasElement;Returns the bound HTML canvas element.
Returns
Section titled “Returns”HTMLCanvasElement
Implementation of
Section titled “Implementation of”getConfig()
Section titled “getConfig()”getConfig(): ResolvedWaveformConfig;Returns the resolved waveform configuration options.
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”getRendererKind()
Section titled “getRendererKind()”getRendererKind(): string;Returns the active rendering engine (canvas2d, webgl2, or bars).
Returns
Section titled “Returns”string
Implementation of
Section titled “Implementation of”IWaveformViewer.getRendererKind
getSource()
Section titled “getSource()”getSource(): AudioSource;Returns the active audio source.
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”getStatus()
Section titled “getStatus()”getStatus(): WaveformStatus;Returns the current render status.
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”getViewport()
Section titled “getViewport()”getViewport(): WaveformViewport;Returns the visible time viewport.
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”getViewportController()
Section titled “getViewportController()”getViewportController(): IViewportController;Returns the bound viewport controller.
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”IWaveformViewer.getViewportController
on<Name>(name: Name, handler: (event: WaveformEvents[Name]) => void): () => void;Subscribes to waveform events.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
Name extends keyof WaveformEvents |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name | Name |
handler | (event: WaveformEvents[Name]) => void |
Returns
Section titled “Returns”() => void
Implementation of
Section titled “Implementation of”render()
Section titled “render()”render(): Promise<void>;Renders the current waveform viewport asynchronously.
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”requestRender()
Section titled “requestRender()”requestRender(): void;Schedules a render on the next animation frame.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”setConfig()
Section titled “setConfig()”setConfig(input: Partial<WaveformOptions>): void;Alias for updateConfig.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input | Partial<WaveformOptions> |
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”setSource()
Section titled “setSource()”setSource(source: AudioSource): void;Updates the audio source.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
source | AudioSource |
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”setViewport()
Section titled “setViewport()”setViewport(vp: Partial<ViewportConfig>): void;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
vp | Partial<ViewportConfig> |
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”timeToCanvas()
Section titled “timeToCanvas()”timeToCanvas(time: number): number;Converts time in seconds to canvas X pixel position.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
time | number |
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”updateConfig()
Section titled “updateConfig()”updateConfig(input: Partial<WaveformOptions>): void;Updates configuration options and triggers a re-render.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input | Partial<WaveformOptions> |
Returns
Section titled “Returns”void