Skip to main content

Using via Hook

How to use

First you have to import the useAudioFeature hook. Pass in a ref of an audio element and you are ready to access the functions that Soundy-js provides for you.

Visualizer

import useAudioFeatures from '../soundHook';

const YourVisualization = () => {
const playerRef = useRef(null);
const { getLowFrequencyData, getMidFrequencyData, getHighFrequencyData } =
useAudioFeatures(playerRef);
return (
<div>
<audio
id="audioPlayer"
src="your_audio.mp3"
ref={playerRef}>
</audio>
... your visualization elements here
</div>
);
};