UNPKG

@audiowave/react

Version:

React audio visualization component

68 lines 2.34 kB
import { RefObject } from 'react'; import { ScrollingWaveformParams, WaveformDataPoint } from '../types'; export interface CanvasSetupResult { context: CanvasRenderingContext2D; width: number; height: number; halfWidth: number; halfHeight: number; } export interface RenderBarParams { context: CanvasRenderingContext2D; x: number; y: number; width: number; height: number; color: string; rounded: number; } export interface RenderWaveformParams { canvas: HTMLCanvasElement; audioData: Uint8Array; backgroundColor: string; barColor: string; secondaryBarColor: string; barWidth: number; gap: number; rounded: number; speed: number; animateCurrentPick: boolean; fullscreen: boolean; isActive: boolean; } /** * Initialize canvas with proper dimensions and background */ export declare function setupCanvas(canvas: HTMLCanvasElement, backgroundColor?: string): CanvasSetupResult | null; /** * Render a single bar with optional rounded corners */ export declare function renderBar({ context, x, y, width, height, color, rounded }: RenderBarParams): void; /** * Draw live streaming waveform visualization */ export declare const drawByLiveStream: ({ audioData, unit, index, index2, canvas, isAudioInProgress, isPausedAudio, picks, backgroundColor, barWidth, mainBarColor, secondaryBarColor, rounded, animateCurrentPick, fullscreen, gain, amplitudeMode, }: { audioData: Uint8Array; unit: number; index: RefObject<number>; index2: RefObject<number>; canvas: HTMLCanvasElement; isAudioInProgress: boolean; isPausedAudio: boolean; picks: Array<WaveformDataPoint | null>; backgroundColor: string; barWidth: number; mainBarColor: string; secondaryBarColor: string; rounded: number; animateCurrentPick: boolean; fullscreen: boolean; gain?: number; amplitudeMode?: "peak" | "rms" | "adaptive"; }) => void; export declare function renderScrollingWaveform(params: ScrollingWaveformParams): void; /** * Utility to resize canvas with proper pixel ratio handling and background initialization */ export declare function resizeCanvas(canvas: HTMLCanvasElement, width: number, height: number, backgroundColor?: string, _pixelRatio?: number): void; //# sourceMappingURL=canvasRenderer.d.ts.map