Type fixes.

Added new Synth_Dexed library with pitchbend fixes to third-party.
dev
Holger Wirtz 9 months ago
parent 1fe784196e
commit c2411b892c
  1. 74
      midi_devices.hpp
  2. 11
      third-party/Synth_Dexed/src/dexed.cpp
  3. 2
      third-party/Synth_Dexed/src/dexed.h

@ -77,13 +77,13 @@ MIDI_NAMESPACE::SerialMIDI<USBSerial, CustomBaudRateSettings> serialMIDI(userial
MIDI_NAMESPACE::MidiInterface<MIDI_NAMESPACE::SerialMIDI<USBSerial, CustomBaudRateSettings>> usbhost_midi_serial((MIDI_NAMESPACE::SerialMIDI<USBSerial, CustomBaudRateSettings> &)serialMIDI); MIDI_NAMESPACE::MidiInterface<MIDI_NAMESPACE::SerialMIDI<USBSerial, CustomBaudRateSettings>> usbhost_midi_serial((MIDI_NAMESPACE::SerialMIDI<USBSerial, CustomBaudRateSettings> &)serialMIDI);
#endif #endif
void handleNoteOn(byte inChannel, uint8_t inNumber, uint8_t inVelocity); void handleNoteOn(uint8_t inChannel, uint8_t inNumber, uint8_t inVelocity);
void handleNoteOff(byte inChannel, uint8_t inNumber, uint8_t inVelocity); void handleNoteOff(uint8_t inChannel, uint8_t inNumber, uint8_t inVelocity);
void handleControlChange(byte inChannel, uint8_t inData1, uint8_t inData2); void handleControlChange(uint8_t inChannel, uint8_t inData1, uint8_t inData2);
void handleAfterTouch(byte inChannel, uint8_t inPressure); void handleAfterTouch(uint8_t inChannel, uint8_t inPressure);
void handlePitchBend(byte inChannel, int inPitch); void handlePitchBend(uint8_t inChannel, int inPitch);
void handleProgramChange(byte inChannel, uint8_t inProgram); void handleProgramChange(uint8_t inChannel, uint8_t inProgram);
void handleAfterTouchPoly(byte inChannel, uint8_t inNumber, uint8_t inVelocity); void handleAfterTouchPoly(uint8_t inChannel, uint8_t inNumber, uint8_t inVelocity);
void handleSystemExclusive(uint8_t *data, uint len); void handleSystemExclusive(uint8_t *data, uint len);
//void handleSystemExclusiveChunk(const uint8_t *data, uint len, bool last); //void handleSystemExclusiveChunk(const uint8_t *data, uint len, bool last);
void handleTimeCodeQuarterFrame(uint8_t data); 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 "MIDI_USB_HOST"
#define MIDI_BY_USB_HOST_SERIAL "MIDI_USB_HOST_SERIAL" #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(uint8_t 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, uint_8t event) {
char text[10]; char text[10];
switch (event) { switch (event) {
@ -585,32 +585,32 @@ void handleRealtime_generic(const char *midi_device, midi::MidiType event) {
*****************************************/ *****************************************/
#ifdef MIDI_DEVICE_DIN #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); 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); 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); 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); 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; inPitch += 0x2000;
handle_generic(inChannel, (inPitch & 0x07), (inPitch >> 0x07), MIDI_BY_DIN, midi::PitchBend); 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); 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); handle_generic(inChannel, inNoteNumber, inVelocity, MIDI_BY_DIN, midi::AfterTouchPoly);
} }
@ -690,32 +690,32 @@ void handleSystemReset_MIDI_DEVICE_DIN(void) {
MIDI_DEVICE_USB_HOST MIDI_DEVICE_USB_HOST
*****************************************/ *****************************************/
#ifdef 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); 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); 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); 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); 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; inPitch += 0x2000;
handle_generic(inChannel, (inPitch & 0x07), (inPitch >> 0x07), MIDI_BY_USB_HOST, midi::PitchBend); 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); 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); 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 #endif // MIDI_DEVICE_USB_HOST
#ifdef MIDI_DEVICE_USB_HOST_SERIAL #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); 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); 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); 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); 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; inPitch += 0x2000;
handle_generic(inChannel, (inPitch & 0x07), (inPitch >> 0x07), MIDI_BY_USB_HOST_SERIAL, midi::PitchBend); 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); 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); 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 MIDI_DEVICE_USB
*****************************************/ *****************************************/
#ifdef 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); 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); 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); 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); 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; inPitch += 0x2000;
handle_generic(inChannel, (inPitch & 0x07), (inPitch >> 0x07), MIDI_BY_USB, midi::PitchBend); 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); 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); handle_generic(inChannel, inNoteNumber, inVelocity, MIDI_BY_USB, midi::AfterTouchPoly);
} }

@ -1030,11 +1030,22 @@ uint8_t Dexed::getAftertouch(void)
return (controllers.aftertouch_cc); 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) void Dexed::setPitchbend(int16_t value)
{ {
value = constrain(value, -8192, 8191); value = constrain(value, -8192, 8191);
controllers.values_[kControllerPitch] = value + 0x2000; // -8192 to +8191 --> 0 to 16383 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) int16_t Dexed::getPitchbend(void)

@ -242,7 +242,9 @@ class Dexed
uint8_t getFootController(void); uint8_t getFootController(void);
void setAftertouch(uint8_t value); void setAftertouch(uint8_t value);
uint8_t getAftertouch(void); uint8_t getAftertouch(void);
void setPitchbend(uint8_t value1, uint8_t value2);
void setPitchbend(int16_t value); void setPitchbend(int16_t value);
void setPitchbend(uint16_t value);
int16_t getPitchbend(void); int16_t getPitchbend(void);
void setPitchbendRange(uint8_t range); void setPitchbendRange(uint8_t range);
uint8_t getPitchbendRange(void); uint8_t getPitchbendRange(void);

Loading…
Cancel
Save