From 78267f9c9eb0897ccb48dac7e12a2ca2ef09cd62 Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Sun, 30 Jul 2023 23:44:49 +0200 Subject: [PATCH] add midi channel to note function --- src/IO/MidiConnection.ts | 15 ++++++++------- src/main.ts | 2 -- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/IO/MidiConnection.ts b/src/IO/MidiConnection.ts index 46e0dee..e51793f 100644 --- a/src/IO/MidiConnection.ts +++ b/src/IO/MidiConnection.ts @@ -57,22 +57,23 @@ export class MidiConnection{ console.log(`${index + 1}. ${output.name}`); }); } - - public sendMidiNote(noteNumber: number, velocity: number, durationMs: number): void { + + + public sendMidiNote(noteNumber: number, channel: number, velocity: number, durationMs: number): void { const output = this.midiOutputs[this.currentOutputIndex]; if (output) { - const noteOnMessage = [0x90, noteNumber, velocity]; - const noteOffMessage = [0x80, noteNumber, 0]; - + const noteOnMessage = [0x90 + channel, noteNumber, velocity]; + const noteOffMessage = [0x80 + channel, noteNumber, 0]; + // Send Note On output.send(noteOnMessage); - + // Schedule Note Off const timeoutId = setTimeout(() => { output.send(noteOffMessage); delete this.scheduledNotes[noteNumber]; }, durationMs); - + this.scheduledNotes[noteNumber] = timeoutId; } else { console.error('MIDI output not available.'); diff --git a/src/main.ts b/src/main.ts index d6238a4..bd2281a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -249,9 +249,7 @@ export class Editor { (keycode, index) => { if (event.keyCode === keycode) { event.preventDefault(); - // Check if Ctrl is pressed as well if (event.ctrlKey) { - // We trigger a script if ctrl is pressed this.api.script(keycode - 111) } else { this.changeToLocalBuffer(index);