diff --git a/src/App.js b/src/App.js index 6b8f644..13c9978 100644 --- a/src/App.js +++ b/src/App.js @@ -1,5 +1,5 @@ import "./App.css"; -import { useEffect, useRef, useState } from "react"; +import { useCallback, useEffect, useRef, useState } from "react"; import WaveForm from "./WaveForm"; const App = () => { @@ -16,11 +16,11 @@ const App = () => { audioElmRef = useRef(null), audioAnalyzer = () => { const audioCtx = new (window.AudioContext || window.webkitAudioContext)(), + source = audioCtx.createMediaElementSource(audioElmRef.current), analyzer = audioCtx.createAnalyser() analyzer.fftSize = 2048 const bufferLength = analyzer.frequencyBinCount, - dataArray = new Uint8Array(bufferLength), - source = audioCtx.createMediaElementSource(audioElmRef.current) + dataArray = new Uint8Array(bufferLength) source.connect(analyzer) source.connect(audioCtx.destination) source.onended = () => { @@ -102,10 +102,10 @@ const App = () => {