useAudio
Creates a reactive Link whose value is the frequency response of a connected audio source.
Importing
1
import { useAudio } from '@infinityfx/lively/hooks';
Usage
Call signature
1
const [ref, link] = useAudio({ bands, minFrequency, maxFrequency, smoothing })
Parameters
bands?:
number
= 8
The number of frequency bands to keep track of.
minFrequency?:
number
= 100
The frequency in hertz of the first band.
maxFrequency?:
number
= 2000
The frequency in hertz of the last band.
smoothing?:
number
= 0.7
A number between 0 and 1, which specifies how much smoothing to apply to the frequency response over time.
Returns
ref:
React.RefObject<HTMLAudioElement | null>
A React ref to attach to an HTMLAudioElement
link:
Link<number[]>
A link which can be used inside the animate property to create an animation.