From b07deec428658e577e20e48f6b85f5e34d22777b Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Fri, 8 Dec 2023 10:57:07 +0100 Subject: [PATCH 1/2] Fix for MIDI incoming handling for USB-MIDI-Serial. --- midi_devices.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/midi_devices.hpp b/midi_devices.hpp index c8ccda4..b474c2f 100644 --- a/midi_devices.hpp +++ b/midi_devices.hpp @@ -67,9 +67,12 @@ USBHub hub3(usb_host); #elif NUM_HUBS_MIDI_DEVICE_USB_HOST_SERIAL < 5 USBHub hub4(usb_host); #endif -USBSerial_BigBuffer userial(usb_host, 1); -MIDI_NAMESPACE::SerialMIDI serialMIDI(userial); -MIDI_NAMESPACE::MidiInterface> usbhost_midi_serial((MIDI_NAMESPACE::SerialMIDI &)serialMIDI); +//USBSerial_BigBuffer userial(usb_host, 1); +//MIDI_NAMESPACE::SerialMIDI serialMIDI(userial); +//MIDI_NAMESPACE::MidiInterface> usbhost_midi_serial((MIDI_NAMESPACE::SerialMIDI &)serialMIDI); +USBSerial userial(usb_host); +MIDI_NAMESPACE::SerialMIDI serialMIDI(userial); +MIDI_NAMESPACE::MidiInterface> usbhost_midi_serial((MIDI_NAMESPACE::SerialMIDI &)serialMIDI); #endif void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity); From 380210a05f2ad6becddcabb29229c0f019e90c6d Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Sat, 9 Dec 2023 15:25:22 +0100 Subject: [PATCH 2/2] Fix for pitchbend handling. --- MicroDexed.ino | 10 +++++----- midi_devices.hpp | 22 +++++++++++++--------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index 026bced..3238ee4 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -155,10 +155,10 @@ AudioConnection patchCord[] = { { reverb_mixer_l, 0, reverb, 1 }, { reverb, 0, master_mixer_r, MASTER_MIX_CH_REVERB }, { reverb, 1, master_mixer_l, MASTER_MIX_CH_REVERB }, -// { master_mixer_r, compressor_r }, -// { master_mixer_l, compressor_l }, -// { compressor_r, volume_r }, -// { compressor_l, volume_l }, + // { master_mixer_r, compressor_r }, + // { master_mixer_l, compressor_l }, + // { compressor_r, volume_r }, + // { compressor_l, volume_l }, { master_mixer_r, volume_r }, { master_mixer_l, volume_l }, { volume_r, 0, stereo2mono, 0 }, @@ -1251,7 +1251,7 @@ void handleAfterTouch(byte inChannel, byte inPressure) { void handlePitchBend(byte inChannel, int inPitch) { for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) { if (checkMidiChannel(inChannel, instance_id)) { - MicroDexed[instance_id]->setPitchbend(inPitch); + MicroDexed[instance_id]->setPitchbend(inPitch - 0x2000); } } } diff --git a/midi_devices.hpp b/midi_devices.hpp index b474c2f..e1ede66 100644 --- a/midi_devices.hpp +++ b/midi_devices.hpp @@ -122,7 +122,7 @@ void handle_generic(byte inChannel, byte inData1, byte inData2, const char *midi strlcpy(text, "Mono AT", sizeof(text)); break; case midi::PitchBend: - handlePitchBend(inChannel, inData1); + handlePitchBend(inChannel, (inData2 << 7) | inData1); strlcpy(text, "PB", sizeof(text)); break; case midi::ProgramChange: @@ -158,7 +158,7 @@ void handle_generic(byte inChannel, byte inData1, byte inData2, const char *midi usbMIDI.sendAfterTouch(inData1, inChannel); break; case midi::PitchBend: - usbMIDI.sendPitchBend(inData1, inChannel); + usbMIDI.sendPitchBend((inData2 << 7) | inData1, inChannel); break; case midi::ProgramChange: usbMIDI.sendProgramChange(inData1, inChannel); @@ -191,7 +191,7 @@ void handle_generic(byte inChannel, byte inData1, byte inData2, const char *midi midi_serial.sendAfterTouch(inData1, inChannel); break; case midi::PitchBend: - midi_serial.sendPitchBend(inData1, inChannel); + midi_serial.sendPitchBend((inData2 << 7) | inData1, inChannel); break; case midi::ProgramChange: midi_serial.sendProgramChange(inData1, inChannel); @@ -224,7 +224,7 @@ void handle_generic(byte inChannel, byte inData1, byte inData2, const char *midi midi_usb.sendAfterTouch(inData1, inChannel); break; case midi::PitchBend: - midi_usb.sendPitchBend(inData1, inChannel); + midi_usb.sendPitchBend((inData2 << 7) | inData1, inChannel); break; case midi::ProgramChange: midi_usb.sendProgramChange(inData1, inChannel); @@ -257,7 +257,7 @@ void handle_generic(byte inChannel, byte inData1, byte inData2, const char *midi usbhost_midi_serial.sendAfterTouch(inData1, inChannel); break; case midi::PitchBend: - usbhost_midi_serial.sendPitchBend(inData1, inChannel); + usbhost_midi_serial.sendPitchBend((inData2 << 7) | inData1, inChannel); break; case midi::ProgramChange: usbhost_midi_serial.sendProgramChange(inData1, inChannel); @@ -599,7 +599,8 @@ void handleAfterTouch_MIDI_DEVICE_DIN(byte inChannel, byte inPressure) { } void handlePitchBend_MIDI_DEVICE_DIN(byte inChannel, int inPitch) { - handle_generic(inChannel, inPitch, '\0', MIDI_BY_DIN, midi::PitchBend); + inPitch += 0x2000; + handle_generic(inChannel, (inPitch & 0x07), (inPitch >> 0x07), MIDI_BY_DIN, midi::PitchBend); } void handleProgramChange_MIDI_DEVICE_DIN(byte inChannel, byte inProgram) { @@ -703,7 +704,8 @@ void handleAfterTouch_MIDI_DEVICE_USB_HOST(byte inChannel, byte inPressure) { } void handlePitchBend_MIDI_DEVICE_USB_HOST(byte inChannel, int inPitch) { - handle_generic(inChannel, inPitch, '\0', MIDI_BY_USB_HOST, midi::PitchBend); + inPitch += 0x2000; + handle_generic(inChannel, (inPitch & 0x07), (inPitch >> 0x07), MIDI_BY_USB_HOST, midi::PitchBend); } void handleProgramChange_MIDI_DEVICE_USB_HOST(byte inChannel, byte inProgram) { @@ -805,7 +807,8 @@ void handleAfterTouch_MIDI_DEVICE_USB_HOST_SERIAL(byte inChannel, byte inPressur } void handlePitchBend_MIDI_DEVICE_USB_HOST_SERIAL(byte inChannel, int inPitch) { - handle_generic(inChannel, inPitch, '\0', MIDI_BY_USB_HOST_SERIAL, midi::PitchBend); + inPitch += 0x2000; + handle_generic(inChannel, (inPitch & 0x07), (inPitch >> 0x07), MIDI_BY_USB_HOST_SERIAL, midi::PitchBend); } void handleProgramChange_MIDI_DEVICE_USB_HOST_SERIAL(byte inChannel, byte inProgram) { @@ -909,7 +912,8 @@ void handleAfterTouch_MIDI_DEVICE_USB(byte inChannel, byte inPressure) { } void handlePitchBend_MIDI_DEVICE_USB(byte inChannel, int inPitch) { - handle_generic(inChannel, inPitch, '\0', MIDI_BY_USB, midi::PitchBend); + inPitch += 0x2000; + handle_generic(inChannel, (inPitch & 0x07), (inPitch >> 0x07), MIDI_BY_USB, midi::PitchBend); } void handleProgramChange_MIDI_DEVICE_USB(byte inChannel, byte inProgram) {