mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-22 09:37:17 +00:00
Set FFT size in outer component
This commit is contained in:
parent
cfab50cb94
commit
5ec817dffd
2 changed files with 4 additions and 13 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import React, { useMemo, useCallback, useState } from "react";
|
||||
import React, { useMemo, useCallback, useState, useLayoutEffect } from "react";
|
||||
|
||||
import * as Actions from "../actionCreators";
|
||||
import * as Selectors from "../selectors";
|
||||
|
|
@ -125,6 +125,9 @@ function preRenderBar(
|
|||
return barCanvas;
|
||||
}
|
||||
function Visualizer(props: Props) {
|
||||
useLayoutEffect(() => {
|
||||
props.analyser.fftSize = 2048;
|
||||
}, [props.analyser]);
|
||||
const colors = useTypedSelector(Selectors.getSkinColors);
|
||||
const style = useTypedSelector(Selectors.getVisualizerStyle);
|
||||
const status = useTypedSelector(Selectors.getMediaStatus);
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@ class VisualizerInner extends React.Component {
|
|||
this.canvasCtx = this.canvas.getContext("2d");
|
||||
this.canvasCtx.imageSmoothingEnabled = false;
|
||||
|
||||
this.setStyle();
|
||||
|
||||
// Kick off the animation loop
|
||||
const loop = () => {
|
||||
if (this.props.status === MEDIA_STATUS.PLAYING) {
|
||||
|
|
@ -38,7 +36,6 @@ class VisualizerInner extends React.Component {
|
|||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
this.setStyle();
|
||||
// Redraw the current frame, since the skin may have changed.
|
||||
this.paintFrame();
|
||||
}
|
||||
|
|
@ -59,15 +56,6 @@ class VisualizerInner extends React.Component {
|
|||
return this.props.width * PIXEL_DENSITY;
|
||||
}
|
||||
|
||||
setStyle() {
|
||||
if (!this.props.colors) {
|
||||
return;
|
||||
}
|
||||
// TODO: Split this into to methods. One for skin update, one for style
|
||||
// update.
|
||||
this.props.analyser.fftSize = 2048;
|
||||
}
|
||||
|
||||
paintFrame() {
|
||||
switch (this.props.style) {
|
||||
case VISUALIZERS.OSCILLOSCOPE:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue