3f59c2c4c2
- NativeInstrumentEngine: track GM bank per channel (CC0/CC32), use bank in programChange - app.jsx: send CC0/CC32+PROGRAM before notes via __ensureBridgeProgram, dedupe, clear dedupe after async LOAD - audioRoutingEngine/bridgeAudioNode: idempotent connect (no disconnect-flush on re-connect), fixes note cut & multi-track stuck - main.cpp: remove 10s poll in OPEN_GUI control job (blocked realtime loop, watchdog race), VstWindowProc stores channel not inst pointer, cleanup gui maps on WM_DESTROY
48 lines
1.9 KiB
JavaScript
48 lines
1.9 KiB
JavaScript
// app/static/js/services/audioRoutingEngine.js
|
|
// Routes the native bridge audio node into the DAW graph:
|
|
// bridge node -> track.sfEntry (FX rack chain) -> fader/pan -> masterBus
|
|
// Falls back to masterBus.input when no per-track sfEntry exists.
|
|
(function () {
|
|
var engine = {
|
|
_connected: false,
|
|
_trackId: null,
|
|
_dest: null,
|
|
|
|
isConnected: function () { return this._connected; },
|
|
|
|
/** bridgeNode = window.BridgeAudioNode; trackCtx = track node ({ sfEntry, gainNode }). */
|
|
connect: function (bridgeNode, trackCtx, trackId) {
|
|
if (!bridgeNode || !bridgeNode.getOutputNode) return false;
|
|
var dest = null;
|
|
if (trackCtx && trackCtx.sfEntry) dest = trackCtx.sfEntry;
|
|
else if (trackCtx && trackCtx.gainNode) dest = trackCtx.gainNode;
|
|
else if (window.masterBus && window.masterBus.input) dest = window.masterBus.input;
|
|
if (!dest) {
|
|
console.warn('[AudioRoutingEngine] no destination (no trackCtx / masterBus)');
|
|
return false;
|
|
}
|
|
// Idempotent: updateSfRouting/ensureMasteringRouting chay tren MOI keydown/
|
|
// note-on — neu da noi dung dest thi KHONG disconnect (disconnect flush ring
|
|
// -> am phim dang vang bi cat). Chi doi khi dest/track thuc su khac.
|
|
if (this._connected && this._dest === dest && this._trackId === (trackId || null)) return true;
|
|
this.disconnect();
|
|
if (!bridgeNode.isReady()) bridgeNode.init();
|
|
bridgeNode.connect(dest);
|
|
this._connected = true;
|
|
this._trackId = trackId || null;
|
|
this._dest = dest;
|
|
console.log('[AudioRoutingEngine] bridge audio -> ' + (trackId || 'masterBus'));
|
|
return true;
|
|
},
|
|
|
|
disconnect: function () {
|
|
if (window.BridgeAudioNode) window.BridgeAudioNode.disconnect();
|
|
this._connected = false;
|
|
this._trackId = null;
|
|
this._dest = null;
|
|
}
|
|
};
|
|
|
|
window.AudioRoutingEngine = engine;
|
|
})();
|