Skip to content

Commit e01353e

Browse files
authored
Merge pull request #7 from WMsans/refactor-waveform-allocation
refactor: waveform allocation optimization
2 parents 861b6f4 + 11092d4 commit e01353e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/components/audio-waveform/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,12 @@ const AudioWaveform = ({
9292
canvas.width = width;
9393
canvas.height = height;
9494

95+
const bufferLength = analyser.frequencyBinCount;
96+
const dataArray = new Uint8Array(bufferLength);
97+
9598
const draw = () => {
9699
if (!analyser || !ctx) return;
97100

98-
const bufferLength = analyser.frequencyBinCount;
99-
const dataArray = new Uint8Array(bufferLength);
100101
analyser.getByteFrequencyData(dataArray);
101102

102103
ctx.clearRect(0, 0, width, height);

0 commit comments

Comments
 (0)