mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-28 12:36:35 +00:00
Derive buffer length
This commit is contained in:
parent
e467a457e6
commit
412c089848
2 changed files with 6 additions and 9 deletions
|
|
@ -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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue