Actualiser src/utils/midiHelper.js
Deploy to home / deploy (push) Successful in 11s

This commit is contained in:
2026-08-10 21:22:42 +02:00
parent 21117736da
commit ac03abc07d
+6 -1
View File
@@ -81,7 +81,7 @@ export const changeMidiInputPort = (portId) => {
});
};
export const changeKeyboardInputPort = (portId) => {
export const changeKeyboardInputPort = (portId, channel = 1) => {
if (!navigator.requestMIDIAccess) return;
navigator.requestMIDIAccess({ sysex: true }).then((midiAccess) => {
@@ -97,6 +97,11 @@ export const changeKeyboardInputPort = (portId) => {
if (selectedKeyboardInput) {
selectedKeyboardInput.onmidimessage = (event) => {
const data = Array.from(event.data);
const command = data[0] & 0xF0;
if (command >= 0x80 && command <= 0xE0) {
data[0] = command | ((channel - 1) & 0x0F);
}
if (selectedMidiOutput) {
selectedMidiOutput.send(data);