Size
0.67 kb
useAudioAnalyser
Real-time audio analysis based on the Web Audio API.
Installation
Quick Start
Pass the MediaStream or HTMLAudioElement to analyze to useAudioAnalyser.
Check out the API reference to learn more about the available methods
Examples
1. Visualize audio frequencies of a media element
Visualize audio frequencies in real-time by analyzing data from an HTML audio element using the useAudioAnalyser hook.
2. Visualize audio frequencies from a microphone
Combine the useUserMedia hook to capture microphone input with the useAudioAnalyser hook to process and visualize the audio frequency data in real-time.
3. Draw the frequency data on a canvas
This example uses the useAudioAnalyser hook to analyze the audio frequency data from an audio element and draw the frequency data on a canvas.
API Reference
Parameters
| Prop | Type | Default | 
|---|---|---|
options? | AudioAnalyserOptions | - | 
source | MediaStream | HTMLMediaElement | null | - | 
AudioAnalyserOptions
The options for the audio analyzer.
| Prop | Type | Default | 
|---|---|---|
onData? | ((data: number[]) => void) | - | 
smoothingTimeConstant? | number | - | 
maxDecibels? | number | - | 
minDecibels? | number | - | 
fftSize? | number | - | 
sampleRate? | number | - | 
method | string | - |