FIX: Carla sử dụng bridge có midikeyboard

This commit is contained in:
2026-08-10 08:53:05 +07:00
parent aa32272f36
commit 250b94cd88
5 changed files with 163 additions and 25 deletions
+46 -1
View File
@@ -5294,6 +5294,8 @@ const PluginManagerModal = ({ isOpen, onClose, pluginsData, onInsertInstrument }
const [pmSfLoading, setPmSfLoading] = React.useState({});
// Force re-render sau khi đnh v Carla (capabilities đi)
const [pmCarlaVersion, setPmCarlaVersion] = React.useState(0);
// Khai báo trc tiếp thư mc cha carla.exe (nhp tay, không cn picker)
const [pmCarlaPathInput, setPmCarlaPathInput] = React.useState('');
React.useEffect(() => {
if (isOpen) {
window.SonicAPI.listPlugins()
@@ -5416,6 +5418,24 @@ const PluginManagerModal = ({ isOpen, onClose, pluginsData, onInsertInstrument }
}
} catch (err) { showToast('Lỗi định vị Carla: ' + (err.message || err), 'error'); }
};
// Khai báo thư mc Carla trc tiếp (nhp tay) tương t Đnh v nhưng
// không cn hp thoi chn thư mc.
const saveCarlaInput = async () => {
const p = (pmCarlaPathInput || '').trim();
if (!p) { showToast('Nhập đường dẫn thư mục chứa carla.exe', 'warning'); return; }
try {
const r = await window.SonicAPI.setCarlaPath(p);
if (r && r.success && r.carla_path) {
window.SonicRuntime.capabilities = r;
document.documentElement.dataset.carla = r.features && r.features.carla_local ? '1' : '0';
setPmCarlaVersion(v => v + 1);
setPmCarlaPathInput('');
showToast('Đã lưu Carla: ' + r.carla_path, 'success');
} else {
showToast('Không tìm thấy carla.exe trong đường dẫn đã nhập', 'error');
}
} catch (err) { showToast('Lỗi: ' + (err.message || err), 'error'); }
};
// Lưu dirs (user override) + scan c 2 thư mc refresh list + catalog.
const saveAndScanDirs = async () => {
setPmScanning(true);
@@ -5667,6 +5687,20 @@ const PluginManagerModal = ({ isOpen, onClose, pluginsData, onInsertInstrument }
onClick: () => { window.SonicAPI.openInCarla().then(function (r) { if (r && r.success) showToast('Đã mở Carla', 'success'); }).catch(function (err) { showToast('Lỗi mở Carla: ' + (err.message || err), 'error'); }); },
className: 'px-3 py-1.5 bg-zinc-800 hover:bg-zinc-700 text-teal-300 text-xs font-semibold rounded transition flex items-center gap-1'
}, React.createElement('i', { 'data-lucide': 'play', className: 'w-3 h-3' }), 'Mở Carla')
),
React.createElement('div', { className: 'flex gap-2 mt-2' },
React.createElement('input', {
type: 'text',
placeholder: 'Hoặc nhập thư mục chứa carla.exe (VD: D:/Tools/Carla)',
value: pmCarlaPathInput,
onChange: e => setPmCarlaPathInput(e.target.value),
onKeyDown: e => { if (e.key === 'Enter') saveCarlaInput(); },
className: 'flex-1 bg-zinc-800 border border-zinc-700 rounded px-2 py-1.5 text-xs text-zinc-300 focus:outline-none focus:border-teal-600'
}),
React.createElement('button', {
onClick: saveCarlaInput,
className: 'px-3 py-1.5 bg-zinc-800 hover:bg-zinc-700 text-teal-300 text-xs font-semibold rounded transition shrink-0'
}, 'Lưu')
)
),
// Plugin directories section (folder picker + save + scan)
@@ -30099,7 +30133,18 @@ STRICT CONSTRAINTS:
className: "flex items-stretch"
},
/*#__PURE__*/React.createElement("button", {
onClick: () => { setInstrumentDropdownTrackId(null); setInstrumentDropdownBtnRect(null); setTrackInstrumentWithUndo(instrumentDropdownTrackId, v.id, v.name || v.id); },
onClick: () => {
setInstrumentDropdownTrackId(null);
setInstrumentDropdownBtnRect(null);
setTrackInstrumentWithUndo(instrumentDropdownTrackId, v.id, v.name || v.id);
// T ĐNG m Carla vi VSTi va chn (desktop + Carla local)
// Carla load sn plugin, native GUI + keyboard o đ preview realtime.
if (window.SonicRuntime && window.SonicRuntime.capabilities && window.SonicRuntime.capabilities.features && window.SonicRuntime.capabilities.features.carla_local) {
window.SonicAPI.openInCarla(v.id).then(function (r) {
if (r && r.success) showToast('Đã mở Carla với ' + (v.name || v.id) + ' — chọn preset, bấm keyboard để preview', 'success');
}).catch(function (err) { showToast('Lỗi mở Carla: ' + (err.message || err), 'error'); });
}
},
className: "flex-1 min-w-0 text-left px-3 py-1.5 text-xs bg-zinc-800 hover:bg-violet-800 text-zinc-200 flex items-center justify-between"
}, /*#__PURE__*/React.createElement("span", { className: "truncate" }, v.name || v.id), /*#__PURE__*/React.createElement("span", { className: "text-[10px] text-cyan-400 shrink-0 ml-1" }, v.type || "VST")),
window.SonicRuntime && window.SonicRuntime.capabilities && window.SonicRuntime.capabilities.features && window.SonicRuntime.capabilities.features.carla_local ? /*#__PURE__*/React.createElement("button", {
File diff suppressed because one or more lines are too long