@wesbos/audio-visualizer
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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.

Package Sidebar

Install

npm i @wesbos/audio-visualizer

Weekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

4.43 kB

Total Files

4

Last publish

Collaborators

  • wesbos