Certainly! Here's the full library documentation in Markdown format:
The AudioVisualizer
library provides a way to visualize audio using a canvas element. It supports visualizing audio from an audioElement
or a microphone stream.
Creates an instance of the AudioVisualizer
class.
constructor(canvas: HTMLCanvasElement)
-
canvas
: The HTMLCanvasElement representing the canvas element where the visualization will be rendered.
Starts visualizing audio from an audioElement
.
visualize(audioElement: HTMLAudioElement): void
-
audioElement
: The HTMLAudioElement representing the audio element to visualize.
Starts visualizing audio from a microphone stream.
visualizeMicrophone(): void
import { AudioVisualizer } from "your-library-path";
// Example usage with an audio element
const canvas = document.getElementById("your-canvas-id");
const audio = document.getElementById("your-audio-element-id");
const visualizer = new AudioVisualizer(canvas);
visualizer.visualize(audio);
// Example usage with a microphone stream
const canvas = document.getElementById("your-canvas-id");
const visualizer = new AudioVisualizer(canvas);
visualizer.visualizeMicrophone();
Make sure to replace 'your-library-path'
, 'your-canvas-id'
, and 'your-audio-element-id'
with the actual path to your library, the ID of your canvas element, and the ID of your audio element, respectively.
That concludes the documentation for the AudioVisualizer
library. You can now integrate the library into your projects to visualize audio using a canvas element.