fix: real VU meter levels from pipeline instead of random animation
- Added input_level and output_level to /api/state (scaled 0-100) - React RigScreen now reads real levels from state instead of random walk - When no audio flows, VU meters show flat (0) instead of fake animation
This commit is contained in:
@@ -460,23 +460,11 @@ function SlidePanel({ children, onClose }) {
|
||||
// 1. RIG SCREEN ────────────────────────────────────────────────
|
||||
function RigScreen({ state, connected }) {
|
||||
const [volume, setVolume] = useState(state?.master_volume != null ? Math.round(state.master_volume * 100) : 80);
|
||||
const [vuL, setVuL] = useState(45);
|
||||
const [vuR, setVuR] = useState(42);
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (state?.master_volume != null) setVolume(Math.round(state.master_volume * 100));
|
||||
}, [state?.master_volume]);
|
||||
|
||||
// Animated VU
|
||||
useEffect(() => {
|
||||
const id = setInterval(() => {
|
||||
setVuL(prev => Math.max(10, Math.min(95, prev + (Math.random() - 0.48) * 12)));
|
||||
setVuR(prev => Math.max(10, Math.min(95, prev + (Math.random() - 0.48) * 12)));
|
||||
}, 90);
|
||||
return () => clearInterval(id);
|
||||
}, []);
|
||||
|
||||
const handleVolume = async (val) => {
|
||||
setVolume(val);
|
||||
try {
|
||||
@@ -497,6 +485,10 @@ function RigScreen({ state, connected }) {
|
||||
} catch (e) { /* ignore */ }
|
||||
};
|
||||
|
||||
// Real audio levels from the pipeline (0-100 scale, updated every poll cycle)
|
||||
const inputLevel = state?.input_level ?? 0;
|
||||
const outputLevel = state?.output_level ?? 0;
|
||||
|
||||
return (
|
||||
<div style={{ display: "flex", flexDirection: "column", height: "100%" }}>
|
||||
<div className="screen-header">
|
||||
@@ -518,8 +510,8 @@ function RigScreen({ state, connected }) {
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ display: "flex", gap: 6, alignItems: "center" }}>
|
||||
<VUMeter level={vuL} height={44} />
|
||||
<VUMeter level={vuR} height={44} />
|
||||
<VUMeter level={inputLevel} height={44} />
|
||||
<VUMeter level={outputLevel} height={44} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="screen-body">
|
||||
|
||||
Reference in New Issue
Block a user