diff --git a/js/components/Visualizer.js b/js/components/Visualizer.js index c6857796..5fa25b48 100644 --- a/js/components/Visualizer.js +++ b/js/components/Visualizer.js @@ -94,14 +94,14 @@ class Visualizer extends React.Component { // update. this.props.analyser.fftSize = 2048; if (this.props.style === VISUALIZERS.OSCILLOSCOPE) { - this.bufferLength = this.props.analyser.fftSize; - this.dataArray = new Uint8Array(this.bufferLength); + this.dataArray = new Uint8Array(this.props.analyser.fftSize); } else if (this.props.style === VISUALIZERS.BAR) { - this.bufferLength = this.props.analyser.frequencyBinCount; - this.dataArray = new Uint8Array(this.bufferLength); + this.dataArray = new Uint8Array(this.props.analyser.frequencyBinCount); if (!this.octaveBuckets) { - this.octaveBuckets = octaveBucketsForBufferLength(this.bufferLength); + this.octaveBuckets = octaveBucketsForBufferLength( + this.dataArray.length + ); } } } @@ -116,7 +116,6 @@ class Visualizer extends React.Component { canvasCtx: this.canvasCtx, height: this.props.height, width: this.props.width, - bufferLength: this.bufferLength, colors: this.props.colors, renderWidth: this.props.renderWidth, }); diff --git a/js/components/visualizerUtils.ts b/js/components/visualizerUtils.ts index 9df2c8fa..322acccd 100644 --- a/js/components/visualizerUtils.ts +++ b/js/components/visualizerUtils.ts @@ -116,7 +116,6 @@ export function paintOscilloscopeFrame({ canvasCtx, height, width, - bufferLength, colors, renderWidth, }: { @@ -125,7 +124,6 @@ export function paintOscilloscopeFrame({ canvasCtx: CanvasRenderingContext2D; height: number; width: number; - bufferLength: number; colors: string[]; renderWidth: number; }) { @@ -142,7 +140,7 @@ export function paintOscilloscopeFrame({ // // We use the 2x scale here since we only want to plot values for // "real" pixels. - const sliceWidth = Math.floor(bufferLength / width) * PIXEL_DENSITY; + const sliceWidth = Math.floor(dataArray.length / width) * PIXEL_DENSITY; const h = height;