fix(export): MIDI offline khong co am thanh - cache preview cam/khong du -> tu chuyen sang bounce REALTIME (capture masterBus.output) thay vi xuat file cam

This commit is contained in:
2026-08-24 18:59:22 +07:00
parent 8639529ecd
commit 2bcc8369a5
3 changed files with 19 additions and 4 deletions
+12 -2
View File
@@ -27970,7 +27970,7 @@ const App = () => {
const hasMidiItems = allT.some(t => t.midiItems && t.midiItems.length > 0)
|| (sessionTabs || []).some(s => (s.tracks || []).some(t => t.midiItems && t.midiItems.length > 0));
if (hasMidiItems) {
const midiTracks = allT.filter(t => t.midiItems && t.midiItems.length > 0);
const midiTracks = allT.filter(t => t.midiItems && t.midiItems.length > 0 && !t.muted);
let needDur = 1.0;
midiTracks.forEach(t => {
(t.midiItems || []).forEach(m => {
@@ -27993,7 +27993,17 @@ const App = () => {
const c = midiCacheRef.current[t.id];
return c && c.chunks.length > 0 && c.duration >= needDur - 0.3 && cacheHasEnergy(c);
});
if (!cacheOK) {
// MIDI chỉ render offline qua preview cache (tap sfEntry lúc play). Cache
// câm/thiếu khi routing bridge vào masterBus.input hoặc sub-node thay vì
// sfEntry → file offline đủ duration nhưng KHÔNG CÓ ÂM THANH. Khi cache
// không đủ → TỰ chuyển sang bounce REALTIME (capture masterBus.output =
// đúng âm đang nghe) thay vì xuất file câm. Áp dụng Export Project (mix).
if (midiTracks.length > 0 && !cacheOK && exportSettings.source === 'project' && exportSettings.format === 'wav') {
showToast("Cache MIDI chưa đủ — tự chuyển sang bounce REALTIME để giữ nguyên âm thanh...", "info");
await triggerBounceExport();
return;
}
if (midiTracks.length > 0 && !cacheOK) {
showToast("Project có MIDI items chưa đủ cache preview — file offline có thể thiếu âm MIDI. Bật Realtime để bounce trung thực.", "warning");
}
}