From c28a2a3dffdfc621309e3029b5aedf61be72d99e Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Thu, 28 May 2020 15:29:29 +0200 Subject: [PATCH] Sending sysex data when parameter changes are done at UI. --- UI.hpp | 16 +++++++++++++++- dexed.cpp | 2 +- doc/param_assignment.txt | 15 +++++++++++++++ midi_devices.hpp | 23 +++++++++++++++++++++++ 4 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 doc/param_assignment.txt diff --git a/UI.hpp b/UI.hpp index 8c5c3b3..c2fd8be 100644 --- a/UI.hpp +++ b/UI.hpp @@ -93,7 +93,6 @@ extern char sd_string[LCD_cols + 1]; extern char g_voice_name[NUM_DEXED][VOICE_NAME_LEN]; extern char g_bank_name[NUM_DEXED][BANK_NAME_LEN]; -extern void send_sysex_voice(uint8_t midi_channel, uint8_t* data); /*********************************************************************** GLOBAL @@ -1604,6 +1603,7 @@ void UI_func_transpose(uint8_t param) MicroDexed[selected_instance_id]->data[DEXED_VOICE_OFFSET + DEXED_TRANSPOSE] = configuration.dexed[selected_instance_id].transpose; MicroDexed[selected_instance_id]->notesOff(); + send_sysex_param(configuration.dexed[selected_instance_id].midi_channel, 144, configuration.dexed[selected_instance_id].transpose, 0); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -2331,6 +2331,7 @@ void UI_func_pb_range(uint8_t param) lcd_display_bar_int("PB Range", configuration.dexed[selected_instance_id].pb_range, 1.0, PB_RANGE_MIN, PB_RANGE_MAX, 2, false, false, false); MicroDexed[selected_instance_id]->setPBController(configuration.dexed[selected_instance_id].pb_range, configuration.dexed[selected_instance_id].pb_step); + send_sysex_param(configuration.dexed[selected_instance_id].midi_channel, 65, configuration.dexed[selected_instance_id].pb_range, 2); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -2384,6 +2385,7 @@ void UI_func_pb_step(uint8_t param) lcd_display_bar_int("PB Step", configuration.dexed[selected_instance_id].pb_step, 1.0, PB_STEP_MIN, PB_STEP_MAX, 2, false, false, false); MicroDexed[selected_instance_id]->setPBController(configuration.dexed[selected_instance_id].pb_range, configuration.dexed[selected_instance_id].pb_step); + send_sysex_param(configuration.dexed[selected_instance_id].midi_channel, 66, configuration.dexed[selected_instance_id].pb_step, 2); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -2437,6 +2439,7 @@ void UI_func_mw_range(uint8_t param) lcd_display_bar_int("MW Range", configuration.dexed[selected_instance_id].mw_range, 1.0, MW_RANGE_MIN, MW_RANGE_MAX, 2, false, false, false); MicroDexed[selected_instance_id]->setMWController(configuration.dexed[selected_instance_id].mw_range, configuration.dexed[selected_instance_id].mw_assign, configuration.dexed[selected_instance_id].mw_mode); + send_sysex_param(configuration.dexed[selected_instance_id].midi_channel, 70, configuration.dexed[selected_instance_id].mw_range, 2); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -2488,6 +2491,7 @@ void UI_func_mw_assign(uint8_t param) } MicroDexed[selected_instance_id]->setMWController(configuration.dexed[selected_instance_id].mw_range, configuration.dexed[selected_instance_id].mw_assign, configuration.dexed[selected_instance_id].mw_mode); + send_sysex_param(configuration.dexed[selected_instance_id].midi_channel, 71, configuration.dexed[selected_instance_id].mw_assign, 2); lcd.setCursor(0, 1); switch (configuration.dexed[selected_instance_id].mw_assign) @@ -2636,6 +2640,7 @@ void UI_func_fc_range(uint8_t param) lcd_display_bar_int("FC Range", configuration.dexed[selected_instance_id].fc_range, 1.0, FC_RANGE_MIN, FC_RANGE_MAX, 2, false, false, false); MicroDexed[selected_instance_id]->setFCController(configuration.dexed[selected_instance_id].fc_range, configuration.dexed[selected_instance_id].fc_assign, configuration.dexed[selected_instance_id].fc_mode); + send_sysex_param(configuration.dexed[selected_instance_id].midi_channel, 72, configuration.dexed[selected_instance_id].fc_range, 2); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -2687,6 +2692,7 @@ void UI_func_fc_assign(uint8_t param) } MicroDexed[selected_instance_id]->setFCController(configuration.dexed[selected_instance_id].fc_range, configuration.dexed[selected_instance_id].fc_assign, configuration.dexed[selected_instance_id].fc_mode); + send_sysex_param(configuration.dexed[selected_instance_id].midi_channel, 73, configuration.dexed[selected_instance_id].fc_assign, 2); lcd.setCursor(0, 1); switch (configuration.dexed[selected_instance_id].fc_assign) @@ -2835,6 +2841,7 @@ void UI_func_bc_range(uint8_t param) lcd_display_bar_int("BC Range", configuration.dexed[selected_instance_id].bc_range, 1.0, BC_RANGE_MIN, BC_RANGE_MAX, 2, false, false, false); MicroDexed[selected_instance_id]->setBCController(configuration.dexed[selected_instance_id].bc_range, configuration.dexed[selected_instance_id].bc_assign, configuration.dexed[selected_instance_id].bc_mode); + send_sysex_param(configuration.dexed[selected_instance_id].midi_channel, 74, configuration.dexed[selected_instance_id].bc_range, 2); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -2886,6 +2893,7 @@ void UI_func_bc_assign(uint8_t param) } MicroDexed[selected_instance_id]->setBCController(configuration.dexed[selected_instance_id].bc_range, configuration.dexed[selected_instance_id].bc_assign, configuration.dexed[selected_instance_id].bc_mode); + send_sysex_param(configuration.dexed[selected_instance_id].midi_channel, 75, configuration.dexed[selected_instance_id].bc_assign, 2); lcd.setCursor(0, 1); switch (configuration.dexed[selected_instance_id].bc_assign) @@ -3034,6 +3042,7 @@ void UI_func_at_range(uint8_t param) lcd_display_bar_int("AT Range", configuration.dexed[selected_instance_id].at_range, 1.0, AT_RANGE_MIN, AT_RANGE_MAX, 2, false, false, false); MicroDexed[selected_instance_id]->setATController(configuration.dexed[selected_instance_id].at_range, configuration.dexed[selected_instance_id].at_assign, configuration.dexed[selected_instance_id].at_mode); + send_sysex_param(configuration.dexed[selected_instance_id].midi_channel, 76, configuration.dexed[selected_instance_id].at_range, 2); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -3086,6 +3095,7 @@ void UI_func_at_assign(uint8_t param) } MicroDexed[selected_instance_id]->setATController(configuration.dexed[selected_instance_id].at_range, configuration.dexed[selected_instance_id].at_assign, configuration.dexed[selected_instance_id].at_mode); + send_sysex_param(configuration.dexed[selected_instance_id].midi_channel, 77, configuration.dexed[selected_instance_id].at_assign, 2); lcd.setCursor(0, 1); switch (configuration.dexed[selected_instance_id].at_assign) @@ -3232,6 +3242,7 @@ void UI_func_portamento_mode(uint8_t param) } MicroDexed[selected_instance_id]->setPortamentoMode(configuration.dexed[selected_instance_id].portamento_mode, configuration.dexed[selected_instance_id].portamento_glissando, configuration.dexed[selected_instance_id].portamento_time); + send_sysex_param(configuration.dexed[selected_instance_id].midi_channel, 67, configuration.dexed[selected_instance_id].portamento_mode, 2); lcd.setCursor(0, 1); switch (configuration.dexed[selected_instance_id].portamento_mode) @@ -3300,6 +3311,7 @@ void UI_func_portamento_glissando(uint8_t param) } MicroDexed[selected_instance_id]->setPortamentoMode(configuration.dexed[selected_instance_id].portamento_mode, configuration.dexed[selected_instance_id].portamento_glissando, configuration.dexed[selected_instance_id].portamento_time); + send_sysex_param(configuration.dexed[selected_instance_id].midi_channel, 68, configuration.dexed[selected_instance_id].portamento_glissando, 2); lcd.setCursor(0, 1); switch (configuration.dexed[selected_instance_id].portamento_glissando) @@ -3364,6 +3376,7 @@ void UI_func_portamento_time(uint8_t param) lcd_display_bar_int("Portam. Time", configuration.dexed[selected_instance_id].portamento_time, 1.0, PORTAMENTO_TIME_MIN, PORTAMENTO_TIME_MAX, 2, false, false, false); MicroDexed[selected_instance_id]->setPortamentoMode(configuration.dexed[selected_instance_id].portamento_mode, configuration.dexed[selected_instance_id].portamento_glissando, configuration.dexed[selected_instance_id].portamento_time); + send_sysex_param(configuration.dexed[selected_instance_id].midi_channel, 69, configuration.dexed[selected_instance_id].portamento_time, 2); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -3444,6 +3457,7 @@ void UI_handle_OP(uint8_t param) MicroDexed[selected_instance_id]->setOPs(configuration.dexed[selected_instance_id].op_enabled); MicroDexed[selected_instance_id]->doRefreshVoice(); + send_sysex_param(configuration.dexed[selected_instance_id].midi_channel, 155, configuration.dexed[selected_instance_id].op_enabled, 0); } if (LCDML.FUNC_close()) // ****** STABLE END ********* diff --git a/dexed.cpp b/dexed.cpp index 33236a0..b7cfd14 100644 --- a/dexed.cpp +++ b/dexed.cpp @@ -510,7 +510,7 @@ uint8_t Dexed::getNumNotesPlaying(void) return (count_playing_voices); } -bool Dexed::decodeVoice(uint8_t* encoded_data,uint8_t* new_data) +bool Dexed::decodeVoice(uint8_t* encoded_data, uint8_t* new_data) { uint8_t* p_data = new_data; uint8_t op; diff --git a/doc/param_assignment.txt b/doc/param_assignment.txt new file mode 100644 index 0000000..de25dc9 --- /dev/null +++ b/doc/param_assignment.txt @@ -0,0 +1,15 @@ +transpose FUNC 144 +operator FUNC 155 +pb_range SYSEX 65 +pb_step SYSEX 66 +mw_range SYSEX 70 +mw_assign SYSEX 71 +fc_range SYSEX 72 +fc_assign SYSEX 73 +bc_range SYSEX 74 +bc_assign SYSEX 75 +at_range SYSEX 76 +at_assign SYSEX 77 +portamento_mode SYSEX 67 +portamento_glissando SYSEX 68 +portamento_time SYSEX 69 diff --git a/midi_devices.hpp b/midi_devices.hpp index ba9c67a..c9183fa 100644 --- a/midi_devices.hpp +++ b/midi_devices.hpp @@ -1703,4 +1703,27 @@ void send_sysex_bank(uint8_t midi_channel, uint8_t* bank_data) usbMIDI.sendSysEx(4104, bank_data); // Send to USB-HOST MIDI } +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[2] |= 1; + s[3] = var & 0x7f; + } + else + { + s[3] = var & 0x7f; + } + s[4] = val & 0x7f; + + midi_serial.sendSysEx(5, s); // Send to DIN MIDI + midi_usb.sendSysEx(5, s); // Send to USB MIDI + usbMIDI.sendSysEx(5, s); // Send to USB-HOST MIDI +} + #endif // MIDI_DEVICES_H