useAudio
Creates a reactive Link whose value continuously updates to reflect the frequency response of a connected audio element.
Importing
1
import { useAudio } from '@infinityfx/lively/hooks';Usage
Call signature
1
const [ref, link] = useAudio({ bands, minFrequency, maxFrequency, smoothing })Parameters
bands?:
number = 8Number of frequency bands to divide the audio spectrum into.
minFrequency?:
number = 100The minimum frequency boundary in hertz.
maxFrequency?:
number = 2000The maximum frequency boundary in hertz.
smoothing?:
number = 0.7A number between 0 and 1 specifying how much temporal smoothing to apply to frequency changes.
Returns
ref:
React.RefObject<HTMLAudioElement | null> A React ref to attach to an HTMLAudioElement.
link:
AnimationLink<number[]> A reactive Link containing an array of normalized frequency values.