useAudioAnalyser
Use the AnalyserNode (opens in a new tab) API to analyze audio data.
Type Definitions
type MediaSourceObject = HTMLAudioElement | HTMLVideoElement | MediaStream;
type MediaSourceNode<T extends MediaSourceObject> = T extends MediaStream ? MediaElementAudioSourceNode : MediaStreamAudioSourceNode;
type FrequencyDataHandler = (data: Uint8Array) => any;
const useAudioAnalyser: (args: {
handler: FrequencyDataHandler;
fftSize?: number;
}) => {
nodeRef: React.MutableRefObject<AnalyserNode | undefined>;
context: React.MutableRefObject<AudioContext | undefined>;
connect: <T extends MediaSourceObject>(source: T) => Promise<MediaSourceNode<T> | undefined>;
disconnect: () => void;
};