@wesbos/audio-visualizer
v1.0.0
Published
A reusable library for visualizing audio data using a moving average technique
Downloads
2
Maintainers
Readme
Certainly! Here's the full library documentation in Markdown format:
AudioVisualizer Library Documentation
The AudioVisualizer
library provides a way to visualize audio using a canvas element. It supports visualizing audio from an audioElement
or a microphone stream.
Class: AudioVisualizer
Constructor
Creates an instance of the AudioVisualizer
class.
constructor(canvas: HTMLCanvasElement)
canvas
: The HTMLCanvasElement representing the canvas element where the visualization will be rendered.
Methods
visualize(audioElement: HTMLAudioElement)
Starts visualizing audio from an audioElement
.
visualize(audioElement: HTMLAudioElement): void
audioElement
: The HTMLAudioElement representing the audio element to visualize.
visualizeMicrophone()
Starts visualizing audio from a microphone stream.
visualizeMicrophone(): void
Example Usage
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.