diff --git a/UI.hpp b/UI.hpp index 570d0cb..c2597b8 100644 --- a/UI.hpp +++ b/UI.hpp @@ -4854,17 +4854,10 @@ void UI_func_velocity_level(uint8_t param) { } void UI_update_instance_icons() { -#ifdef TESTDISPLAY20x4 - display.setCursor(18, 0); - display.write(0); //Icon for first instance - display.setCursor(19, 0); - display.write(1); //Icon for second instance -#else display.setCursor(14, 0); display.write(0); //Icon for first instance display.setCursor(15, 0); display.write(1); //Icon for second instance -#endif } void UI_func_voice_select(uint8_t param) { @@ -4872,12 +4865,6 @@ void UI_func_voice_select(uint8_t param) { if (LCDML.FUNC_setup()) // ****** SETUP ********* { -#ifdef TESTDISPLAY20x4 - display.setCursor(0, 3); - display.print("MENU"); - display.setCursor(17, 3); - display.print("+/-"); -#endif encoderDir[ENC_R].reset(); lcd_active_instance_number(selected_instance_id); @@ -5029,26 +5016,7 @@ void UI_func_voice_select(uint8_t param) { display.show(0, 0, 2, configuration.dexed[selected_instance_id].bank); display.show(1, 0, 2, configuration.dexed[selected_instance_id].voice + 1); -#ifdef TESTDISPLAY20x4 - string_toupper(bank_name); - display.show(0, 4, 8, bank_name); - string_toupper(voice_name); - display.show(1, 4, 10, voice_name); - switch (menu_voice_select) { - case MENU_VOICE_BANK: - display.show(0, 3, 1, "["); - display.show(0, 12, 1, "]"); - display.show(1, 3, 1, " "); - display.show(1, 14, 1, " "); - break; - case MENU_VOICE_SOUND: - display.show(0, 3, 1, " "); - display.show(0, 12, 1, " "); - display.show(1, 3, 1, "["); - display.show(1, 14, 1, "]"); - break; - } -#else + string_toupper(bank_name); display.show(0, 3, 8, bank_name); display.show(0, 12, 1, " "); //forced because this char does not clear after fav-search (because the bank name is one char to short to do it). @@ -5069,9 +5037,10 @@ void UI_func_voice_select(uint8_t param) { display.show(1, 13, 1, "]"); break; } -#endif + draw_favorite_icon(configuration.dexed[selected_instance_id].bank, configuration.dexed[selected_instance_id].voice, selected_instance_id); } + if (LCDML.FUNC_close()) // ****** STABLE END ********* { lcd_special_chars(SCROLLBAR); @@ -6386,7 +6355,7 @@ void display_float(float var, uint8_t size_number, uint8_t size_fraction, bool z if (brackets == true) { char tmp[LCD_cols + 1]; - strlcpy(tmp, s,sizeof(tmp)); + strlcpy(tmp, s, sizeof(tmp)); snprintf_P(s, sizeof(s), PSTR("[%s]"), tmp); } @@ -6921,18 +6890,10 @@ void draw_favorite_icon(uint8_t b, uint8_t v, uint8_t instance_id) { if (sd_card > 0) { snprintf_P(tmp, sizeof(tmp), PSTR("/%s/%d/%d.fav"), FAV_CONFIG_PATH, b, v); if (SD.exists(tmp)) { //is Favorite -#ifdef TESTDISPLAY20x4 - display.setCursor(17, 0); -#else display.setCursor(13, 0); -#endif display.write(2); //fav symbol } else { // it was not a favorite -#ifdef TESTDISPLAY20x4 - display.setCursor(17, 0); -#else display.setCursor(13, 0); -#endif display.print(" "); } } @@ -6988,11 +6949,7 @@ void save_favorite(uint8_t b, uint8_t v, uint8_t instance_id) { myFav = SD.open(tmp, FILE_WRITE); myFav.close(); Serial.println(F("Favorite saved...")); -#ifdef TESTDISPLAY20x4 - display.setCursor(17, 0); -#else display.setCursor(13, 0); -#endif display.write(2); //fav symbol #ifdef DEBUG Serial.println(F("Added to Favorites...")); @@ -7015,11 +6972,7 @@ void save_favorite(uint8_t b, uint8_t v, uint8_t instance_id) { Serial.println(F("Removed folder since no voice in bank flagged as favorite any more")); #endif } -#ifdef TESTDISPLAY20x4 - display.setCursor(17, 0); -#else display.setCursor(13, 0); -#endif display.print(" "); //remove fav symbol #ifdef DEBUG Serial.println(F("Removed from Favorites...")); diff --git a/addon/SD/PERFORMANCE/0/performance.json b/addon/SD/PERFORMANCE/0/performance.json index 5c3f71d..4cdaadf 100644 --- a/addon/SD/PERFORMANCE/0/performance.json +++ b/addon/SD/PERFORMANCE/0/performance.json @@ -1,27 +1,3 @@ { - "name": [ - 73, - 78, - 73, - 84, - 32, - 80, - 101, - 114, - 102, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ] -} \ No newline at end of file + "name": "MD-Perf1" +} diff --git a/config.h b/config.h index 605f04e..448317b 100644 --- a/config.h +++ b/config.h @@ -92,7 +92,7 @@ //************************************************************************************************* //* DEBUG OUTPUT SETTINGS //************************************************************************************************* -//#define DEBUG 1 +#define DEBUG 1 //#define DEBUG_SHOW_JSON 1 #define SERIAL_SPEED 230400 #define SHOW_XRUN 1 @@ -231,7 +231,6 @@ #define ENABLE_LCD_UI 1 #define STANDARD_LCD_I2C //#define OLED_SPI -//#define TESTDISPLAY20x4 //Currently for testing I2C Display 20x4 aka type "2004" // LCD Display //I2C_DISPLAY only @@ -239,13 +238,8 @@ #define LCD_I2C_ADDRESS 0x27 //#define LCD_I2C_ADDRESS 0x3f //Display size, must be set for U8X8 as well -#ifdef TESTDISPLAY20x4 -#define LCD_cols 20 -#define LCD_rows 4 -#else #define LCD_cols 16 #define LCD_rows 2 -#endif #define I2C_DISPLAY // [I2C] SCL: Pin 19, SDA: Pin 18 (https://www.pjrc.com/teensy/td_libs_Wire.html) diff --git a/disp_plus.h b/disp_plus.h index cc75cf9..b082e9d 100644 --- a/disp_plus.h +++ b/disp_plus.h @@ -28,61 +28,58 @@ #include "config.h" -#define STRING_BUFFER_SIZE LCD_cols+1 +#define STRING_BUFFER_SIZE LCD_cols + 1 -template -class Disp_Plus : public T -{ - public: +template +class Disp_Plus : public T { +public: - using T::T; + using T::T; - void show(uint8_t y, uint8_t x, uint8_t fs, const char *str) - { - _show(y, x, fs, str, false, false); - } + void show(uint8_t y, uint8_t x, uint8_t fs, const char *str) { + _show(y, x, fs, str, false, false); + } - void show(uint8_t y, uint8_t x, uint8_t fs, long num) - { - char _buf10[STRING_BUFFER_SIZE]; + void show(uint8_t y, uint8_t x, uint8_t fs, long num) { + char _buf10[STRING_BUFFER_SIZE]; - _show(y, x, fs, itoa(num, _buf10, 10), true, true); - } + _show(y, x, fs, itoa(num, _buf10, 10), true, true); + } - private: - void _show(uint8_t pos_y, uint8_t pos_x, uint8_t field_size, const char *str, bool justify_right, bool fill_zero) +private: + void _show(uint8_t pos_y, uint8_t pos_x, uint8_t field_size, const char *str, bool justify_right, bool fill_zero) { { - { - char tmp[STRING_BUFFER_SIZE]; - char *s = tmp; - uint8_t l = strlen(str); + char tmp[STRING_BUFFER_SIZE]; + char *s = tmp; + uint8_t l = strlen(str); - memset(tmp, 0, sizeof(tmp)); - if (fill_zero == true) - memset(tmp, '0', field_size); - else - memset(tmp, 0x20, field_size); // blank + memset(tmp, 0, sizeof(tmp)); + if (fill_zero == true) + memset(tmp, '0', field_size); + else + memset(tmp, 0x20, field_size); // blank - if (l > field_size) - l = field_size; + if (l > field_size) + l = field_size; - if (justify_right == true) - s += field_size - l; + if (justify_right == true) + s += field_size - l; - strlcpy(s, str, l); + strncpy(s, str, l); + s[l] = '\0'; - //setCursor(pos_x * getMaxCharWidth(), pos_y * getMaxCharHeight()); - this->setCursor(pos_x, pos_y ); - this->print(tmp); + //setCursor(pos_x * getMaxCharWidth(), pos_y * getMaxCharHeight()); + this->setCursor(pos_x, pos_y); + this->print(tmp); #ifdef DEBUG - Serial.print(pos_y, DEC); - Serial.print(F("/")); - Serial.print(pos_x, DEC); - Serial.print(F(": [")); - Serial.print(tmp); - Serial.println(F("]")); + Serial.print(pos_y, DEC); + Serial.print(F("/")); + Serial.print(pos_x, DEC); + Serial.print(F(": [")); + Serial.print(tmp); + Serial.println(F("]")); #endif - } } + } }; diff --git a/midi_devices.hpp b/midi_devices.hpp index 8d124b4..a4076af 100644 --- a/midi_devices.hpp +++ b/midi_devices.hpp @@ -33,9 +33,8 @@ extern config_t configuration; #endif // override default sysex size settings -struct MicroDexedSettings : public midi::DefaultSettings -{ - static const unsigned SysExMaxSize = 4104; // Accept SysEx messages up to 1024 bytes long. +struct MicroDexedSettings : public midi::DefaultSettings { + static const unsigned SysExMaxSize = 4104; // Accept SysEx messages up to 1024 bytes long. }; #ifdef MIDI_DEVICE_DIN @@ -71,38 +70,37 @@ void MD_sendControlChange(uint8_t channel, uint8_t cc, uint8_t value); #define MIDI_BY_USB_HOST "MIDI_USB_HOST" #define MIDI_BY_USB "USB_MIDI" -void handle_generic(byte inChannel, byte inData1, byte inData2, const char *midi_device, midi::MidiType event) -{ +void handle_generic(byte inChannel, byte inData1, byte inData2, const char *midi_device, midi::MidiType event) { char text[10]; - switch(event) { + switch (event) { case midi::NoteOn: handleNoteOn(inChannel, inData1, inData2); - strlcpy(text, "NoteOn",sizeof(text)); + strlcpy(text, "NoteOn", sizeof(text)); break; case midi::NoteOff: handleNoteOff(inChannel, inData1, inData2); - strlcpy(text, "NoteOff",sizeof(text)); + strlcpy(text, "NoteOff", sizeof(text)); break; case midi::ControlChange: handleControlChange(inChannel, inData1, inData2); - strlcpy(text, "CC",sizeof(text)); + strlcpy(text, "CC", sizeof(text)); break; case midi::AfterTouchChannel: handleAfterTouch(inChannel, inData1); - strlcpy(text, "Mono AT",sizeof(text)); + strlcpy(text, "Mono AT", sizeof(text)); break; case midi::PitchBend: handlePitchBend(inChannel, inData1); - strlcpy(text, "PB",sizeof(text)); + strlcpy(text, "PB", sizeof(text)); break; case midi::ProgramChange: handleProgramChange(inChannel, inData1); - strlcpy(text, "PC",sizeof(text)); + strlcpy(text, "PC", sizeof(text)); break; case midi::AfterTouchPoly: handleAfterTouchPoly(inChannel, inData1, inData2); - strlcpy(text, "Poly AT",sizeof(text)); + strlcpy(text, "Poly AT", sizeof(text)); break; default: break; @@ -112,11 +110,10 @@ void handle_generic(byte inChannel, byte inData1, byte inData2, const char *midi #endif // MIDI THRU - if (configuration.sys.soft_midi_thru == 1) - { + if (configuration.sys.soft_midi_thru == 1) { #ifdef MIDI_DEVICE_USB - if(strcmp(MIDI_BY_USB, midi_device)) { - switch(event) { + if (strcmp(MIDI_BY_USB, midi_device)) { + switch (event) { case midi::NoteOn: usbMIDI.sendNoteOn(inData1, inData2, inChannel); break; @@ -141,15 +138,15 @@ void handle_generic(byte inChannel, byte inData1, byte inData2, const char *midi default: break; } - #ifdef DEBUG +#ifdef DEBUG Serial.print(F(" THRU->MIDI_USB")); - #endif +#endif } #endif #ifdef MIDI_DEVICE_DIN - if(strcmp(MIDI_BY_DIN, midi_device)) { - switch(event) { + if (strcmp(MIDI_BY_DIN, midi_device)) { + switch (event) { case midi::NoteOn: midi_serial.sendNoteOn(inData1, inData2, inChannel); break; @@ -174,15 +171,15 @@ void handle_generic(byte inChannel, byte inData1, byte inData2, const char *midi default: break; } - #ifdef DEBUG +#ifdef DEBUG Serial.print(F(" THRU->MIDI_DIN")); - #endif +#endif } #endif #ifdef MIDI_DEVICE_USB_HOST - if(strcmp(MIDI_BY_USB_HOST, midi_device)) { - switch(event) { + if (strcmp(MIDI_BY_USB_HOST, midi_device)) { + switch (event) { case midi::NoteOn: midi_usb.sendNoteOn(inData1, inData2, inChannel); break; @@ -207,9 +204,9 @@ void handle_generic(byte inChannel, byte inData1, byte inData2, const char *midi default: break; } - #ifdef DEBUG +#ifdef DEBUG Serial.print(F(" THRU->MIDI_USB_HOST")); - #endif +#endif } #endif } @@ -226,32 +223,31 @@ void handleSystemExclusive_generic(byte *data, uint len, const char *midi_device #endif // MIDI THRU - if (configuration.sys.soft_midi_thru == 1) - { + if (configuration.sys.soft_midi_thru == 1) { #ifdef MIDI_DEVICE_USB - if(strcmp(MIDI_BY_USB, midi_device)) { - usbMIDI.sendSysEx(len, data); - #ifdef DEBUG - Serial.print(F(" THRU->MIDI_USB")); - #endif + if (strcmp(MIDI_BY_USB, midi_device)) { + usbMIDI.sendSysEx(len, data); +#ifdef DEBUG + Serial.print(F(" THRU->MIDI_USB")); +#endif } #endif #ifdef MIDI_DEVICE_DIN - if(strcmp(MIDI_BY_DIN, midi_device)) { - midi_serial.sendSysEx(len, data); - #ifdef DEBUG - Serial.print(F(" THRU->MIDI_DIN")); - #endif + if (strcmp(MIDI_BY_DIN, midi_device)) { + midi_serial.sendSysEx(len, data); +#ifdef DEBUG + Serial.print(F(" THRU->MIDI_DIN")); +#endif } #endif #ifdef MIDI_DEVICE_USB_HOST - if(strcmp(MIDI_BY_USB_HOST, midi_device)) { - midi_usb.sendSysEx(len, data); - #ifdef DEBUG - Serial.print(F(" THRU->MIDI_USB_HOST")); - #endif + if (strcmp(MIDI_BY_USB_HOST, midi_device)) { + midi_usb.sendSysEx(len, data); +#ifdef DEBUG + Serial.print(F(" THRU->MIDI_USB_HOST")); +#endif } #endif } @@ -261,22 +257,21 @@ void handleSystemExclusive_generic(byte *data, uint len, const char *midi_device #endif } -void handleSystemCommon_generic(byte inData1, const char *midi_device, midi::MidiType event) -{ +void handleSystemCommon_generic(byte inData1, const char *midi_device, midi::MidiType event) { char text[10]; - switch(event) { + switch (event) { case midi::TimeCodeQuarterFrame: handleTimeCodeQuarterFrame(inData1); - strlcpy(text, "TimeCodeQuarterFrame",sizeof(text)); + strlcpy(text, "TimeCodeQuarterFrame", sizeof(text)); break; case midi::SongSelect: handleSongSelect(inData1); - strlcpy(text, "SongSelect",sizeof(text)); + strlcpy(text, "SongSelect", sizeof(text)); break; case midi::TuneRequest: handleTuneRequest(); - strlcpy(text, "TuneRequest",sizeof(text)); + strlcpy(text, "TuneRequest", sizeof(text)); break; default: break; @@ -286,11 +281,10 @@ void handleSystemCommon_generic(byte inData1, const char *midi_device, midi::Mid #endif // MIDI THRU - if (configuration.sys.soft_midi_thru == 1) - { + if (configuration.sys.soft_midi_thru == 1) { #ifdef MIDI_DEVICE_USB - if(strcmp(MIDI_BY_USB, midi_device)) { - switch(event) { + if (strcmp(MIDI_BY_USB, midi_device)) { + switch (event) { case midi::TimeCodeQuarterFrame: usbMIDI.sendTimeCodeQuarterFrame(0xF1, inData1); break; @@ -303,15 +297,15 @@ void handleSystemCommon_generic(byte inData1, const char *midi_device, midi::Mid default: break; } - #ifdef DEBUG +#ifdef DEBUG Serial.print(F(" THRU->MIDI_USB")); - #endif +#endif } #endif #ifdef MIDI_DEVICE_DIN - if(strcmp(MIDI_BY_DIN, midi_device)) { - switch(event) { + if (strcmp(MIDI_BY_DIN, midi_device)) { + switch (event) { case midi::TimeCodeQuarterFrame: midi_serial.sendTimeCodeQuarterFrame(inData1); break; @@ -324,15 +318,15 @@ void handleSystemCommon_generic(byte inData1, const char *midi_device, midi::Mid default: break; } - #ifdef DEBUG +#ifdef DEBUG Serial.print(F(" THRU->MIDI_DIN")); - #endif +#endif } #endif #ifdef MIDI_DEVICE_USB_HOST - if(strcmp(MIDI_BY_USB_HOST, midi_device)) { - switch(event) { + if (strcmp(MIDI_BY_USB_HOST, midi_device)) { + switch (event) { case midi::TimeCodeQuarterFrame: midi_usb.sendTimeCodeQuarterFrame(0xF1, inData1); break; @@ -345,9 +339,9 @@ void handleSystemCommon_generic(byte inData1, const char *midi_device, midi::Mid default: break; } - #ifdef DEBUG +#ifdef DEBUG Serial.print(F(" THRU->MIDI_USB_HOST")); - #endif +#endif } #endif } @@ -357,34 +351,33 @@ void handleSystemCommon_generic(byte inData1, const char *midi_device, midi::Mid #endif } -void handleRealtime_generic(const char *midi_device, midi::MidiType event) -{ +void handleRealtime_generic(const char *midi_device, midi::MidiType event) { char text[10]; - switch(event) { + switch (event) { case midi::Clock: handleClock(); - strlcpy(text, "Clock",sizeof(text)); + strlcpy(text, "Clock", sizeof(text)); break; case midi::Start: handleStart(); - strlcpy(text, "Start",sizeof(text)); + strlcpy(text, "Start", sizeof(text)); break; case midi::Continue: handleContinue(); - strlcpy(text, "Continue",sizeof(text)); + strlcpy(text, "Continue", sizeof(text)); break; case midi::Stop: handleStop(); - strlcpy(text, "Stop",sizeof(text)); + strlcpy(text, "Stop", sizeof(text)); break; case midi::ActiveSensing: handleActiveSensing(); - strlcpy(text, "ActiveSensing",sizeof(text)); + strlcpy(text, "ActiveSensing", sizeof(text)); break; case midi::SystemReset: handleSystemReset(); - strlcpy(text, "SystemReset",sizeof(text)); + strlcpy(text, "SystemReset", sizeof(text)); break; default: break; @@ -394,32 +387,31 @@ void handleRealtime_generic(const char *midi_device, midi::MidiType event) #endif // MIDI THRU - if (configuration.sys.soft_midi_thru == 1) - { + if (configuration.sys.soft_midi_thru == 1) { #ifdef MIDI_DEVICE_USB - if(strcmp(MIDI_BY_USB, midi_device)) { + if (strcmp(MIDI_BY_USB, midi_device)) { usbMIDI.sendRealTime(event); - #ifdef DEBUG +#ifdef DEBUG Serial.print(F(" THRU->MIDI_USB")); - #endif +#endif } #endif #ifdef MIDI_DEVICE_DIN - if(strcmp(MIDI_BY_DIN, midi_device)) { + if (strcmp(MIDI_BY_DIN, midi_device)) { midi_serial.sendRealTime(event); - #ifdef DEBUG +#ifdef DEBUG Serial.print(F(" THRU->MIDI_DIN")); - #endif +#endif } #endif #ifdef MIDI_DEVICE_USB_HOST - if(strcmp(MIDI_BY_USB_HOST, midi_device)) { + if (strcmp(MIDI_BY_USB_HOST, midi_device)) { midi_usb.sendRealTime(event); - #ifdef DEBUG +#ifdef DEBUG Serial.print(F(" THRU->MIDI_USB_HOST")); - #endif +#endif } #endif } @@ -435,13 +427,13 @@ void handleRealtime_generic(const char *midi_device, midi::MidiType event) // handleRealTimeSystem(); // #ifdef DEBUG // switch(midi_device) { -// case MIDI_DIN: +// case MIDI_DIN: // Serial.print(F("[MIDI_DIN] RealTimeSystem")); // break; -// case MIDI_USB_HOST: +// case MIDI_USB_HOST: // Serial.print(F("[MIDI_USB_HOST] RealTimeSystem")); // break; -// case USB_MIDI: +// case USB_MIDI: // Serial.print(F("[USB_MIDI] RealTimeSystem")); // break; // } @@ -487,43 +479,35 @@ void handleRealtime_generic(const char *midi_device, midi::MidiType event) *****************************************/ #ifdef MIDI_DEVICE_DIN -void handleNoteOn_MIDI_DEVICE_DIN(byte inChannel, byte inNoteNumber, byte inVelocity) -{ +void handleNoteOn_MIDI_DEVICE_DIN(byte inChannel, byte inNoteNumber, byte inVelocity) { handle_generic(inChannel, inNoteNumber, inVelocity, MIDI_BY_DIN, midi::NoteOn); } -void handleNoteOff_MIDI_DEVICE_DIN(byte inChannel, byte inNoteNumber, byte inVelocity) -{ +void handleNoteOff_MIDI_DEVICE_DIN(byte inChannel, byte inNoteNumber, byte inVelocity) { handle_generic(inChannel, inNoteNumber, inVelocity, MIDI_BY_DIN, midi::NoteOff); } -void handleControlChange_MIDI_DEVICE_DIN(byte inChannel, byte inData1, byte inData2) -{ +void handleControlChange_MIDI_DEVICE_DIN(byte inChannel, byte inData1, byte inData2) { handle_generic(inChannel, inData1, inData2, MIDI_BY_DIN, midi::ControlChange); } -void handleAfterTouch_MIDI_DEVICE_DIN(byte inChannel, byte inPressure) -{ +void handleAfterTouch_MIDI_DEVICE_DIN(byte inChannel, byte 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(byte inChannel, int inPitch) { handle_generic(inChannel, inPitch, '\0', MIDI_BY_DIN, midi::PitchBend); } -void handleProgramChange_MIDI_DEVICE_DIN(byte inChannel, byte inProgram) -{ +void handleProgramChange_MIDI_DEVICE_DIN(byte inChannel, byte inProgram) { handle_generic(inChannel, inProgram, '\0', MIDI_BY_DIN, midi::ProgramChange); } -void handleAfterTouchPoly_MIDI_DEVICE_DIN(byte inChannel, byte inNoteNumber, byte inVelocity) -{ +void handleAfterTouchPoly_MIDI_DEVICE_DIN(byte inChannel, byte inNoteNumber, byte inVelocity) { handle_generic(inChannel, inNoteNumber, inVelocity, MIDI_BY_DIN, midi::AfterTouchPoly); } -void handleSystemExclusive_MIDI_DEVICE_DIN(byte * data, uint len) -{ +void handleSystemExclusive_MIDI_DEVICE_DIN(byte *data, uint len) { handleSystemExclusive_generic(data, len, MIDI_BY_DIN); } @@ -553,48 +537,39 @@ void handleSystemExclusive_MIDI_DEVICE_DIN(byte * data, uint len) #endif } */ -void handleTimeCodeQuarterFrame_MIDI_DEVICE_DIN(byte data) -{ +void handleTimeCodeQuarterFrame_MIDI_DEVICE_DIN(byte data) { handleSystemCommon_generic(data, MIDI_BY_DIN, midi::TimeCodeQuarterFrame); } -void handleSongSelect_MIDI_DEVICE_DIN(byte inSong) -{ +void handleSongSelect_MIDI_DEVICE_DIN(byte inSong) { handleSystemCommon_generic(inSong, MIDI_BY_DIN, midi::SongSelect); } -void handleTuneRequest_MIDI_DEVICE_DIN(void) -{ +void handleTuneRequest_MIDI_DEVICE_DIN(void) { handleSystemCommon_generic('\0', MIDI_BY_DIN, midi::TuneRequest); } -void handleClock_MIDI_DEVICE_DIN(void) -{ +void handleClock_MIDI_DEVICE_DIN(void) { handleRealtime_generic(MIDI_BY_DIN, midi::Clock); } -void handleStart_MIDI_DEVICE_DIN(void) -{ +void handleStart_MIDI_DEVICE_DIN(void) { handleRealtime_generic(MIDI_BY_DIN, midi::Start); } -void handleContinue_MIDI_DEVICE_DIN(void) -{ +void handleContinue_MIDI_DEVICE_DIN(void) { handleRealtime_generic(MIDI_BY_DIN, midi::Continue); } -void handleStop_MIDI_DEVICE_DIN(void) -{ +void handleStop_MIDI_DEVICE_DIN(void) { handleRealtime_generic(MIDI_BY_DIN, midi::Stop); } -void handleActiveSensing_MIDI_DEVICE_DIN(void) -{ +void handleActiveSensing_MIDI_DEVICE_DIN(void) { handleRealtime_generic(MIDI_BY_DIN, midi::ActiveSensing); } -void handleSystemReset_MIDI_DEVICE_DIN(void) -{ +void handleSystemReset_MIDI_DEVICE_DIN(void) { handleRealtime_generic(MIDI_BY_DIN, midi::SystemReset); } @@ -602,49 +577,41 @@ void handleSystemReset_MIDI_DEVICE_DIN(void) { handleRealTimeSystem_generic(MIDI_DIN); } */ -#endif // MIDI_DEVICE_DIN +#endif // MIDI_DEVICE_DIN /***************************************** MIDI_DEVICE_USB_HOST *****************************************/ #ifdef MIDI_DEVICE_USB_HOST -void handleNoteOn_MIDI_DEVICE_USB_HOST(byte inChannel, byte inNoteNumber, byte inVelocity) -{ +void handleNoteOn_MIDI_DEVICE_USB_HOST(byte inChannel, byte inNoteNumber, byte inVelocity) { handle_generic(inChannel, inNoteNumber, inVelocity, MIDI_BY_USB_HOST, midi::NoteOn); } -void handleNoteOff_MIDI_DEVICE_USB_HOST(byte inChannel, byte inNoteNumber, byte inVelocity) -{ +void handleNoteOff_MIDI_DEVICE_USB_HOST(byte inChannel, byte inNoteNumber, byte inVelocity) { handle_generic(inChannel, inNoteNumber, inVelocity, MIDI_BY_USB_HOST, midi::NoteOff); } -void handleControlChange_MIDI_DEVICE_USB_HOST(byte inChannel, byte inData1, byte inData2) -{ +void handleControlChange_MIDI_DEVICE_USB_HOST(byte inChannel, byte inData1, byte inData2) { handle_generic(inChannel, inData1, inData2, MIDI_BY_USB_HOST, midi::ControlChange); } -void handleAfterTouch_MIDI_DEVICE_USB_HOST(byte inChannel, byte inPressure) -{ +void handleAfterTouch_MIDI_DEVICE_USB_HOST(byte inChannel, byte 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(byte inChannel, int inPitch) { handle_generic(inChannel, inPitch, '\0', MIDI_BY_USB_HOST, midi::PitchBend); } -void handleProgramChange_MIDI_DEVICE_USB_HOST(byte inChannel, byte inPitch) -{ +void handleProgramChange_MIDI_DEVICE_USB_HOST(byte inChannel, byte inPitch) { handle_generic(inChannel, inPitch, '\0', MIDI_BY_USB_HOST, midi::ProgramChange); } -void handleAfterTouchPoly_MIDI_DEVICE_USB_HOST(byte inChannel, byte inNoteNumber, byte inVelocity) -{ +void handleAfterTouchPoly_MIDI_DEVICE_USB_HOST(byte inChannel, byte inNoteNumber, byte inVelocity) { handle_generic(inChannel, inNoteNumber, inVelocity, MIDI_BY_USB_HOST, midi::AfterTouchPoly); } -void handleSystemExclusive_MIDI_DEVICE_USB_HOST(byte * data, uint len) -{ +void handleSystemExclusive_MIDI_DEVICE_USB_HOST(byte *data, uint len) { handleSystemExclusive_generic(data, len, MIDI_BY_USB_HOST); } @@ -674,48 +641,39 @@ void handleSystemExclusive_MIDI_DEVICE_USB_HOST(byte * data, uint len) #endif } */ -void handleTimeCodeQuarterFrame_MIDI_DEVICE_USB_HOST(midi::DataByte data) -{ +void handleTimeCodeQuarterFrame_MIDI_DEVICE_USB_HOST(midi::DataByte data) { handleSystemCommon_generic(data, MIDI_BY_USB_HOST, midi::TimeCodeQuarterFrame); } -void handleSongSelect_MIDI_DEVICE_USB_HOST(byte inSong) -{ +void handleSongSelect_MIDI_DEVICE_USB_HOST(byte inSong) { handleSystemCommon_generic(inSong, MIDI_BY_USB_HOST, midi::SongSelect); } -void handleTuneRequest_MIDI_DEVICE_USB_HOST(void) -{ +void handleTuneRequest_MIDI_DEVICE_USB_HOST(void) { handleSystemCommon_generic('\0', MIDI_BY_USB_HOST, midi::TuneRequest); } -void handleClock_MIDI_DEVICE_USB_HOST(void) -{ +void handleClock_MIDI_DEVICE_USB_HOST(void) { handleRealtime_generic(MIDI_BY_USB_HOST, midi::Clock); } -void handleStart_MIDI_DEVICE_USB_HOST(void) -{ +void handleStart_MIDI_DEVICE_USB_HOST(void) { handleRealtime_generic(MIDI_BY_USB_HOST, midi::Start); } -void handleContinue_MIDI_DEVICE_USB_HOST(void) -{ +void handleContinue_MIDI_DEVICE_USB_HOST(void) { handleRealtime_generic(MIDI_BY_USB_HOST, midi::Continue); } -void handleStop_MIDI_DEVICE_USB_HOST(void) -{ +void handleStop_MIDI_DEVICE_USB_HOST(void) { handleRealtime_generic(MIDI_BY_USB_HOST, midi::Stop); } -void handleActiveSensing_MIDI_DEVICE_USB_HOST(void) -{ +void handleActiveSensing_MIDI_DEVICE_USB_HOST(void) { handleRealtime_generic(MIDI_BY_USB_HOST, midi::ActiveSensing); } -void handleSystemReset_MIDI_DEVICE_USB_HOST(void) -{ +void handleSystemReset_MIDI_DEVICE_USB_HOST(void) { handleRealtime_generic(MIDI_BY_USB_HOST, midi::SystemReset); } @@ -723,49 +681,41 @@ void handleSystemReset_MIDI_DEVICE_USB_HOST(void) { handleRealTimeSystem_generic(inRealTime, MIDI_USB_HOST); } */ -#endif // MIDI_DEVICE_USB_HOST +#endif // MIDI_DEVICE_USB_HOST /***************************************** MIDI_DEVICE_USB *****************************************/ #ifdef MIDI_DEVICE_USB -void handleNoteOn_MIDI_DEVICE_USB(byte inChannel, byte inNoteNumber, byte inVelocity) -{ +void handleNoteOn_MIDI_DEVICE_USB(byte inChannel, byte inNoteNumber, byte inVelocity) { handle_generic(inChannel, inNoteNumber, inVelocity, MIDI_BY_USB, midi::NoteOn); } -void handleNoteOff_MIDI_DEVICE_USB(byte inChannel, byte inNoteNumber, byte inVelocity) -{ +void handleNoteOff_MIDI_DEVICE_USB(byte inChannel, byte inNoteNumber, byte inVelocity) { handle_generic(inChannel, inNoteNumber, inVelocity, MIDI_BY_USB, midi::NoteOff); } -void handleControlChange_MIDI_DEVICE_USB(byte inChannel, byte inData1, byte inData2) -{ +void handleControlChange_MIDI_DEVICE_USB(byte inChannel, byte inData1, byte inData2) { handle_generic(inChannel, inData1, inData2, MIDI_BY_USB, midi::ControlChange); } -void handleAfterTouch_MIDI_DEVICE_USB(byte inChannel, byte inPressure) -{ +void handleAfterTouch_MIDI_DEVICE_USB(byte inChannel, byte 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(byte inChannel, int inPitch) { handle_generic(inChannel, inPitch, '\0', MIDI_BY_USB, midi::PitchBend); } -void handleProgramChange_MIDI_DEVICE_USB(byte inChannel, byte inProgram) -{ +void handleProgramChange_MIDI_DEVICE_USB(byte inChannel, byte inProgram) { handle_generic(inChannel, inProgram, '\0', MIDI_BY_USB, midi::ProgramChange); } -void handleAfterTouchPoly_MIDI_DEVICE_USB(byte inChannel, byte inNoteNumber, byte inVelocity) -{ +void handleAfterTouchPoly_MIDI_DEVICE_USB(byte inChannel, byte inNoteNumber, byte inVelocity) { handle_generic(inChannel, inNoteNumber, inVelocity, MIDI_BY_USB, midi::AfterTouchPoly); } -void handleSystemExclusive_MIDI_DEVICE_USB(byte * data, uint len) -{ +void handleSystemExclusive_MIDI_DEVICE_USB(byte *data, uint len) { handleSystemExclusive_generic(data, len, MIDI_BY_USB); } @@ -795,48 +745,39 @@ void handleSystemExclusive_MIDI_DEVICE_USB(byte * data, uint len) #endif } */ -void handleTimeCodeQuarterFrame_MIDI_DEVICE_USB(midi::DataByte data) -{ +void handleTimeCodeQuarterFrame_MIDI_DEVICE_USB(midi::DataByte data) { handleSystemCommon_generic(data, MIDI_BY_USB, midi::TimeCodeQuarterFrame); } -void handleSongSelect_MIDI_DEVICE_USB(byte inSong) -{ +void handleSongSelect_MIDI_DEVICE_USB(byte inSong) { handleSystemCommon_generic(inSong, MIDI_BY_USB, midi::SongSelect); } -void handleTuneRequest_MIDI_DEVICE_USB(void) -{ +void handleTuneRequest_MIDI_DEVICE_USB(void) { handleSystemCommon_generic('\0', MIDI_BY_USB, midi::TuneRequest); } -void handleClock_MIDI_DEVICE_USB(void) -{ +void handleClock_MIDI_DEVICE_USB(void) { handleRealtime_generic(MIDI_BY_USB, midi::Clock); } -void handleStart_MIDI_DEVICE_USB(void) -{ +void handleStart_MIDI_DEVICE_USB(void) { handleRealtime_generic(MIDI_BY_USB, midi::Start); } -void handleContinue_MIDI_DEVICE_USB(void) -{ +void handleContinue_MIDI_DEVICE_USB(void) { handleRealtime_generic(MIDI_BY_USB, midi::Continue); } -void handleStop_MIDI_DEVICE_USB(void) -{ +void handleStop_MIDI_DEVICE_USB(void) { handleRealtime_generic(MIDI_BY_USB, midi::Stop); } -void handleActiveSensing_MIDI_DEVICE_USB(void) -{ +void handleActiveSensing_MIDI_DEVICE_USB(void) { handleRealtime_generic(MIDI_BY_USB, midi::ActiveSensing); } -void handleSystemReset_MIDI_DEVICE_USB(void) -{ +void handleSystemReset_MIDI_DEVICE_USB(void) { handleRealtime_generic(MIDI_BY_USB, midi::SystemReset); } @@ -844,10 +785,9 @@ void handleSystemReset_MIDI_DEVICE_USB(void) { handleRealTimeSystem_generic(inRealTime, USB_MIDI); } */ -#endif // MIDI_DEVICE_USB +#endif // MIDI_DEVICE_USB -FLASHMEM void MD_sendControlChange(uint8_t channel, uint8_t cc, uint8_t value) -{ +FLASHMEM void MD_sendControlChange(uint8_t channel, uint8_t cc, uint8_t value) { #ifdef DEBUG Serial.print(F("[MD] SendControlChange CH:")); Serial.print(channel, DEC); @@ -882,8 +822,7 @@ FLASHMEM void MD_sendControlChange(uint8_t channel, uint8_t cc, uint8_t value) /***************************************** HELPER FUNCTIONS *****************************************/ -FLASHMEM void setup_midi_devices(void) -{ +FLASHMEM void setup_midi_devices(void) { #ifdef MIDI_DEVICE_DIN // Start serial MIDI midi_serial.begin(DEFAULT_MIDI_CHANNEL); @@ -966,8 +905,7 @@ FLASHMEM void setup_midi_devices(void) #endif } -FLASHMEM void check_midi_devices(void) -{ +FLASHMEM void check_midi_devices(void) { #ifdef MIDI_DEVICE_DIN midi_serial.read(); #endif @@ -980,82 +918,75 @@ FLASHMEM void check_midi_devices(void) #endif } -FLASHMEM void send_sysex_voice(uint8_t midi_channel, uint8_t* data) -{ +FLASHMEM void send_sysex_voice(uint8_t midi_channel, uint8_t *data) { uint8_t checksum = 0; uint8_t vd[161]; // Send SYSEX data also via MIDI //vd[0] = 0xF0; // SysEx start - vd[0] = 0x43; // ID=Yamaha - vd[1] = midi_channel; // Sub-status and MIDI channel - vd[2] = 0x00; // Format number (0=1 voice) - vd[3] = 0x01; // Byte count MSB - vd[4] = 0x1B; // Byte count LSB - for (uint8_t n = 0; n < 155; n++) - { + vd[0] = 0x43; // ID=Yamaha + vd[1] = midi_channel; // Sub-status and MIDI channel + vd[2] = 0x00; // Format number (0=1 voice) + vd[3] = 0x01; // Byte count MSB + vd[4] = 0x1B; // Byte count LSB + for (uint8_t n = 0; n < 155; n++) { checksum -= data[n]; vd[5 + n] = data[n]; } - vd[160] = checksum & 0x7f; // Checksum + vd[160] = checksum & 0x7f; // Checksum //vd[162] = 0xF7; // SysEx end #ifdef MIDI_DEVICE_DIN - midi_serial.sendSysEx(161, vd); // Send to DIN MIDI + midi_serial.sendSysEx(161, vd); // Send to DIN MIDI #endif #ifdef MIDI_DEVICE_USB - usbMIDI.sendSysEx(161, vd); // Send to USB MIDI + usbMIDI.sendSysEx(161, vd); // Send to USB MIDI #endif #ifdef MIDI_DEVICE_USB_HOST - midi_usb.sendSysEx(161, vd); // Send to USB-HOST MIDI + midi_usb.sendSysEx(161, vd); // Send to USB-HOST MIDI #endif } -FLASHMEM void send_sysex_bank(uint8_t midi_channel, uint8_t* bank_data) -{ +FLASHMEM void send_sysex_bank(uint8_t midi_channel, uint8_t *bank_data) { #ifdef MIDI_DEVICE_DIN - midi_serial.sendSysEx(4104, bank_data); // Send to DIN MIDI + midi_serial.sendSysEx(4104, bank_data); // Send to DIN MIDI #endif #ifdef MIDI_DEVICE_USB // Sysex bank dump is splitted due to Windows USB driver limitations - usbMIDI.sendSysEx(2048, bank_data, true); // Send to USB MIDI + usbMIDI.sendSysEx(2048, bank_data, true); // Send to USB MIDI delay(50); - usbMIDI.sendSysEx(2048, bank_data+2048, true); + usbMIDI.sendSysEx(2048, bank_data + 2048, true); delay(50); - usbMIDI.sendSysEx(8, bank_data+4096, true); + usbMIDI.sendSysEx(8, bank_data + 4096, true); #endif #ifdef MIDI_DEVICE_USB_HOST - midi_usb.sendSysEx(4104, bank_data); // Send to USB-HOST MIDI + midi_usb.sendSysEx(4104, bank_data); // Send to USB-HOST MIDI #endif } -FLASHMEM void send_sysex_param(uint8_t midi_channel, uint8_t var, uint8_t val, uint8_t param_group) -{ +FLASHMEM void send_sysex_param(uint8_t midi_channel, uint8_t var, uint8_t val, uint8_t param_group) { uint8_t s[5]; - s[0] = 0x43; // ID=Yamaha - s[1] = midi_channel; // Sub-status and MIDI channel - s[2] = (param_group & 5) << 2; // Format number (0=1 voice) - if (param_group == 0) - { + s[0] = 0x43; // ID=Yamaha + s[1] = midi_channel; // Sub-status and MIDI channel + s[2] = (param_group & 5) << 2; // Format number (0=1 voice) + if (param_group == 0) { s[2] |= 1; s[3] = var & 0x7f; - } - else - { + } else { s[3] = var & 0x7f; } s[4] = val & 0x7f; #ifdef MIDI_DEVICE_DIN - midi_serial.sendSysEx(5, s); // Send to DIN MIDI + midi_serial.sendSysEx(5, s); // Send to DIN MIDI #endif #ifdef MIDI_DEVICE_USB - usbMIDI.sendSysEx(5, s); // Send to USB MIDI + usbMIDI.sendSysEx(5, s); // Send to USB MIDI #endif #ifdef MIDI_DEVICE_USB_HOST - midi_usb.sendSysEx(5, s); // Send to USB-HOST MIDI + midi_usb.sendSysEx(5, s); // Send to USB-HOST MIDI #endif } -#endif // MIDI_DEVICES_H +#endif // MIDI_DEVICES_H