Optimize realtime display processing

This commit is contained in:
Mikei386
2026-07-21 22:04:50 +02:00
parent a123539023
commit c067c73024
6 changed files with 165 additions and 26 deletions
+32 -5
View File
@@ -716,6 +716,7 @@ function buildProcessingProfile(viewId = style) {
const profile = {
needXy: false,
needRta: false,
needSpectro: false,
needVu: false,
needPpmDin: false,
needPpmEbu: false,
@@ -728,6 +729,8 @@ function buildProcessingProfile(viewId = style) {
for (const plotId of plotIds) {
if (plotId === 'realtime') {
profile.needRta = true;
} else if (plotId === 'spectrogram') {
profile.needSpectro = true;
} else if (plotId === 'goniometer-rtw') {
profile.needXy = true;
profile.needRms = true;
@@ -792,6 +795,7 @@ function setSlotForView(viewId, idx, value){
try { saveConfig?.(); } catch (_) {}
try { env?.audio?.updatePhoenixGlobalConfig?.(); } catch (_) {}
}
requestRender('processing-profile-change');
}
function resetAllSlotsToDefaults() {
@@ -804,6 +808,7 @@ function resetAllSlotsToDefaults() {
saveSlotState(slotsState);
saveSlotCustomizedState({});
refreshSlotEditors();
requestRender('processing-profile-change');
}
function initSlotSelect(sel, idx){
if (!sel) return;
@@ -1007,11 +1012,13 @@ initSplitPlotSelect(splitLeftSel, (val) => {
const clean = sanitizeSplitPlotId(val) ?? 'none';
CONFIG.SPLIT_VIEW_LEFT = clean;
saveConfig();
requestRender('processing-profile-change');
});
initSplitPlotSelect(splitRightSel, (val) => {
const clean = sanitizeSplitPlotId(val) ?? 'none';
CONFIG.SPLIT_VIEW_RIGHT = clean;
saveConfig();
requestRender('processing-profile-change');
});
function clampMeterCount3(v) {
@@ -1053,6 +1060,7 @@ function writeMeterToConfig(prefix, idx, val) {
const key = getMeterKey(prefix, idx);
CONFIG[key] = sanitizeSlotId(val) ?? 'vu';
saveConfig();
requestRender('processing-profile-change');
}
function setSplitMeterPopupOpen(open) {
@@ -1098,10 +1106,10 @@ function syncQuadPlotPopup() {
if (quadPlotSelBR) quadPlotSelBR.value = sanitizeSplitPlotId(CONFIG.QUAD_VIEW_BR) ?? 'none';
}
initSplitPlotSelect(quadPlotSelTL, (val) => { CONFIG.QUAD_VIEW_TL = sanitizeSplitPlotId(val) ?? 'phase-wheel'; saveConfig(); });
initSplitPlotSelect(quadPlotSelTR, (val) => { CONFIG.QUAD_VIEW_TR = sanitizeSplitPlotId(val) ?? 'realtime'; saveConfig(); });
initSplitPlotSelect(quadPlotSelBL, (val) => { CONFIG.QUAD_VIEW_BL = sanitizeSplitPlotId(val) ?? 'goniometer-rtw'; saveConfig(); });
initSplitPlotSelect(quadPlotSelBR, (val) => { CONFIG.QUAD_VIEW_BR = sanitizeSplitPlotId(val) ?? 'none'; saveConfig(); });
initSplitPlotSelect(quadPlotSelTL, (val) => { CONFIG.QUAD_VIEW_TL = sanitizeSplitPlotId(val) ?? 'phase-wheel'; saveConfig(); requestRender('processing-profile-change'); });
initSplitPlotSelect(quadPlotSelTR, (val) => { CONFIG.QUAD_VIEW_TR = sanitizeSplitPlotId(val) ?? 'realtime'; saveConfig(); requestRender('processing-profile-change'); });
initSplitPlotSelect(quadPlotSelBL, (val) => { CONFIG.QUAD_VIEW_BL = sanitizeSplitPlotId(val) ?? 'goniometer-rtw'; saveConfig(); requestRender('processing-profile-change'); });
initSplitPlotSelect(quadPlotSelBR, (val) => { CONFIG.QUAD_VIEW_BR = sanitizeSplitPlotId(val) ?? 'none'; saveConfig(); requestRender('processing-profile-change'); });
if (splitMeterBtn) {
splitMeterBtn.addEventListener('click', () => {
@@ -1857,10 +1865,12 @@ function handleSplitTapUp(x, y) {
if (env?.splitPopup?.open) {
env.splitPopup.open = false;
env.splitPopup.viewId = null;
requestRender('processing-profile-change');
return;
}
env.splitPopup.open = true;
env.splitPopup.viewId = target;
requestRender('processing-profile-change');
return;
}
env.switchView?.(target);
@@ -1877,6 +1887,7 @@ function handleQuadTapUp(x, y) {
// Popup ist offen: Tap innerhalb/außerhalb schließt
env.quadPopup.open = false;
env.quadPopup.viewId = null;
requestRender('processing-profile-change');
return;
}
if (isInAnyMeterHitRect(x, y)) return;
@@ -1889,6 +1900,7 @@ function handleQuadTapUp(x, y) {
if (env?.quadPopup) {
env.quadPopup.open = true;
env.quadPopup.viewId = target;
requestRender('processing-profile-change');
}
return;
}
@@ -1912,6 +1924,7 @@ C.addEventListener('pointerdown', (e) => {
if (!env?.splitPopup?.open) return;
env.splitPopup.open = false;
env.splitPopup.viewId = null;
requestRender('processing-profile-change');
try { e.preventDefault?.(); } catch (_) {}
try { e.stopPropagation?.(); } catch (_) {}
}, { capture: true, passive: false });
@@ -1968,6 +1981,7 @@ C.addEventListener('pointerdown', (e) => {
if (pointInRect(x, y, box)) return;
env.quadPopup.open = false;
env.quadPopup.viewId = null;
requestRender('processing-profile-change');
try { e.preventDefault?.(); } catch (_) {}
try { e.stopPropagation?.(); } catch (_) {}
}, { capture: true, passive: false });
@@ -2612,9 +2626,14 @@ let audioRecoverInFlight = false;
let lastAudioRecoverAt = 0;
let renderDirty = true;
let lastRenderedAudioSeq = 0;
let processingProfileDirty = true;
let appliedProcessingProfileView = '';
const DATA_ONLY_RENDER_REASONS = new Set(['audio', 'spectro', 'visuals']);
function requestRender(reason = 'ui') {
renderDirty = true;
if (!DATA_ONLY_RENDER_REASONS.has(reason)) processingProfileDirty = true;
env.__lastRenderReason = reason;
}
@@ -2647,7 +2666,15 @@ async function loop(now){
const elapsed = now - lastFrameTime;
const audioOk = env.audio.alive && !audioLost(env);
const renderStyle = getRenderableStyle();
try { env.audio?.updateProcessingConfig?.(buildProcessingProfile(renderStyle)); } catch (_) {}
if (processingProfileDirty || appliedProcessingProfileView !== renderStyle) {
try {
if (typeof env.audio?.updateProcessingConfig === 'function') {
env.audio.updateProcessingConfig(buildProcessingProfile(renderStyle));
processingProfileDirty = false;
appliedProcessingProfileView = renderStyle;
}
} catch (_) {}
}
const targetMs = audioOk ? (1000 / desiredFpsForStyle(renderStyle)) : (1000 / 20);
const target = targetMs;
const currentAudioSeq = Number.isFinite(env.audio?.xySeq) ? env.audio.xySeq : 0;