M22: fix Bug C playhead nhay khi PWR toggle — rebase timeline (off/at + anchor=ps) khi wake warm-session giua play; diag Bug B — mdiag dB khi F7 toggle Mixer Panel

This commit is contained in:
2026-09-07 10:38:45 +07:00
parent 0ffb6caa82
commit dc962c87cd
3 changed files with 43 additions and 7 deletions
+27
View File
@@ -19630,6 +19630,10 @@ const App = () => {
setShowMediaExplorerRef.current = setShowMediaExplorer;
// F6/F7 mutual exclusion: enabling one panel disables the other
window.__toggleMixerRef = function() {
// M22 Bug B diag: F7 mở/đóng MIXER PANEL (user: mở panel → âm lượng giảm
// nhỏ; M20 chỉ instrument MasteringModal panel_open — F7 đi đường khác nên
// chưa có dB). Chụp dB master OUT + hist + post như panel_open.
try { _mdiagSample('mixer_toggle'); _mdiagDump(); _mdiagSchedulePost(); } catch (e) {}
setShowMixer(function(p) {
const next = !p;
if (next) setShowMediaExplorerRef.current(false);
@@ -20828,6 +20832,8 @@ const App = () => {
useEffect(() => {
window.currentMasteringSettings = masteringSettings;
const _fxPrevAct = !!(fxRt && fxRt.active);
const _fxPrevWarm = !!(fxRt && fxRt.warm);
if (audioCtx && masterBus) {
toggleMasteringOnMaster(masteringSettings.masterConnected, masteringSettings.isBypassed);
applyMasteringSettings(masteringSettings);
@@ -20914,6 +20920,7 @@ const App = () => {
updateSfRouting();
} catch (e) {}
}
try { if (!_fxPrevAct && _fxPrevWarm && fxRt.active && window.__fxRtWakeRebase) window.__fxRtWakeRebase(); } catch (e) {}
try { if (_phArmed() && window.__phSnapAll) { window.__phSnapAll('ph_effect'); _dbgLog('ph_effect', 'mc=' + (masteringSettings.masterConnected ? 1 : 0) + ' bp=' + (masteringSettings.isBypassed ? 1 : 0) + ' chain=' + fxRtChain().length + ' gui=' + (masteringSettings.gui_open_path || 'na')); } } catch (e) {}
}, [masteringSettings]);
@@ -21875,6 +21882,26 @@ const App = () => {
const mainResumeRef = useRef(null);
currentTimeRef.current = currentTime;
// M22 Bug C fix hook: rebase timeline khi wake warm-session (PWR ON giữa lúc
// play) — engine processedSamples bị đóng băng suốt OFF-warm (worklet rời
// graph) nên ps−anchor cũ tụt cả khoảng OFF; nếu không rebase playhead
// engine-derived nhảy LÙI về vị trí trước OFF (ph_jump d âm lớn). Rebase:
// dời startOffsetTimeRef/startAudioTimeRef về wall hiện tại + anchor=ps →
// engine clock nối lại đúng chỗ, playhead liên tục (lệch ~latencyTotal).
window.__fxRtWakeRebase = function () {
try {
if (!fxRt || !fxRt.active) return;
const _c = getAudioContext();
const _wall = (startOffsetTimeRef.current || 0) + (_c.currentTime - (startAudioTimeRef.current || _c.currentTime));
const _pa = (typeof fxRt.processedSamples === 'number') ? fxRt.processedSamples : null;
startOffsetTimeRef.current = _wall;
startAudioTimeRef.current = _c.currentTime;
if (_pa !== null) fxRt.processedAnchor = _pa;
if (_fxRtSeekFreeze) { _fxRtSeekFreeze = false; if (_fxRtSeekFreezeTimer) { clearTimeout(_fxRtSeekFreezeTimer); _fxRtSeekFreezeTimer = null; } }
try { _dbgLog('ph_rebase', 'wall=' + _wall.toFixed(3) + ' at=' + startAudioTimeRef.current.toFixed(3) + ' off=' + startOffsetTimeRef.current.toFixed(3) + ' ps=' + (typeof fxRt.processedSamples === 'number' ? fxRt.processedSamples : 'na') + ' pa=' + (typeof fxRt.processedAnchor === 'number' ? fxRt.processedAnchor : 'na') + ' lat=' + (fxRt.latencyTotal || 0)); } catch (e) {}
} catch (e) { try { _dbgLog('ph_rebase', 'err ' + String(e)); } catch (e2) {} }
};
// M21 ph-diag hooks (Bug C — playhead nhay khi PWR master FX toggle)
// __phArmPwr: user bam PWR OFF/ON -> arm cua so log 6s + snapshot ngay lap tuc.
// __phSnapAll: snapshot refs/fxRt tai diem goi (chi log khi cua so dang mo).