UNPKG

react-sound-visualizer

Version:

A lightweight wrapper for the sound-visualizer library

47 lines (44 loc) 1.42 kB
import { UseVisualizerOptions } from './useVisualizer.mjs'; import 'sound-visualizer'; /** * The props passed to the function supplied as the child of `Visualizer`. **/ interface VisualizerChildrenProps { /** * Sets the canvas for the `Visualizer` to draw on. * * Should be passed as the `ref` prop to an HTML `canvas` element. **/ canvasRef: (canvas: HTMLCanvasElement) => void; /** * Starts the visualization on the canvas. **/ start?: () => void; /** * Stops the visualization, but does not clear the canvas. **/ stop?: () => void; /** * Stops the visualization and clears the canvas. **/ reset?: () => void; } type VisualizerProps = UseVisualizerOptions & { /** * A functional component that renders out the canvas and functions used by the `Visualizer`. **/ children?: React.FC<VisualizerChildrenProps>; /** * The audio to visualize. * * **Note:** it is the responsibility of the comoponent rendering `Visualizer` to stop the `MediaStream`'s tracks, * in case it's a recording. **/ audio: MediaStream | null; /** * When `true`, the `start` function will be run as soon as there is audio and a canvas. **/ autoStart?: boolean; }; declare const Visualizer: React.FC<VisualizerProps>; export { Visualizer, type VisualizerChildrenProps, type VisualizerProps };