From c2411b892c6544d1c9b65144d7daf8cec292ed5b Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Thu, 15 Feb 2024 11:22:31 +0100 Subject: [PATCH] Type fixes. Added new Synth_Dexed library with pitchbend fixes to third-party. --- midi_devices.hpp | 74 +++++++++++++-------------- third-party/Synth_Dexed/src/dexed.cpp | 11 ++++ third-party/Synth_Dexed/src/dexed.h | 2 + 3 files changed, 50 insertions(+), 37 deletions(-) diff --git a/midi_devices.hpp b/midi_devices.hpp index 7b5e4b7..06cf6cd 100644 --- a/midi_devices.hpp +++ b/midi_devices.hpp @@ -77,13 +77,13 @@ MIDI_NAMESPACE::SerialMIDI serialMIDI(userial MIDI_NAMESPACE::MidiInterface> usbhost_midi_serial((MIDI_NAMESPACE::SerialMIDI &)serialMIDI); #endif -void handleNoteOn(byte inChannel, uint8_t inNumber, uint8_t inVelocity); -void handleNoteOff(byte inChannel, uint8_t inNumber, uint8_t inVelocity); -void handleControlChange(byte inChannel, uint8_t inData1, uint8_t inData2); -void handleAfterTouch(byte inChannel, uint8_t inPressure); -void handlePitchBend(byte inChannel, int inPitch); -void handleProgramChange(byte inChannel, uint8_t inProgram); -void handleAfterTouchPoly(byte inChannel, uint8_t inNumber, uint8_t inVelocity); +void handleNoteOn(uint8_t inChannel, uint8_t inNumber, uint8_t inVelocity); +void handleNoteOff(uint8_t inChannel, uint8_t inNumber, uint8_t inVelocity); +void handleControlChange(uint8_t inChannel, uint8_t inData1, uint8_t inData2); +void handleAfterTouch(uint8_t inChannel, uint8_t inPressure); +void handlePitchBend(uint8_t inChannel, int inPitch); +void handleProgramChange(uint8_t inChannel, uint8_t inProgram); +void handleAfterTouchPoly(uint8_t inChannel, uint8_t inNumber, uint8_t inVelocity); void handleSystemExclusive(uint8_t *data, uint len); //void handleSystemExclusiveChunk(const uint8_t *data, uint len, bool last); void handleTimeCodeQuarterFrame(uint8_t data); @@ -103,8 +103,8 @@ void MD_sendControlChange(uint8_t channel, uint8_t cc, uint8_t value); #define MIDI_BY_USB_HOST "MIDI_USB_HOST" #define MIDI_BY_USB_HOST_SERIAL "MIDI_USB_HOST_SERIAL" -void handle_generic(byte inChannel, uint8_t inData1, uint8_t inData2, const char *midi_device, midi::MidiType event) { -//void handle_generic(byte inChannel, uint8_t inData1, uint8_t inData2, const char *midi_device, uint_8t event) { +void handle_generic(uint8_t inChannel, uint8_t inData1, uint8_t inData2, const char *midi_device, midi::MidiType event) { +//void handle_generic(uint8_t inChannel, uint8_t inData1, uint8_t inData2, const char *midi_device, uint_8t event) { char text[10]; switch (event) { @@ -585,32 +585,32 @@ void handleRealtime_generic(const char *midi_device, midi::MidiType event) { *****************************************/ #ifdef MIDI_DEVICE_DIN -void handleNoteOn_MIDI_DEVICE_DIN(byte inChannel, uint8_t inNoteNumber, uint8_t inVelocity) { +void handleNoteOn_MIDI_DEVICE_DIN(uint8_t inChannel, uint8_t inNoteNumber, uint8_t inVelocity) { handle_generic(inChannel, inNoteNumber, inVelocity, MIDI_BY_DIN, midi::NoteOn); } -void handleNoteOff_MIDI_DEVICE_DIN(byte inChannel, uint8_t inNoteNumber, uint8_t inVelocity) { +void handleNoteOff_MIDI_DEVICE_DIN(uint8_t inChannel, uint8_t inNoteNumber, uint8_t inVelocity) { handle_generic(inChannel, inNoteNumber, inVelocity, MIDI_BY_DIN, midi::NoteOff); } -void handleControlChange_MIDI_DEVICE_DIN(byte inChannel, uint8_t inData1, uint8_t inData2) { +void handleControlChange_MIDI_DEVICE_DIN(uint8_t inChannel, uint8_t inData1, uint8_t inData2) { handle_generic(inChannel, inData1, inData2, MIDI_BY_DIN, midi::ControlChange); } -void handleAfterTouch_MIDI_DEVICE_DIN(byte inChannel, uint8_t inPressure) { +void handleAfterTouch_MIDI_DEVICE_DIN(uint8_t inChannel, uint8_t inPressure) { handle_generic(inChannel, inPressure, '\0', MIDI_BY_DIN, midi::AfterTouchChannel); } -void handlePitchBend_MIDI_DEVICE_DIN(byte inChannel, int inPitch) { +void handlePitchBend_MIDI_DEVICE_DIN(uint8_t inChannel, int inPitch) { inPitch += 0x2000; handle_generic(inChannel, (inPitch & 0x07), (inPitch >> 0x07), MIDI_BY_DIN, midi::PitchBend); } -void handleProgramChange_MIDI_DEVICE_DIN(byte inChannel, uint8_t inProgram) { +void handleProgramChange_MIDI_DEVICE_DIN(uint8_t inChannel, uint8_t inProgram) { handle_generic(inChannel, inProgram, '\0', MIDI_BY_DIN, midi::ProgramChange); } -void handleAfterTouchPoly_MIDI_DEVICE_DIN(byte inChannel, uint8_t inNoteNumber, uint8_t inVelocity) { +void handleAfterTouchPoly_MIDI_DEVICE_DIN(uint8_t inChannel, uint8_t inNoteNumber, uint8_t inVelocity) { handle_generic(inChannel, inNoteNumber, inVelocity, MIDI_BY_DIN, midi::AfterTouchPoly); } @@ -690,32 +690,32 @@ void handleSystemReset_MIDI_DEVICE_DIN(void) { MIDI_DEVICE_USB_HOST *****************************************/ #ifdef MIDI_DEVICE_USB_HOST -void handleNoteOn_MIDI_DEVICE_USB_HOST(byte inChannel, uint8_t inNoteNumber, uint8_t inVelocity) { +void handleNoteOn_MIDI_DEVICE_USB_HOST(uint8_t inChannel, uint8_t inNoteNumber, uint8_t inVelocity) { handle_generic(inChannel, inNoteNumber, inVelocity, MIDI_BY_USB_HOST, midi::NoteOn); } -void handleNoteOff_MIDI_DEVICE_USB_HOST(byte inChannel, uint8_t inNoteNumber, uint8_t inVelocity) { +void handleNoteOff_MIDI_DEVICE_USB_HOST(uint8_t inChannel, uint8_t inNoteNumber, uint8_t inVelocity) { handle_generic(inChannel, inNoteNumber, inVelocity, MIDI_BY_USB_HOST, midi::NoteOff); } -void handleControlChange_MIDI_DEVICE_USB_HOST(byte inChannel, uint8_t inData1, uint8_t inData2) { +void handleControlChange_MIDI_DEVICE_USB_HOST(uint8_t inChannel, uint8_t inData1, uint8_t inData2) { handle_generic(inChannel, inData1, inData2, MIDI_BY_USB_HOST, midi::ControlChange); } -void handleAfterTouch_MIDI_DEVICE_USB_HOST(byte inChannel, uint8_t inPressure) { +void handleAfterTouch_MIDI_DEVICE_USB_HOST(uint8_t inChannel, uint8_t inPressure) { handle_generic(inChannel, inPressure, '\0', MIDI_BY_USB_HOST, midi::AfterTouchChannel); } -void handlePitchBend_MIDI_DEVICE_USB_HOST(byte inChannel, int inPitch) { +void handlePitchBend_MIDI_DEVICE_USB_HOST(uint8_t inChannel, int inPitch) { inPitch += 0x2000; handle_generic(inChannel, (inPitch & 0x07), (inPitch >> 0x07), MIDI_BY_USB_HOST, midi::PitchBend); } -void handleProgramChange_MIDI_DEVICE_USB_HOST(byte inChannel, uint8_t inProgram) { +void handleProgramChange_MIDI_DEVICE_USB_HOST(uint8_t inChannel, uint8_t inProgram) { handle_generic(inChannel, inProgram, '\0', MIDI_BY_USB_HOST, midi::ProgramChange); } -void handleAfterTouchPoly_MIDI_DEVICE_USB_HOST(byte inChannel, uint8_t inNoteNumber, uint8_t inVelocity) { +void handleAfterTouchPoly_MIDI_DEVICE_USB_HOST(uint8_t inChannel, uint8_t inNoteNumber, uint8_t inVelocity) { handle_generic(inChannel, inNoteNumber, inVelocity, MIDI_BY_USB_HOST, midi::AfterTouchPoly); } @@ -793,32 +793,32 @@ void handleSystemReset_MIDI_DEVICE_USB_HOST(void) { #endif // MIDI_DEVICE_USB_HOST #ifdef MIDI_DEVICE_USB_HOST_SERIAL -void handleNoteOn_MIDI_DEVICE_USB_HOST_SERIAL(byte inChannel, uint8_t inNoteNumber, uint8_t inVelocity) { +void handleNoteOn_MIDI_DEVICE_USB_HOST_SERIAL(uint8_t inChannel, uint8_t inNoteNumber, uint8_t inVelocity) { handle_generic(inChannel, inNoteNumber, inVelocity, MIDI_BY_USB_HOST_SERIAL, midi::NoteOn); } -void handleNoteOff_MIDI_DEVICE_USB_HOST_SERIAL(byte inChannel, uint8_t inNoteNumber, uint8_t inVelocity) { +void handleNoteOff_MIDI_DEVICE_USB_HOST_SERIAL(uint8_t inChannel, uint8_t inNoteNumber, uint8_t inVelocity) { handle_generic(inChannel, inNoteNumber, inVelocity, MIDI_BY_USB_HOST_SERIAL, midi::NoteOff); } -void handleControlChange_MIDI_DEVICE_USB_HOST_SERIAL(byte inChannel, uint8_t inData1, uint8_t inData2) { +void handleControlChange_MIDI_DEVICE_USB_HOST_SERIAL(uint8_t inChannel, uint8_t inData1, uint8_t inData2) { handle_generic(inChannel, inData1, inData2, MIDI_BY_USB_HOST_SERIAL, midi::ControlChange); } -void handleAfterTouch_MIDI_DEVICE_USB_HOST_SERIAL(byte inChannel, uint8_t inPressure) { +void handleAfterTouch_MIDI_DEVICE_USB_HOST_SERIAL(uint8_t inChannel, uint8_t inPressure) { handle_generic(inChannel, inPressure, '\0', MIDI_BY_USB_HOST_SERIAL, midi::AfterTouchChannel); } -void handlePitchBend_MIDI_DEVICE_USB_HOST_SERIAL(byte inChannel, int inPitch) { +void handlePitchBend_MIDI_DEVICE_USB_HOST_SERIAL(uint8_t inChannel, int inPitch) { 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, uint8_t inProgram) { +void handleProgramChange_MIDI_DEVICE_USB_HOST_SERIAL(uint8_t inChannel, uint8_t inProgram) { handle_generic(inChannel, inProgram, '\0', MIDI_BY_USB_HOST_SERIAL, midi::ProgramChange); } -void handleAfterTouchPoly_MIDI_DEVICE_USB_HOST_SERIAL(byte inChannel, uint8_t inNoteNumber, uint8_t inVelocity) { +void handleAfterTouchPoly_MIDI_DEVICE_USB_HOST_SERIAL(uint8_t inChannel, uint8_t inNoteNumber, uint8_t inVelocity) { handle_generic(inChannel, inNoteNumber, inVelocity, MIDI_BY_USB_HOST_SERIAL, midi::AfterTouchPoly); } @@ -898,32 +898,32 @@ void handleSystemReset_MIDI_DEVICE_USB_HOST_SERIAL(void) { MIDI_DEVICE_USB *****************************************/ #ifdef MIDI_DEVICE_USB -void handleNoteOn_MIDI_DEVICE_USB(byte inChannel, uint8_t inNoteNumber, uint8_t inVelocity) { +void handleNoteOn_MIDI_DEVICE_USB(uint8_t inChannel, uint8_t inNoteNumber, uint8_t inVelocity) { handle_generic(inChannel, inNoteNumber, inVelocity, MIDI_BY_USB, midi::NoteOn); } -void handleNoteOff_MIDI_DEVICE_USB(byte inChannel, uint8_t inNoteNumber, uint8_t inVelocity) { +void handleNoteOff_MIDI_DEVICE_USB(uint8_t inChannel, uint8_t inNoteNumber, uint8_t inVelocity) { handle_generic(inChannel, inNoteNumber, inVelocity, MIDI_BY_USB, midi::NoteOff); } -void handleControlChange_MIDI_DEVICE_USB(byte inChannel, uint8_t inData1, uint8_t inData2) { +void handleControlChange_MIDI_DEVICE_USB(uint8_t inChannel, uint8_t inData1, uint8_t inData2) { handle_generic(inChannel, inData1, inData2, MIDI_BY_USB, midi::ControlChange); } -void handleAfterTouch_MIDI_DEVICE_USB(byte inChannel, uint8_t inPressure) { +void handleAfterTouch_MIDI_DEVICE_USB(uint8_t inChannel, uint8_t inPressure) { handle_generic(inChannel, inPressure, '\0', MIDI_BY_USB, midi::AfterTouchChannel); } -void handlePitchBend_MIDI_DEVICE_USB(byte inChannel, int inPitch) { +void handlePitchBend_MIDI_DEVICE_USB(uint8_t inChannel, int inPitch) { inPitch += 0x2000; handle_generic(inChannel, (inPitch & 0x07), (inPitch >> 0x07), MIDI_BY_USB, midi::PitchBend); } -void handleProgramChange_MIDI_DEVICE_USB(byte inChannel, uint8_t inProgram) { +void handleProgramChange_MIDI_DEVICE_USB(uint8_t inChannel, uint8_t inProgram) { handle_generic(inChannel, inProgram, '\0', MIDI_BY_USB, midi::ProgramChange); } -void handleAfterTouchPoly_MIDI_DEVICE_USB(byte inChannel, uint8_t inNoteNumber, uint8_t inVelocity) { +void handleAfterTouchPoly_MIDI_DEVICE_USB(uint8_t inChannel, uint8_t inNoteNumber, uint8_t inVelocity) { handle_generic(inChannel, inNoteNumber, inVelocity, MIDI_BY_USB, midi::AfterTouchPoly); } diff --git a/third-party/Synth_Dexed/src/dexed.cpp b/third-party/Synth_Dexed/src/dexed.cpp index 942e763..cf501f8 100644 --- a/third-party/Synth_Dexed/src/dexed.cpp +++ b/third-party/Synth_Dexed/src/dexed.cpp @@ -1030,11 +1030,22 @@ uint8_t Dexed::getAftertouch(void) return (controllers.aftertouch_cc); } +void Dexed::setPitchbend(uint8_t value1, uint8_t value2) +{ + setPitchbend(uint16_t(((value2 & 0x7f) << 7) | (value1 & 0x7f))); +} + void Dexed::setPitchbend(int16_t value) { value = constrain(value, -8192, 8191); controllers.values_[kControllerPitch] = value + 0x2000; // -8192 to +8191 --> 0 to 16383 + setPitchbend(uint16_t(value + 0x2000)); // -8192 to +8191 --> 0 to 16383 +} + +void Dexed::setPitchbend(uint16_t value) +{ + controllers.values_[kControllerPitch] = (value & 0x3fff); } int16_t Dexed::getPitchbend(void) diff --git a/third-party/Synth_Dexed/src/dexed.h b/third-party/Synth_Dexed/src/dexed.h index a5e04df..8d91150 100644 --- a/third-party/Synth_Dexed/src/dexed.h +++ b/third-party/Synth_Dexed/src/dexed.h @@ -242,7 +242,9 @@ class Dexed uint8_t getFootController(void); void setAftertouch(uint8_t value); uint8_t getAftertouch(void); + void setPitchbend(uint8_t value1, uint8_t value2); void setPitchbend(int16_t value); + void setPitchbend(uint16_t value); int16_t getPitchbend(void); void setPitchbendRange(uint8_t range); uint8_t getPitchbendRange(void);