Capítulo 985 de 988
_Part of the @remotion/media-utils package of helper functions.
export const MyComponent: React.FC = () => {
const frame = useCurrentFrame();
const {width, height, fps} = useVideoConfig();
const audioData = useAudioData(staticFile('music.mp3'));
if (!audioData) {
return null;
}
const visualization = visualizeAudio({
fps,
frame,
audioData,
numberOfSamples: 16,
}); // [0.22, 0.1, 0.01, 0.01, 0.01, 0.02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
// Render a bar chart for each frequency, the higher the amplitude,
// the longer the bar
return (
<div>
<Audio src={staticFile('music.mp3')} />
{visualization.map((v) => {
return <div style={{width: 1000 * v, height: 15, backgroundColor: 'blue'}} />;
})}
</div>
);
};