M21: diag Bug C — ph-diag log playhead quanh PWR master FX toggle (arm 6s: snapshot refs/fxRt tai click/effect/freeze/snap/anchor + ph_jump khi delta>0.25s)

This commit is contained in:
2026-09-07 10:04:59 +07:00
parent fa6d09ee83
commit 0ffb6caa82
3 changed files with 52 additions and 13 deletions
+35 -1
View File
@@ -386,6 +386,10 @@ let _fxRtFreezeTimer = null;
let _fxRtFreezeTries = 0;
let _fxRtSeekFreeze = false;
let _fxRtSeekFreezeTimer = null;
// M21 ph-diag (Bug C): playhead nhay khi PWR master FX toggle. _phDiagArmedUntil
// (ms epoch) mo cua so log khi __phArmPwr duoc goi; _phArmed kiem tra hieu luc.
let _phDiagArmedUntil = 0;
const _phArmed = () => Date.now() < _phDiagArmedUntil;
const _nativeTrackUrls = {};
const _nativeTrackPending = {};
// ── MIDI overlap cleanup + polyphony gain (spec midi_polyphony_loudness) ─
@@ -2551,11 +2555,15 @@ const FX_RT_START_EST_MS = 450;
// (moi play/resume path deu goi); cold start (chua active) -> null -> WS message
// dau tien anchor.
function fxRtAnchorProcessed() {
const _phPrevAnchor = (fxRt && fxRt.processedAnchor);
if (fxRt && fxRt.active && typeof fxRt.processedSamples === 'number') {
fxRt.processedAnchor = fxRt.processedSamples;
} else {
fxRt.processedAnchor = null;
}
try {
if (_phArmed()) _dbgLog('ph_anchor', 'prevA=' + (typeof _phPrevAnchor === 'number' ? _phPrevAnchor : 'na') + ' ps=' + (typeof fxRt.processedSamples === 'number' ? fxRt.processedSamples : 'na') + ' pa=' + (typeof fxRt.processedAnchor === 'number' ? fxRt.processedAnchor : 'na') + ' act=' + (fxRt && fxRt.active ? 1 : 0));
} catch (e) {}
}
function fxRtApplyPdc() {
@@ -3679,6 +3687,7 @@ const MasterStripConsole = ({ masterVolume, setMasterVolume, masterVolL, setMast
id: "powerBtn",
className: "btn-daw h-[18px] rounded text-xs transition-all" + (isMasterActive ? " btn-teal-active" : ""),
onClick: function() {
try { if (window.__phArmPwr) window.__phArmPwr(isMasterActive ? 'off' : 'on'); } catch (e) {}
if (setMasteringSettings) {
setMasteringSettings(function(prev) { return Object.assign({}, prev, { masterConnected: !prev.masterConnected, isBypassed: false }); });
}
@@ -15684,7 +15693,7 @@ const addMasterVst = (path) => { const fx = (masterFxList || []).find(f => f.pat
<div className="flex items-center gap-3 text-xs oz-font-mono">
<span className="text-slate-400 text-[11px]">Target LUFS:</span>
<span className="text-cyan-400 font-bold bg-slate-950 border border-cyan-900/60 px-2 py-0.5 rounded">-11.0 LUFS</span>
<button onClick={() => { getAudioContext(); setMasterConnected(prev => !prev); }}
<button onClick={() => { try { if (window.__phArmPwr) window.__phArmPwr(masterConnected ? 'off' : 'on'); } catch (e) {} getAudioContext(); setMasterConnected(prev => !prev); }}
className={`px-2 py-0.5 rounded text-[10px] font-bold border transition-colors ${masterConnected ? 'bg-emerald-700 border-emerald-500 text-white' : 'bg-slate-800 border-slate-700 text-slate-300 hover:bg-slate-700'}`}>
{masterConnected ? 'Master ON' : 'Master OFF'}
</button>
@@ -20905,6 +20914,7 @@ const App = () => {
updateSfRouting();
} 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]);
const [pluginManagerModalOpen, setPluginManagerModalOpen] = useState(false);
@@ -21775,6 +21785,7 @@ const App = () => {
// worklet fx_play_first → bỏ freeze đúng mẫu đầu tiên nghe được. Fail-safe:
// session không active trong 1500ms → hủy freeze (đừng đóng băng playhead vô hạn).
window.__fxRtPlayheadFreeze = function (allowCold) {
try { if (_phArmed()) { window.__phSnapAll('ph_freeze_pre'); _dbgLog('ph_freeze_pre', 'allowCold=' + (allowCold ? 1 : 0) + ' chain=' + fxRtChain().length); } } catch (e) {}
try { if (_fxRtFreezeTimer) { clearTimeout(_fxRtFreezeTimer); _fxRtFreezeTimer = null; } } catch (e3) {}
// G3: FX active -> playhead engine-derived (processed) — KHONG freeze/snap.
// Anchor processed tai day (moi play/resume path deu goi ham nay).
@@ -21822,6 +21833,7 @@ const App = () => {
}, _estMs);
};
window.__fxRtSnapPlayhead = function () {
try { if (_phArmed()) window.__phSnapAll('ph_snap_pre'); } catch (e) {}
// V45.16: hết seek-freeze — playhead bắt đầu từ startOffset tại mẫu nghe được.
if (_fxRtSeekFreeze) {
_fxRtSeekFreeze = false;
@@ -21863,6 +21875,22 @@ const App = () => {
const mainResumeRef = useRef(null);
currentTimeRef.current = currentTime;
// 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).
window.__phArmPwr = function (dir) {
try {
_phDiagArmedUntil = Date.now() + 6000;
_dbgLog('ph_pwr', 'dir=' + dir + ' cur=' + (currentTimeRef.current == null ? 'na' : currentTimeRef.current.toFixed(3)) + ' off=' + (startOffsetTimeRef.current == null ? 'na' : startOffsetTimeRef.current.toFixed(3)) + ' at=' + (startAudioTimeRef.current == null ? 'na' : startAudioTimeRef.current.toFixed(3)) + ' ctx=' + (getAudioContext().currentTime || 0).toFixed(3) + ' fx=' + (fxRt ? ('act=' + (fxRt.active ? 1 : 0) + ' warm=' + (fxRt.warm ? 1 : 0) + ' start=' + (fxRt.starting ? 1 : 0) + ' ps=' + (typeof fxRt.processedSamples === 'number' ? fxRt.processedSamples : 'na') + ' pa=' + (typeof fxRt.processedAnchor === 'number' ? fxRt.processedAnchor : 'na') + ' lat=' + (fxRt.latencyTotal || 0) + ' pdc=' + (fxRt.pdcCalibMs || 0) + ' sid=' + (fxRt.sessionId || 'na')) : 'na') + ' freeze=' + (_fxRtSeekFreeze ? 1 : 0) + ' snap=' + (_fxRtPlayheadSnapPending ? 1 : 0) + ' wh=' + (wrapHoldRef.current ? (wrapHoldRef.current.end.toFixed(3) + '/' + wrapHoldRef.current.v0.toFixed(3)) : 'na'));
} catch (e) { try { _dbgLog('ph_pwr', 'err ' + String(e)); } catch (e2) {} }
};
window.__phSnapAll = function (tag) {
try {
if (!_phArmed()) return;
_dbgLog(tag, 'cur=' + (currentTimeRef.current == null ? 'na' : currentTimeRef.current.toFixed(3)) + ' off=' + (startOffsetTimeRef.current == null ? 'na' : startOffsetTimeRef.current.toFixed(3)) + ' at=' + (startAudioTimeRef.current == null ? 'na' : startAudioTimeRef.current.toFixed(3)) + ' ctx=' + (getAudioContext().currentTime || 0).toFixed(3) + ' fx=' + (fxRt ? ('act=' + (fxRt.active ? 1 : 0) + ' warm=' + (fxRt.warm ? 1 : 0) + ' start=' + (fxRt.starting ? 1 : 0) + ' ps=' + (typeof fxRt.processedSamples === 'number' ? fxRt.processedSamples : 'na') + ' pa=' + (typeof fxRt.processedAnchor === 'number' ? fxRt.processedAnchor : 'na') + ' lat=' + (fxRt.latencyTotal || 0) + ' pdc=' + (fxRt.pdcCalibMs || 0) + ' sid=' + (fxRt.sessionId || 'na')) : 'na') + ' freeze=' + (_fxRtSeekFreeze ? 1 : 0) + ' snap=' + (_fxRtPlayheadSnapPending ? 1 : 0) + ' wh=' + (wrapHoldRef.current ? (wrapHoldRef.current.end.toFixed(3) + '/' + wrapHoldRef.current.v0.toFixed(3)) : 'na'));
} catch (e) { try { _dbgLog(tag, 'err ' + String(e)); } catch (e2) {} }
};
// ── Keyboard Shortcuts ──
const handleUndoRef = useRef(handleUndo);
const handleRedoRef = useRef(handleRedo);
@@ -25482,6 +25510,12 @@ const App = () => {
setCurrentTime(_whv);
}
} else {
if (Date.now() < _phDiagArmedUntil) {
const _pd = _playheadSec - (currentTimeRef.current || 0);
if (_pd > 0.25 || _pd < -0.25) {
try { _dbgLog('ph_jump', 'prevShown=' + (currentTimeRef.current || 0).toFixed(3) + ' now=' + _playheadSec.toFixed(3) + ' d=' + _pd.toFixed(3)); } catch (e) {}
}
}
setCurrentTime(_playheadSec);
}
animationFrameIdRef.current = requestAnimationFrame(updatePlayhead);
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -51,7 +51,7 @@
<script src="/static/js/services/promptTemplateManager.js?v=202608290945"></script>
<script src="/static/js/services/undoRedoEngine.js?v=202608290945"></script>
<script src="/static/js/services/chordTheory.js?v=202608290945"></script>
<script src="/static/js/app.precompiled.js?v=202609070903202609070853202609070713" defer></script>
<script src="/static/js/app.precompiled.js?v=202609070903202609070853202609070713202609071004" defer></script>
<link rel="stylesheet" href="/static/css/styles.css?v=202608290945">
<style>
:root {