Merge branch 'worktree-agent-a188c7ec'
This commit is contained in:
commit
97376c8d3f
2 changed files with 11 additions and 7 deletions
|
|
@ -810,6 +810,7 @@ async function setActiveEngine(engine) {
|
||||||
activeEngine = engine;
|
activeEngine = engine;
|
||||||
c15 = engine; // keep alias in sync
|
c15 = engine; // keep alias in sync
|
||||||
arpeggiator.setEngine(engine);
|
arpeggiator.setEngine(engine);
|
||||||
|
if (midiInput) midiInput.setEngine(engine);
|
||||||
const btn = document.getElementById('synth-mode-btn');
|
const btn = document.getElementById('synth-mode-btn');
|
||||||
if (btn) btn.textContent = engine.displayName;
|
if (btn) btn.textContent = engine.displayName;
|
||||||
const engineDockBtn = document.querySelector('[data-drawer="params"]');
|
const engineDockBtn = document.querySelector('[data-drawer="params"]');
|
||||||
|
|
@ -916,7 +917,7 @@ async function init() {
|
||||||
if (el) el.textContent = msg;
|
if (el) el.textContent = msg;
|
||||||
};
|
};
|
||||||
arpeggiator = new Arpeggiator(activeEngine);
|
arpeggiator = new Arpeggiator(activeEngine);
|
||||||
midiInput = new MIDIInput(activeEngine.bridge); // MIDIInput still talks to the C15 bridge directly
|
midiInput = new MIDIInput(activeEngine);
|
||||||
initMIDIControls();
|
initMIDIControls();
|
||||||
|
|
||||||
// MIDI Output
|
// MIDI Output
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
// MIDI Input — receives notes and CCs from external MIDI controllers
|
// MIDI Input — receives notes and CCs from external MIDI controllers
|
||||||
// Uses Web MIDI API, routes note on/off to C15 bridge
|
// Uses Web MIDI API, routes note on/off through a SynthEngine interface
|
||||||
|
|
||||||
export class MIDIInput {
|
export class MIDIInput {
|
||||||
constructor(bridge) {
|
constructor(engine) {
|
||||||
this.bridge = bridge;
|
this.engine = engine;
|
||||||
this.enabled = false;
|
this.enabled = false;
|
||||||
this.midiAccess = null;
|
this.midiAccess = null;
|
||||||
this.selectedInputId = null;
|
this.selectedInputId = null;
|
||||||
|
|
@ -19,6 +19,9 @@ export class MIDIInput {
|
||||||
set onInputsChange(fn) { this._onInputsChange = fn; }
|
set onInputsChange(fn) { this._onInputsChange = fn; }
|
||||||
set onCC(fn) { this._onCC = fn; }
|
set onCC(fn) { this._onCC = fn; }
|
||||||
|
|
||||||
|
/** Hot-swap the engine (e.g. when the user switches synth engines). */
|
||||||
|
setEngine(engine) { this.engine = engine; }
|
||||||
|
|
||||||
_status(msg) {
|
_status(msg) {
|
||||||
console.log('[MIDI]', msg);
|
console.log('[MIDI]', msg);
|
||||||
this._onStatusChange?.(msg);
|
this._onStatusChange?.(msg);
|
||||||
|
|
@ -130,15 +133,15 @@ export class MIDIInput {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 0x90: // Note On
|
case 0x90: // Note On
|
||||||
if (data2 > 0) {
|
if (data2 > 0) {
|
||||||
this.bridge.noteOn(data1, data2 / 127);
|
this.engine.noteOn(data1, data2 / 127);
|
||||||
} else {
|
} else {
|
||||||
// Velocity 0 = note off
|
// Velocity 0 = note off
|
||||||
this.bridge.noteOff(data1);
|
this.engine.noteOff(data1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x80: // Note Off
|
case 0x80: // Note Off
|
||||||
this.bridge.noteOff(data1);
|
this.engine.noteOff(data1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xb0: // Control Change
|
case 0xb0: // Control Change
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue