From 3eccb2a9e11fa62243d683df94e68154f213bafa Mon Sep 17 00:00:00 2001 From: Vincent GAUCHE Date: Mon, 5 Jun 2023 23:10:11 +0200 Subject: [PATCH] Adding sound-design randomization feature for Performance / FX / Preset / OP --- src/uimenu.cpp | 1265 ++++++++++++++++++++++++++---------------------- src/uimenu.h | 125 ++--- 2 files changed, 758 insertions(+), 632 deletions(-) diff --git a/src/uimenu.cpp b/src/uimenu.cpp index 360a5b0..83ad591 100644 --- a/src/uimenu.cpp +++ b/src/uimenu.cpp @@ -29,6 +29,9 @@ #include #include #include +#include + +#include using namespace std; @@ -41,81 +44,82 @@ const CUIMenu::TMenuItem CUIMenu::s_MenuRoot[] = // inserting menu items before "TG1" affect TGShortcutHandler() const CUIMenu::TMenuItem CUIMenu::s_MainMenu[] = { - {"TG1", MenuHandler, s_TGMenu, 0}, + {"TG1", MenuHandler, s_TGMenu, 0}, #ifdef ARM_ALLOW_MULTI_CORE - {"TG2", MenuHandler, s_TGMenu, 1}, - {"TG3", MenuHandler, s_TGMenu, 2}, - {"TG4", MenuHandler, s_TGMenu, 3}, - {"TG5", MenuHandler, s_TGMenu, 4}, - {"TG6", MenuHandler, s_TGMenu, 5}, - {"TG7", MenuHandler, s_TGMenu, 6}, - {"TG8", MenuHandler, s_TGMenu, 7}, + {"TG2", MenuHandler, s_TGMenu, 1}, + {"TG3", MenuHandler, s_TGMenu, 2}, + {"TG4", MenuHandler, s_TGMenu, 3}, + {"TG5", MenuHandler, s_TGMenu, 4}, + {"TG6", MenuHandler, s_TGMenu, 5}, + {"TG7", MenuHandler, s_TGMenu, 6}, + {"TG8", MenuHandler, s_TGMenu, 7}, #endif - {"Effects", MenuHandler, s_EffectsMenu}, - {"Performance", MenuHandler, s_PerformanceMenu}, + {"Effects", MenuHandler, s_EffectsMenu}, + {"Performance", MenuHandler, s_PerformanceMenu}, {0} }; const CUIMenu::TMenuItem CUIMenu::s_TGMenu[] = { - {"Voice", EditProgramNumber}, - {"Bank", EditVoiceBankNumber}, - {"Volume", EditTGParameter, 0, CMiniDexed::TGParameterVolume}, + {"Voice", EditProgramNumber}, + {"Bank", EditVoiceBankNumber}, + {"Volume", EditTGParameter, 0, CMiniDexed::TGParameterVolume}, #ifdef ARM_ALLOW_MULTI_CORE - {"Pan", EditTGParameter, 0, CMiniDexed::TGParameterPan}, + {"Pan", EditTGParameter, 0, CMiniDexed::TGParameterPan}, #endif - {"Reverb-Send", EditTGParameter, 0, CMiniDexed::TGParameterReverbSend}, - {"Detune", EditTGParameter, 0, CMiniDexed::TGParameterMasterTune}, - {"Cutoff", EditTGParameter, 0, CMiniDexed::TGParameterCutoff}, - {"Resonance", EditTGParameter, 0, CMiniDexed::TGParameterResonance}, - {"Pitch Bend", MenuHandler, s_EditPitchBendMenu}, - {"Portamento", MenuHandler, s_EditPortamentoMenu}, - {"Poly/Mono", EditTGParameter, 0, CMiniDexed::TGParameterMonoMode}, - {"Modulation", MenuHandler, s_ModulationMenu}, - {"Channel", EditTGParameter, 0, CMiniDexed::TGParameterMIDIChannel}, - {"Edit Voice", MenuHandler, s_EditVoiceMenu}, + {"Reverb-Send", EditTGParameter, 0, CMiniDexed::TGParameterReverbSend}, + {"Detune", EditTGParameter, 0, CMiniDexed::TGParameterMasterTune}, + {"Cutoff", EditTGParameter, 0, CMiniDexed::TGParameterCutoff}, + {"Resonance", EditTGParameter, 0, CMiniDexed::TGParameterResonance}, + {"Pitch Bend", MenuHandler, s_EditPitchBendMenu}, + {"Portamento", MenuHandler, s_EditPortamentoMenu}, + {"Poly/Mono", EditTGParameter, 0, CMiniDexed::TGParameterMonoMode}, + {"Modulation", MenuHandler, s_ModulationMenu}, + {"Channel", EditTGParameter, 0, CMiniDexed::TGParameterMIDIChannel}, + {"Edit Voice", MenuHandler, s_EditVoiceMenu}, + {"Random", CUIMenu::GenerateRandomPreset, nullptr, 0}, {0} }; const CUIMenu::TMenuItem CUIMenu::s_EffectsMenu[] = { - {"Compress", EditGlobalParameter, 0, CMiniDexed::ParameterCompressorEnable}, + {"Compress", EditGlobalParameter, 0, CMiniDexed::ParameterCompressorEnable}, #ifdef ARM_ALLOW_MULTI_CORE - {"Reverb", MenuHandler, s_ReverbMenu}, + {"Reverb", MenuHandler, s_ReverbMenu}, #endif {0} }; const CUIMenu::TMenuItem CUIMenu::s_EditPitchBendMenu[] = { - {"Bend Range", EditTGParameter2, 0, CMiniDexed::TGParameterPitchBendRange}, - {"Bend Step", EditTGParameter2, 0, CMiniDexed::TGParameterPitchBendStep}, + {"Bend Range", EditTGParameter2, 0, CMiniDexed::TGParameterPitchBendRange}, + {"Bend Step", EditTGParameter2, 0, CMiniDexed::TGParameterPitchBendStep}, {0} }; const CUIMenu::TMenuItem CUIMenu::s_EditPortamentoMenu[] = { - {"Mode", EditTGParameter2, 0, CMiniDexed::TGParameterPortamentoMode}, - {"Glissando", EditTGParameter2, 0, CMiniDexed::TGParameterPortamentoGlissando}, - {"Time", EditTGParameter2, 0, CMiniDexed::TGParameterPortamentoTime}, + {"Mode", EditTGParameter2, 0, CMiniDexed::TGParameterPortamentoMode}, + {"Glissando", EditTGParameter2, 0, CMiniDexed::TGParameterPortamentoGlissando}, + {"Time", EditTGParameter2, 0, CMiniDexed::TGParameterPortamentoTime}, {0} }; const CUIMenu::TMenuItem CUIMenu::s_ModulationMenu[] = { - {"Mod. Wheel", MenuHandler, s_ModulationMenuParameters, CMiniDexed::TGParameterMWRange}, - {"Foot Control", MenuHandler, s_ModulationMenuParameters, CMiniDexed::TGParameterFCRange}, - {"Breath Control", MenuHandler, s_ModulationMenuParameters, CMiniDexed::TGParameterBCRange}, - {"Aftertouch", MenuHandler, s_ModulationMenuParameters, CMiniDexed::TGParameterATRange}, + {"Mod. Wheel", MenuHandler, s_ModulationMenuParameters, CMiniDexed::TGParameterMWRange}, + {"Foot Control", MenuHandler, s_ModulationMenuParameters, CMiniDexed::TGParameterFCRange}, + {"Breath Control", MenuHandler, s_ModulationMenuParameters, CMiniDexed::TGParameterBCRange}, + {"Aftertouch", MenuHandler, s_ModulationMenuParameters, CMiniDexed::TGParameterATRange}, {0} }; const CUIMenu::TMenuItem CUIMenu::s_ModulationMenuParameters[] = { - {"Range", EditTGParameterModulation, 0, 0}, - {"Pitch", EditTGParameterModulation, 0, 1}, - {"Amplitude", EditTGParameterModulation, 0, 2}, - {"EG Bias", EditTGParameterModulation, 0, 3}, + {"Range", EditTGParameterModulation, 0, 0}, + {"Pitch", EditTGParameterModulation, 0, 1}, + {"Amplitude", EditTGParameterModulation, 0, 2}, + {"EG Bias", EditTGParameterModulation, 0, 3}, {0} }; @@ -123,13 +127,14 @@ const CUIMenu::TMenuItem CUIMenu::s_ModulationMenuParameters[] = const CUIMenu::TMenuItem CUIMenu::s_ReverbMenu[] = { - {"Enable", EditGlobalParameter, 0, CMiniDexed::ParameterReverbEnable}, - {"Size", EditGlobalParameter, 0, CMiniDexed::ParameterReverbSize}, - {"High damp", EditGlobalParameter, 0, CMiniDexed::ParameterReverbHighDamp}, - {"Low damp", EditGlobalParameter, 0, CMiniDexed::ParameterReverbLowDamp}, - {"Low pass", EditGlobalParameter, 0, CMiniDexed::ParameterReverbLowPass}, - {"Diffusion", EditGlobalParameter, 0, CMiniDexed::ParameterReverbDiffusion}, - {"Level", EditGlobalParameter, 0, CMiniDexed::ParameterReverbLevel}, + {"Enable", EditGlobalParameter, 0, CMiniDexed::ParameterReverbEnable}, + {"Size", EditGlobalParameter, 0, CMiniDexed::ParameterReverbSize}, + {"High damp", EditGlobalParameter, 0, CMiniDexed::ParameterReverbHighDamp}, + {"Low damp", EditGlobalParameter, 0, CMiniDexed::ParameterReverbLowDamp}, + {"Low pass", EditGlobalParameter, 0, CMiniDexed::ParameterReverbLowPass}, + {"Diffusion", EditGlobalParameter, 0, CMiniDexed::ParameterReverbDiffusion}, + {"Level", EditGlobalParameter, 0, CMiniDexed::ParameterReverbLevel}, + {"Random", CUIMenu::GenerateRandomFX, nullptr, 0}, {0} }; @@ -138,176 +143,177 @@ const CUIMenu::TMenuItem CUIMenu::s_ReverbMenu[] = // inserting menu items before "OP1" affect OPShortcutHandler() const CUIMenu::TMenuItem CUIMenu::s_EditVoiceMenu[] = { - {"OP1", MenuHandler, s_OperatorMenu, 0}, - {"OP2", MenuHandler, s_OperatorMenu, 1}, - {"OP3", MenuHandler, s_OperatorMenu, 2}, - {"OP4", MenuHandler, s_OperatorMenu, 3}, - {"OP5", MenuHandler, s_OperatorMenu, 4}, - {"OP6", MenuHandler, s_OperatorMenu, 5}, - {"Algorithm", EditVoiceParameter, 0, DEXED_ALGORITHM}, - {"Feedback", EditVoiceParameter, 0, DEXED_FEEDBACK}, - {"P EG Rate 1", EditVoiceParameter, 0, DEXED_PITCH_EG_R1}, - {"P EG Rate 2", EditVoiceParameter, 0, DEXED_PITCH_EG_R2}, - {"P EG Rate 3", EditVoiceParameter, 0, DEXED_PITCH_EG_R3}, - {"P EG Rate 4", EditVoiceParameter, 0, DEXED_PITCH_EG_R4}, - {"P EG Level 1",EditVoiceParameter, 0, DEXED_PITCH_EG_L1}, - {"P EG Level 2",EditVoiceParameter, 0, DEXED_PITCH_EG_L2}, - {"P EG Level 3",EditVoiceParameter, 0, DEXED_PITCH_EG_L3}, - {"P EG Level 4",EditVoiceParameter, 0, DEXED_PITCH_EG_L4}, - {"Osc Key Sync",EditVoiceParameter, 0, DEXED_OSC_KEY_SYNC}, - {"LFO Speed", EditVoiceParameter, 0, DEXED_LFO_SPEED}, - {"LFO Delay", EditVoiceParameter, 0, DEXED_LFO_DELAY}, - {"LFO PMD", EditVoiceParameter, 0, DEXED_LFO_PITCH_MOD_DEP}, - {"LFO AMD", EditVoiceParameter, 0, DEXED_LFO_AMP_MOD_DEP}, - {"LFO Sync", EditVoiceParameter, 0, DEXED_LFO_SYNC}, - {"LFO Wave", EditVoiceParameter, 0, DEXED_LFO_WAVE}, - {"P Mod Sens.", EditVoiceParameter, 0, DEXED_LFO_PITCH_MOD_SENS}, - {"Transpose", EditVoiceParameter, 0, DEXED_TRANSPOSE}, - {"Name", InputTxt,0 , 3}, + {"OP1", MenuHandler, s_OperatorMenu, 0}, + {"OP2", MenuHandler, s_OperatorMenu, 1}, + {"OP3", MenuHandler, s_OperatorMenu, 2}, + {"OP4", MenuHandler, s_OperatorMenu, 3}, + {"OP5", MenuHandler, s_OperatorMenu, 4}, + {"OP6", MenuHandler, s_OperatorMenu, 5}, + {"Algorithm", EditVoiceParameter, 0, DEXED_ALGORITHM}, + {"Feedback", EditVoiceParameter, 0, DEXED_FEEDBACK}, + {"P EG Rate 1", EditVoiceParameter, 0, DEXED_PITCH_EG_R1}, + {"P EG Rate 2", EditVoiceParameter, 0, DEXED_PITCH_EG_R2}, + {"P EG Rate 3", EditVoiceParameter, 0, DEXED_PITCH_EG_R3}, + {"P EG Rate 4", EditVoiceParameter, 0, DEXED_PITCH_EG_R4}, + {"P EG Level 1", EditVoiceParameter, 0, DEXED_PITCH_EG_L1}, + {"P EG Level 2", EditVoiceParameter, 0, DEXED_PITCH_EG_L2}, + {"P EG Level 3", EditVoiceParameter, 0, DEXED_PITCH_EG_L3}, + {"P EG Level 4", EditVoiceParameter, 0, DEXED_PITCH_EG_L4}, + {"Osc Key Sync", EditVoiceParameter, 0, DEXED_OSC_KEY_SYNC}, + {"LFO Speed", EditVoiceParameter, 0, DEXED_LFO_SPEED}, + {"LFO Delay", EditVoiceParameter, 0, DEXED_LFO_DELAY}, + {"LFO PMD", EditVoiceParameter, 0, DEXED_LFO_PITCH_MOD_DEP}, + {"LFO AMD", EditVoiceParameter, 0, DEXED_LFO_AMP_MOD_DEP}, + {"LFO Sync", EditVoiceParameter, 0, DEXED_LFO_SYNC}, + {"LFO Wave", EditVoiceParameter, 0, DEXED_LFO_WAVE}, + {"P Mod Sens.", EditVoiceParameter, 0, DEXED_LFO_PITCH_MOD_SENS}, + {"Transpose", EditVoiceParameter, 0, DEXED_TRANSPOSE}, + {"Name", InputTxt, 0, 3}, {0} }; const CUIMenu::TMenuItem CUIMenu::s_OperatorMenu[] = { - {"Output Level",EditOPParameter, 0, DEXED_OP_OUTPUT_LEV}, - {"Freq Coarse", EditOPParameter, 0, DEXED_OP_FREQ_COARSE}, - {"Freq Fine", EditOPParameter, 0, DEXED_OP_FREQ_FINE}, - {"Osc Detune", EditOPParameter, 0, DEXED_OP_OSC_DETUNE}, - {"Osc Mode", EditOPParameter, 0, DEXED_OP_OSC_MODE}, - {"EG Rate 1", EditOPParameter, 0, DEXED_OP_EG_R1}, - {"EG Rate 2", EditOPParameter, 0, DEXED_OP_EG_R2}, - {"EG Rate 3", EditOPParameter, 0, DEXED_OP_EG_R3}, - {"EG Rate 4", EditOPParameter, 0, DEXED_OP_EG_R4}, - {"EG Level 1", EditOPParameter, 0, DEXED_OP_EG_L1}, - {"EG Level 2", EditOPParameter, 0, DEXED_OP_EG_L2}, - {"EG Level 3", EditOPParameter, 0, DEXED_OP_EG_L3}, - {"EG Level 4", EditOPParameter, 0, DEXED_OP_EG_L4}, - {"Break Point", EditOPParameter, 0, DEXED_OP_LEV_SCL_BRK_PT}, - {"L Key Depth", EditOPParameter, 0, DEXED_OP_SCL_LEFT_DEPTH}, - {"R Key Depth", EditOPParameter, 0, DEXED_OP_SCL_RGHT_DEPTH}, - {"L Key Scale", EditOPParameter, 0, DEXED_OP_SCL_LEFT_CURVE}, - {"R Key Scale", EditOPParameter, 0, DEXED_OP_SCL_RGHT_CURVE}, - {"Rate Scaling",EditOPParameter, 0, DEXED_OP_OSC_RATE_SCALE}, - {"A Mod Sens.", EditOPParameter, 0, DEXED_OP_AMP_MOD_SENS}, - {"K Vel. Sens.",EditOPParameter, 0, DEXED_OP_KEY_VEL_SENS}, + {"Output Level", EditOPParameter, 0, DEXED_OP_OUTPUT_LEV}, + {"Freq Coarse", EditOPParameter, 0, DEXED_OP_FREQ_COARSE}, + {"Freq Fine", EditOPParameter, 0, DEXED_OP_FREQ_FINE}, + {"Osc Detune", EditOPParameter, 0, DEXED_OP_OSC_DETUNE}, + {"Osc Mode", EditOPParameter, 0, DEXED_OP_OSC_MODE}, + {"EG Rate 1", EditOPParameter, 0, DEXED_OP_EG_R1}, + {"EG Rate 2", EditOPParameter, 0, DEXED_OP_EG_R2}, + {"EG Rate 3", EditOPParameter, 0, DEXED_OP_EG_R3}, + {"EG Rate 4", EditOPParameter, 0, DEXED_OP_EG_R4}, + {"EG Level 1", EditOPParameter, 0, DEXED_OP_EG_L1}, + {"EG Level 2", EditOPParameter, 0, DEXED_OP_EG_L2}, + {"EG Level 3", EditOPParameter, 0, DEXED_OP_EG_L3}, + {"EG Level 4", EditOPParameter, 0, DEXED_OP_EG_L4}, + {"Break Point", EditOPParameter, 0, DEXED_OP_LEV_SCL_BRK_PT}, + {"L Key Depth", EditOPParameter, 0, DEXED_OP_SCL_LEFT_DEPTH}, + {"R Key Depth", EditOPParameter, 0, DEXED_OP_SCL_RGHT_DEPTH}, + {"L Key Scale", EditOPParameter, 0, DEXED_OP_SCL_LEFT_CURVE}, + {"R Key Scale", EditOPParameter, 0, DEXED_OP_SCL_RGHT_CURVE}, + {"Rate Scaling", EditOPParameter, 0, DEXED_OP_OSC_RATE_SCALE}, + {"A Mod Sens.", EditOPParameter, 0, DEXED_OP_AMP_MOD_SENS}, + {"K Vel. Sens.", EditOPParameter, 0, DEXED_OP_KEY_VEL_SENS}, {"Enable", EditOPParameter, 0, DEXED_OP_ENABLE}, + {"Random", CUIMenu::GenerateRandomOperator, nullptr, 0}, {0} }; const CUIMenu::TMenuItem CUIMenu::s_SaveMenu[] = { - {"Overwrite", SavePerformance, 0, 0}, - {"New", InputTxt,0 , 1}, - {"Save as default", SavePerformance, 0, 1}, + {"Overwrite", SavePerformance, 0, 0}, + {"New", InputTxt, 0, 1}, + {"Save as default", SavePerformance, 0, 1}, {0} }; // must match CMiniDexed::TParameter const CUIMenu::TParameter CUIMenu::s_GlobalParameter[CMiniDexed::ParameterUnknown] = { - {0, 1, 1, ToOnOff}, // ParameterCompessorEnable - {0, 1, 1, ToOnOff}, // ParameterReverbEnable - {0, 99, 1}, // ParameterReverbSize - {0, 99, 1}, // ParameterReverbHighDamp - {0, 99, 1}, // ParameterReverbLowDamp - {0, 99, 1}, // ParameterReverbLowPass - {0, 99, 1}, // ParameterReverbDiffusion - {0, 99, 1} // ParameterReverbLevel + {0, 1, 1, ToOnOff}, // ParameterCompessorEnable + {0, 1, 1, ToOnOff}, // ParameterReverbEnable + {0, 99, 1}, // ParameterReverbSize + {0, 99, 1}, // ParameterReverbHighDamp + {0, 99, 1}, // ParameterReverbLowDamp + {0, 99, 1}, // ParameterReverbLowPass + {0, 99, 1}, // ParameterReverbDiffusion + {0, 99, 1} // ParameterReverbLevel }; // must match CMiniDexed::TTGParameter const CUIMenu::TParameter CUIMenu::s_TGParameter[CMiniDexed::TGParameterUnknown] = { - {0, CSysExFileLoader::MaxVoiceBankID, 1}, // TGParameterVoiceBank - {0, 0, 0}, // TGParameterVoiceBankMSB (not used in menus) - {0, 0, 0}, // TGParameterVoiceBankLSB (not used in menus) - {0, CSysExFileLoader::VoicesPerBank-1, 1}, // TGParameterProgram - {0, 127, 8, ToVolume}, // TGParameterVolume - {0, 127, 8, ToPan}, // TGParameterPan - {-99, 99, 1}, // TGParameterMasterTune - {0, 99, 1}, // TGParameterCutoff - {0, 99, 1}, // TGParameterResonance - {0, CMIDIDevice::ChannelUnknown-1, 1, ToMIDIChannel}, // TGParameterMIDIChannel - {0, 99, 1}, // TGParameterReverbSend - {0, 12, 1}, // TGParameterPitchBendRange - {0, 12, 1}, // TGParameterPitchBendStep - {0, 1, 1, ToPortaMode}, // TGParameterPortamentoMode - {0, 1, 1, ToPortaGlissando}, // TGParameterPortamentoGlissando - {0, 99, 1}, // TGParameterPortamentoTime - {0, 1, 1, ToPolyMono}, // TGParameterMonoMode - {0, 99, 1}, //MW Range - {0, 1, 1, ToOnOff}, //MW Pitch - {0, 1, 1, ToOnOff}, //MW Amp - {0, 1, 1, ToOnOff}, //MW EGBias - {0, 99, 1}, //FC Range - {0, 1, 1, ToOnOff}, //FC Pitch - {0, 1, 1, ToOnOff}, //FC Amp - {0, 1, 1, ToOnOff}, //FC EGBias - {0, 99, 1}, //BC Range - {0, 1, 1, ToOnOff}, //BC Pitch - {0, 1, 1, ToOnOff}, //BC Amp - {0, 1, 1, ToOnOff}, //BC EGBias - {0, 99, 1}, //AT Range - {0, 1, 1, ToOnOff}, //AT Pitch - {0, 1, 1, ToOnOff}, //AT Amp - {0, 1, 1, ToOnOff} //AT EGBias + {0, CSysExFileLoader::MaxVoiceBankID, 1}, // TGParameterVoiceBank + {0, 0, 0}, // TGParameterVoiceBankMSB (not used in menus) + {0, 0, 0}, // TGParameterVoiceBankLSB (not used in menus) + {0, CSysExFileLoader::VoicesPerBank - 1, 1}, // TGParameterProgram + {0, 127, 8, ToVolume}, // TGParameterVolume + {0, 127, 8, ToPan}, // TGParameterPan + {-99, 99, 1}, // TGParameterMasterTune + {0, 99, 1}, // TGParameterCutoff + {0, 99, 1}, // TGParameterResonance + {0, CMIDIDevice::ChannelUnknown - 1, 1, ToMIDIChannel}, // TGParameterMIDIChannel + {0, 99, 1}, // TGParameterReverbSend + {0, 12, 1}, // TGParameterPitchBendRange + {0, 12, 1}, // TGParameterPitchBendStep + {0, 1, 1, ToPortaMode}, // TGParameterPortamentoMode + {0, 1, 1, ToPortaGlissando}, // TGParameterPortamentoGlissando + {0, 99, 1}, // TGParameterPortamentoTime + {0, 1, 1, ToPolyMono}, // TGParameterMonoMode + {0, 99, 1}, // MW Range + {0, 1, 1, ToOnOff}, // MW Pitch + {0, 1, 1, ToOnOff}, // MW Amp + {0, 1, 1, ToOnOff}, // MW EGBias + {0, 99, 1}, // FC Range + {0, 1, 1, ToOnOff}, // FC Pitch + {0, 1, 1, ToOnOff}, // FC Amp + {0, 1, 1, ToOnOff}, // FC EGBias + {0, 99, 1}, // BC Range + {0, 1, 1, ToOnOff}, // BC Pitch + {0, 1, 1, ToOnOff}, // BC Amp + {0, 1, 1, ToOnOff}, // BC EGBias + {0, 99, 1}, // AT Range + {0, 1, 1, ToOnOff}, // AT Pitch + {0, 1, 1, ToOnOff}, // AT Amp + {0, 1, 1, ToOnOff} // AT EGBias }; // must match DexedVoiceParameters in Synth_Dexed const CUIMenu::TParameter CUIMenu::s_VoiceParameter[] = { - {0, 99, 1}, // DEXED_PITCH_EG_R1 - {0, 99, 1}, // DEXED_PITCH_EG_R2 - {0, 99, 1}, // DEXED_PITCH_EG_R3 - {0, 99, 1}, // DEXED_PITCH_EG_R4 - {0, 99, 1}, // DEXED_PITCH_EG_L1 - {0, 99, 1}, // DEXED_PITCH_EG_L2 - {0, 99, 1}, // DEXED_PITCH_EG_L3 - {0, 99, 1}, // DEXED_PITCH_EG_L4 - {0, 31, 1, ToAlgorithm}, // DEXED_ALGORITHM - {0, 7, 1}, // DEXED_FEEDBACK - {0, 1, 1, ToOnOff}, // DEXED_OSC_KEY_SYNC - {0, 99, 1}, // DEXED_LFO_SPEED - {0, 99, 1}, // DEXED_LFO_DELAY - {0, 99, 1}, // DEXED_LFO_PITCH_MOD_DEP - {0, 99, 1}, // DEXED_LFO_AMP_MOD_DEP - {0, 1, 1, ToOnOff}, // DEXED_LFO_SYNC - {0, 5, 1, ToLFOWaveform}, // DEXED_LFO_WAVE - {0, 7, 1}, // DEXED_LFO_PITCH_MOD_SENS - {0, 48, 1, ToTransposeNote}, // DEXED_TRANSPOSE - {0, 1, 1} // Voice Name - Dummy parameters for in case new item would be added in future + {0, 99, 1}, // DEXED_PITCH_EG_R1 + {0, 99, 1}, // DEXED_PITCH_EG_R2 + {0, 99, 1}, // DEXED_PITCH_EG_R3 + {0, 99, 1}, // DEXED_PITCH_EG_R4 + {0, 99, 1}, // DEXED_PITCH_EG_L1 + {0, 99, 1}, // DEXED_PITCH_EG_L2 + {0, 99, 1}, // DEXED_PITCH_EG_L3 + {0, 99, 1}, // DEXED_PITCH_EG_L4 + {0, 31, 1, ToAlgorithm}, // DEXED_ALGORITHM + {0, 7, 1}, // DEXED_FEEDBACK + {0, 1, 1, ToOnOff}, // DEXED_OSC_KEY_SYNC + {0, 99, 1}, // DEXED_LFO_SPEED + {0, 99, 1}, // DEXED_LFO_DELAY + {0, 99, 1}, // DEXED_LFO_PITCH_MOD_DEP + {0, 99, 1}, // DEXED_LFO_AMP_MOD_DEP + {0, 1, 1, ToOnOff}, // DEXED_LFO_SYNC + {0, 5, 1, ToLFOWaveform}, // DEXED_LFO_WAVE + {0, 7, 1}, // DEXED_LFO_PITCH_MOD_SENS + {0, 48, 1, ToTransposeNote}, // DEXED_TRANSPOSE + {0, 1, 1} // Voice Name - Dummy parameters for in case new item would be added in future }; // must match DexedVoiceOPParameters in Synth_Dexed const CUIMenu::TParameter CUIMenu::s_OPParameter[] = { - {0, 99, 1}, // DEXED_OP_EG_R1 - {0, 99, 1}, // DEXED_OP_EG_R2 - {0, 99, 1}, // DEXED_OP_EG_R3 - {0, 99, 1}, // DEXED_OP_EG_R4 - {0, 99, 1}, // DEXED_OP_EG_L1 - {0, 99, 1}, // DEXED_OP_EG_L2 - {0, 99, 1}, // DEXED_OP_EG_L3 - {0, 99, 1}, // DEXED_OP_EG_L4 - {0, 99, 1, ToBreakpointNote}, // DEXED_OP_LEV_SCL_BRK_PT - {0, 99, 1}, // DEXED_OP_SCL_LEFT_DEPTH - {0, 99, 1}, // DEXED_OP_SCL_RGHT_DEPTH - {0, 3, 1, ToKeyboardCurve}, // DEXED_OP_SCL_LEFT_CURVE - {0, 3, 1, ToKeyboardCurve}, // DEXED_OP_SCL_RGHT_CURVE - {0, 7, 1}, // DEXED_OP_OSC_RATE_SCALE - {0, 3, 1}, // DEXED_OP_AMP_MOD_SENS - {0, 7, 1}, // DEXED_OP_KEY_VEL_SENS - {0, 99, 1}, // DEXED_OP_OUTPUT_LEV - {0, 1, 1, ToOscillatorMode}, // DEXED_OP_OSC_MODE - {0, 31, 1}, // DEXED_OP_FREQ_COARSE - {0, 99, 1}, // DEXED_OP_FREQ_FINE - {0, 14, 1, ToOscillatorDetune}, // DEXED_OP_OSC_DETUNE - {0, 1, 1, ToOnOff} // DEXED_OP_ENABLE + {0, 99, 1}, // DEXED_OP_EG_R1 + {0, 99, 1}, // DEXED_OP_EG_R2 + {0, 99, 1}, // DEXED_OP_EG_R3 + {0, 99, 1}, // DEXED_OP_EG_R4 + {0, 99, 1}, // DEXED_OP_EG_L1 + {0, 99, 1}, // DEXED_OP_EG_L2 + {0, 99, 1}, // DEXED_OP_EG_L3 + {0, 99, 1}, // DEXED_OP_EG_L4 + {0, 99, 1, ToBreakpointNote}, // DEXED_OP_LEV_SCL_BRK_PT + {0, 99, 1}, // DEXED_OP_SCL_LEFT_DEPTH + {0, 99, 1}, // DEXED_OP_SCL_RGHT_DEPTH + {0, 3, 1, ToKeyboardCurve}, // DEXED_OP_SCL_LEFT_CURVE + {0, 3, 1, ToKeyboardCurve}, // DEXED_OP_SCL_RGHT_CURVE + {0, 7, 1}, // DEXED_OP_OSC_RATE_SCALE + {0, 3, 1}, // DEXED_OP_AMP_MOD_SENS + {0, 7, 1}, // DEXED_OP_KEY_VEL_SENS + {0, 99, 1}, // DEXED_OP_OUTPUT_LEV + {0, 1, 1, ToOscillatorMode}, // DEXED_OP_OSC_MODE + {0, 31, 1}, // DEXED_OP_FREQ_COARSE + {0, 99, 1}, // DEXED_OP_FREQ_FINE + {0, 14, 1, ToOscillatorDetune}, // DEXED_OP_OSC_DETUNE + {0, 1, 1, ToOnOff} // DEXED_OP_ENABLE }; const char CUIMenu::s_NoteName[100][4] = { - "A1", "A#1", "B1", "C1", "C#1", "D1", "D#1", "E1", "F1", "F#1", "G1", "G#1", + "A1", "A#1", "B1", "C1", "C#1", "D1", "D#1", "E1", "F1", "F#1", "G1", "G#1", "A2", "A#2", "B2", "C2", "C#2", "D2", "D#2", "E2", "F2", "F#2", "G2", "G#2", "A3", "A#3", "B3", "C3", "C#3", "D3", "D#3", "E3", "F3", "F#3", "G3", "G#3", "A4", "A#4", "B4", "C4", "C#4", "D4", "D#4", "E4", "F4", "F#4", "G4", "G#4", @@ -317,26 +323,27 @@ const char CUIMenu::s_NoteName[100][4] = "A8", "A#8", "B8", "C8", "C#8", "D8", "D#8", "E8", "F8", "F#8", "G8", "G#8", "A9", "A#9", "B9", "C9" }; + static const unsigned NoteC3 = 27; const CUIMenu::TMenuItem CUIMenu::s_PerformanceMenu[] = { - {"Load", PerformanceMenu, 0, 0}, - {"Save", MenuHandler, s_SaveMenu}, - {"Delete", PerformanceMenu, 0, 1}, + {"Load", PerformanceMenu, 0, 0}, + {"Save", MenuHandler, s_SaveMenu}, + {"Delete", PerformanceMenu, 0, 1}, + {"Random", CUIMenu::GenerateRandomPerformance, nullptr, 0}, {0} }; - -CUIMenu::CUIMenu (CUserInterface *pUI, CMiniDexed *pMiniDexed) -: m_pUI (pUI), - m_pMiniDexed (pMiniDexed), - m_pParentMenu (s_MenuRoot), - m_pCurrentMenu (s_MainMenu), - m_nCurrentMenuItem (0), - m_nCurrentSelection (0), - m_nCurrentParameter (0), - m_nCurrentMenuDepth (0) +CUIMenu::CUIMenu(CUserInterface *pUI, CMiniDexed *pMiniDexed) + : m_pUI(pUI), + m_pMiniDexed(pMiniDexed), + m_pParentMenu(s_MenuRoot), + m_pCurrentMenu(s_MainMenu), + m_nCurrentMenuItem(0), + m_nCurrentSelection(0), + m_nCurrentParameter(0), + m_nCurrentMenuDepth(0) { #ifndef ARM_ALLOW_MULTI_CORE // If there is just one core, then there is only a single @@ -351,17 +358,17 @@ CUIMenu::CUIMenu (CUserInterface *pUI, CMiniDexed *pMiniDexed) // Place the "root" menu at the top of the stack m_MenuStackParent[0] = s_MenuRoot; m_MenuStackMenu[0] = s_MainMenu; - m_nMenuStackItem[0] = 0; + m_nMenuStackItem[0] = 0; m_nMenuStackSelection[0] = 0; m_nMenuStackParameter[0] = 0; #endif } -void CUIMenu::EventHandler (TMenuEvent Event) +void CUIMenu::EventHandler(TMenuEvent Event) { switch (Event) { - case MenuEventBack: // pop menu + case MenuEventBack: // pop menu if (m_nCurrentMenuDepth) { m_nCurrentMenuDepth--; @@ -372,7 +379,7 @@ void CUIMenu::EventHandler (TMenuEvent Event) m_nCurrentSelection = m_nMenuStackSelection[m_nCurrentMenuDepth]; m_nCurrentParameter = m_nMenuStackParameter[m_nCurrentMenuDepth]; - EventHandler (MenuEventUpdate); + EventHandler(MenuEventUpdate); } break; @@ -399,32 +406,29 @@ void CUIMenu::EventHandler (TMenuEvent Event) m_nMenuStackSelection[0] = 0; m_nMenuStackParameter[0] = 0; #endif - EventHandler (MenuEventUpdate); + EventHandler(MenuEventUpdate); break; default: - (*m_pParentMenu[m_nCurrentMenuItem].Handler) (this, Event); + (*m_pParentMenu[m_nCurrentMenuItem].Handler)(this, Event); break; } } -void CUIMenu::MenuHandler (CUIMenu *pUIMenu, TMenuEvent Event) +void CUIMenu::MenuHandler(CUIMenu *pUIMenu, TMenuEvent Event) { switch (Event) { case MenuEventUpdate: break; - case MenuEventSelect: // push menu - assert (pUIMenu->m_nCurrentMenuDepth < MaxMenuDepth); + case MenuEventSelect: // push menu + assert(pUIMenu->m_nCurrentMenuDepth < MaxMenuDepth); pUIMenu->m_MenuStackParent[pUIMenu->m_nCurrentMenuDepth] = pUIMenu->m_pParentMenu; pUIMenu->m_MenuStackMenu[pUIMenu->m_nCurrentMenuDepth] = pUIMenu->m_pCurrentMenu; - pUIMenu->m_nMenuStackItem[pUIMenu->m_nCurrentMenuDepth] - = pUIMenu->m_nCurrentMenuItem; - pUIMenu->m_nMenuStackSelection[pUIMenu->m_nCurrentMenuDepth] - = pUIMenu->m_nCurrentSelection; - pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth] - = pUIMenu->m_nCurrentParameter; + pUIMenu->m_nMenuStackItem[pUIMenu->m_nCurrentMenuDepth] = pUIMenu->m_nCurrentMenuItem; + pUIMenu->m_nMenuStackSelection[pUIMenu->m_nCurrentMenuDepth] = pUIMenu->m_nCurrentSelection; + pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth] = pUIMenu->m_nCurrentParameter; pUIMenu->m_nCurrentMenuDepth++; pUIMenu->m_pParentMenu = pUIMenu->m_pCurrentMenu; @@ -445,7 +449,7 @@ void CUIMenu::MenuHandler (CUIMenu *pUIMenu, TMenuEvent Event) case MenuEventStepUp: ++pUIMenu->m_nCurrentSelection; - if (!pUIMenu->m_pCurrentMenu[pUIMenu->m_nCurrentSelection].Name) // more entries? + if (!pUIMenu->m_pCurrentMenu[pUIMenu->m_nCurrentSelection].Name) // more entries? { pUIMenu->m_nCurrentSelection--; } @@ -455,27 +459,27 @@ void CUIMenu::MenuHandler (CUIMenu *pUIMenu, TMenuEvent Event) return; } - if (pUIMenu->m_pCurrentMenu) // if this is another menu? + if (pUIMenu->m_pCurrentMenu) // if this is another menu? { - pUIMenu->m_pUI->DisplayWrite ( + pUIMenu->m_pUI->DisplayWrite( pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name, "", pUIMenu->m_pCurrentMenu[pUIMenu->m_nCurrentSelection].Name, pUIMenu->m_nCurrentSelection > 0, - !!pUIMenu->m_pCurrentMenu[pUIMenu->m_nCurrentSelection+1].Name); + !!pUIMenu->m_pCurrentMenu[pUIMenu->m_nCurrentSelection + 1].Name); } else { - pUIMenu->EventHandler (MenuEventUpdate); // no, update parameter display + pUIMenu->EventHandler(MenuEventUpdate); // no, update parameter display } } -void CUIMenu::EditGlobalParameter (CUIMenu *pUIMenu, TMenuEvent Event) +void CUIMenu::EditGlobalParameter(CUIMenu *pUIMenu, TMenuEvent Event) { - CMiniDexed::TParameter Param = (CMiniDexed::TParameter) pUIMenu->m_nCurrentParameter; + CMiniDexed::TParameter Param = (CMiniDexed::TParameter)pUIMenu->m_nCurrentParameter; const TParameter &rParam = s_GlobalParameter[Param]; - int nValue = pUIMenu->m_pMiniDexed->GetParameter (Param); + int nValue = pUIMenu->m_pMiniDexed->GetParameter(Param); switch (Event) { @@ -488,7 +492,7 @@ void CUIMenu::EditGlobalParameter (CUIMenu *pUIMenu, TMenuEvent Event) { nValue = rParam.Minimum; } - pUIMenu->m_pMiniDexed->SetParameter (Param, nValue); + pUIMenu->m_pMiniDexed->SetParameter(Param, nValue); break; case MenuEventStepUp: @@ -497,7 +501,7 @@ void CUIMenu::EditGlobalParameter (CUIMenu *pUIMenu, TMenuEvent Event) { nValue = rParam.Maximum; } - pUIMenu->m_pMiniDexed->SetParameter (Param, nValue); + pUIMenu->m_pMiniDexed->SetParameter(Param, nValue); break; default: @@ -505,22 +509,23 @@ void CUIMenu::EditGlobalParameter (CUIMenu *pUIMenu, TMenuEvent Event) } const char *pMenuName = - pUIMenu->m_MenuStackParent[pUIMenu->m_nCurrentMenuDepth-1] - [pUIMenu->m_nMenuStackItem[pUIMenu->m_nCurrentMenuDepth-1]].Name; + pUIMenu->m_MenuStackParent[pUIMenu->m_nCurrentMenuDepth - 1] + [pUIMenu->m_nMenuStackItem[pUIMenu->m_nCurrentMenuDepth - 1]] + .Name; - string Value = GetGlobalValueString (Param, pUIMenu->m_pMiniDexed->GetParameter (Param)); + string Value = GetGlobalValueString(Param, pUIMenu->m_pMiniDexed->GetParameter(Param)); - pUIMenu->m_pUI->DisplayWrite (pMenuName, - pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name, - Value.c_str (), - nValue > rParam.Minimum, nValue < rParam.Maximum); + pUIMenu->m_pUI->DisplayWrite(pMenuName, + pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name, + Value.c_str(), + nValue > rParam.Minimum, nValue < rParam.Maximum); } -void CUIMenu::EditVoiceBankNumber (CUIMenu *pUIMenu, TMenuEvent Event) +void CUIMenu::EditVoiceBankNumber(CUIMenu *pUIMenu, TMenuEvent Event) { - unsigned nTG = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth-1]; + unsigned nTG = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth - 1]; - int nValue = pUIMenu->m_pMiniDexed->GetTGParameter (CMiniDexed::TGParameterVoiceBank, nTG); + int nValue = pUIMenu->m_pMiniDexed->GetTGParameter(CMiniDexed::TGParameterVoiceBank, nTG); switch (Event) { @@ -528,43 +533,42 @@ void CUIMenu::EditVoiceBankNumber (CUIMenu *pUIMenu, TMenuEvent Event) break; case MenuEventStepDown: - nValue = pUIMenu->m_pMiniDexed->GetSysExFileLoader ()->GetNextBankDown(nValue); - pUIMenu->m_pMiniDexed->SetTGParameter ( + nValue = pUIMenu->m_pMiniDexed->GetSysExFileLoader()->GetNextBankDown(nValue); + pUIMenu->m_pMiniDexed->SetTGParameter( CMiniDexed::TGParameterVoiceBank, nValue, nTG); break; case MenuEventStepUp: - nValue = pUIMenu->m_pMiniDexed->GetSysExFileLoader ()->GetNextBankUp(nValue); - pUIMenu->m_pMiniDexed->SetTGParameter ( + nValue = pUIMenu->m_pMiniDexed->GetSysExFileLoader()->GetNextBankUp(nValue); + pUIMenu->m_pMiniDexed->SetTGParameter( CMiniDexed::TGParameterVoiceBank, nValue, nTG); break; case MenuEventPressAndStepDown: case MenuEventPressAndStepUp: - pUIMenu->TGShortcutHandler (Event); + pUIMenu->TGShortcutHandler(Event); return; default: return; } - string TG ("TG"); - TG += to_string (nTG+1); + string TG("TG"); + TG += to_string(nTG + 1); - string Value = to_string (nValue+1) + "=" - + pUIMenu->m_pMiniDexed->GetSysExFileLoader ()->GetBankName (nValue); + string Value = to_string(nValue + 1) + "=" + pUIMenu->m_pMiniDexed->GetSysExFileLoader()->GetBankName(nValue); - pUIMenu->m_pUI->DisplayWrite (TG.c_str (), - pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name, - Value.c_str (), - nValue > 0, nValue < (int) CSysExFileLoader::MaxVoiceBankID); + pUIMenu->m_pUI->DisplayWrite(TG.c_str(), + pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name, + Value.c_str(), + nValue > 0, nValue < (int)CSysExFileLoader::MaxVoiceBankID); } -void CUIMenu::EditProgramNumber (CUIMenu *pUIMenu, TMenuEvent Event) +void CUIMenu::EditProgramNumber(CUIMenu *pUIMenu, TMenuEvent Event) { - unsigned nTG = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth-1]; + unsigned nTG = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth - 1]; - int nValue = pUIMenu->m_pMiniDexed->GetTGParameter (CMiniDexed::TGParameterProgram, nTG); + int nValue = pUIMenu->m_pMiniDexed->GetTGParameter(CMiniDexed::TGParameterProgram, nTG); switch (Event) { @@ -575,68 +579,69 @@ void CUIMenu::EditProgramNumber (CUIMenu *pUIMenu, TMenuEvent Event) if (--nValue < 0) { // Switch down a voice bank and set to the last voice - nValue = CSysExFileLoader::VoicesPerBank-1; + nValue = CSysExFileLoader::VoicesPerBank - 1; int nVB = pUIMenu->m_pMiniDexed->GetTGParameter(CMiniDexed::TGParameterVoiceBank, nTG); - nVB = pUIMenu->m_pMiniDexed->GetSysExFileLoader ()->GetNextBankDown(nVB); - pUIMenu->m_pMiniDexed->SetTGParameter (CMiniDexed::TGParameterVoiceBank, nVB, nTG); + nVB = pUIMenu->m_pMiniDexed->GetSysExFileLoader()->GetNextBankDown(nVB); + pUIMenu->m_pMiniDexed->SetTGParameter(CMiniDexed::TGParameterVoiceBank, nVB, nTG); } - pUIMenu->m_pMiniDexed->SetTGParameter (CMiniDexed::TGParameterProgram, nValue, nTG); + pUIMenu->m_pMiniDexed->SetTGParameter(CMiniDexed::TGParameterProgram, nValue, nTG); break; case MenuEventStepUp: - if (++nValue > (int) CSysExFileLoader::VoicesPerBank-1) + if (++nValue > (int)CSysExFileLoader::VoicesPerBank - 1) { // Switch up a voice bank and reset to voice 0 nValue = 0; int nVB = pUIMenu->m_pMiniDexed->GetTGParameter(CMiniDexed::TGParameterVoiceBank, nTG); - nVB = pUIMenu->m_pMiniDexed->GetSysExFileLoader ()->GetNextBankUp(nVB); - pUIMenu->m_pMiniDexed->SetTGParameter (CMiniDexed::TGParameterVoiceBank, nVB, nTG); + nVB = pUIMenu->m_pMiniDexed->GetSysExFileLoader()->GetNextBankUp(nVB); + pUIMenu->m_pMiniDexed->SetTGParameter(CMiniDexed::TGParameterVoiceBank, nVB, nTG); } - pUIMenu->m_pMiniDexed->SetTGParameter (CMiniDexed::TGParameterProgram, nValue, nTG); + pUIMenu->m_pMiniDexed->SetTGParameter(CMiniDexed::TGParameterProgram, nValue, nTG); break; case MenuEventPressAndStepDown: case MenuEventPressAndStepUp: - pUIMenu->TGShortcutHandler (Event); + pUIMenu->TGShortcutHandler(Event); return; default: return; } - string voiceName = pUIMenu->m_pMiniDexed->GetVoiceName (nTG); // Skip empty voices - if (voiceName == "EMPTY " - || voiceName == " " - || voiceName == "----------" - || voiceName == "~~~~~~~~~~" ) + string voiceName = pUIMenu->m_pMiniDexed->GetVoiceName(nTG); // Skip empty voices + if (voiceName == "EMPTY " || voiceName == " " || voiceName == "----------" || voiceName == "~~~~~~~~~~") { - if (Event == MenuEventStepUp) { - CUIMenu::EditProgramNumber (pUIMenu, MenuEventStepUp); + if (Event == MenuEventStepUp) + { + CUIMenu::EditProgramNumber(pUIMenu, MenuEventStepUp); } - if (Event == MenuEventStepDown) { - CUIMenu::EditProgramNumber (pUIMenu, MenuEventStepDown); + if (Event == MenuEventStepDown) + { + CUIMenu::EditProgramNumber(pUIMenu, MenuEventStepDown); } - } else { - string TG ("TG"); - TG += to_string (nTG+1); + } + else + { + string TG("TG"); + TG += to_string(nTG + 1); - string Value = to_string (nValue+1) + "=" + pUIMenu->m_pMiniDexed->GetVoiceName (nTG); + string Value = to_string(nValue + 1) + "=" + pUIMenu->m_pMiniDexed->GetVoiceName(nTG); - pUIMenu->m_pUI->DisplayWrite (TG.c_str (), - pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name, - Value.c_str (), - nValue > 0, nValue < (int) CSysExFileLoader::VoicesPerBank-1); + pUIMenu->m_pUI->DisplayWrite(TG.c_str(), + pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name, + Value.c_str(), + nValue > 0, nValue < (int)CSysExFileLoader::VoicesPerBank - 1); } } -void CUIMenu::EditTGParameter (CUIMenu *pUIMenu, TMenuEvent Event) +void CUIMenu::EditTGParameter(CUIMenu *pUIMenu, TMenuEvent Event) { - unsigned nTG = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth-1]; + unsigned nTG = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth - 1]; - CMiniDexed::TTGParameter Param = (CMiniDexed::TTGParameter) pUIMenu->m_nCurrentParameter; + CMiniDexed::TTGParameter Param = (CMiniDexed::TTGParameter)pUIMenu->m_nCurrentParameter; const TParameter &rParam = s_TGParameter[Param]; - int nValue = pUIMenu->m_pMiniDexed->GetTGParameter (Param, nTG); + int nValue = pUIMenu->m_pMiniDexed->GetTGParameter(Param, nTG); switch (Event) { @@ -649,7 +654,7 @@ void CUIMenu::EditTGParameter (CUIMenu *pUIMenu, TMenuEvent Event) { nValue = rParam.Minimum; } - pUIMenu->m_pMiniDexed->SetTGParameter (Param, nValue, nTG); + pUIMenu->m_pMiniDexed->SetTGParameter(Param, nValue, nTG); break; case MenuEventStepUp: @@ -658,38 +663,38 @@ void CUIMenu::EditTGParameter (CUIMenu *pUIMenu, TMenuEvent Event) { nValue = rParam.Maximum; } - pUIMenu->m_pMiniDexed->SetTGParameter (Param, nValue, nTG); + pUIMenu->m_pMiniDexed->SetTGParameter(Param, nValue, nTG); break; case MenuEventPressAndStepDown: case MenuEventPressAndStepUp: - pUIMenu->TGShortcutHandler (Event); + pUIMenu->TGShortcutHandler(Event); return; default: return; } - string TG ("TG"); - TG += to_string (nTG+1); + string TG("TG"); + TG += to_string(nTG + 1); - string Value = GetTGValueString (Param, pUIMenu->m_pMiniDexed->GetTGParameter (Param, nTG)); + string Value = GetTGValueString(Param, pUIMenu->m_pMiniDexed->GetTGParameter(Param, nTG)); - pUIMenu->m_pUI->DisplayWrite (TG.c_str (), - pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name, - Value.c_str (), - nValue > rParam.Minimum, nValue < rParam.Maximum); + pUIMenu->m_pUI->DisplayWrite(TG.c_str(), + pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name, + Value.c_str(), + nValue > rParam.Minimum, nValue < rParam.Maximum); } -void CUIMenu::EditTGParameter2 (CUIMenu *pUIMenu, TMenuEvent Event) // second menu level. Redundant code but in order to not modified original code +void CUIMenu::EditTGParameter2(CUIMenu *pUIMenu, TMenuEvent Event) // second menu level. Redundant code but in order to not modified original code { - unsigned nTG = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth-2]; + unsigned nTG = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth - 2]; - CMiniDexed::TTGParameter Param = (CMiniDexed::TTGParameter) pUIMenu->m_nCurrentParameter; + CMiniDexed::TTGParameter Param = (CMiniDexed::TTGParameter)pUIMenu->m_nCurrentParameter; const TParameter &rParam = s_TGParameter[Param]; - int nValue = pUIMenu->m_pMiniDexed->GetTGParameter (Param, nTG); + int nValue = pUIMenu->m_pMiniDexed->GetTGParameter(Param, nTG); switch (Event) { @@ -702,7 +707,7 @@ void CUIMenu::EditTGParameter2 (CUIMenu *pUIMenu, TMenuEvent Event) // second me { nValue = rParam.Minimum; } - pUIMenu->m_pMiniDexed->SetTGParameter (Param, nValue, nTG); + pUIMenu->m_pMiniDexed->SetTGParameter(Param, nValue, nTG); break; case MenuEventStepUp: @@ -711,38 +716,37 @@ void CUIMenu::EditTGParameter2 (CUIMenu *pUIMenu, TMenuEvent Event) // second me { nValue = rParam.Maximum; } - pUIMenu->m_pMiniDexed->SetTGParameter (Param, nValue, nTG); + pUIMenu->m_pMiniDexed->SetTGParameter(Param, nValue, nTG); break; case MenuEventPressAndStepDown: case MenuEventPressAndStepUp: - pUIMenu->TGShortcutHandler (Event); + pUIMenu->TGShortcutHandler(Event); return; default: return; } - string TG ("TG"); - TG += to_string (nTG+1); + string TG("TG"); + TG += to_string(nTG + 1); - string Value = GetTGValueString (Param, pUIMenu->m_pMiniDexed->GetTGParameter (Param, nTG)); + string Value = GetTGValueString(Param, pUIMenu->m_pMiniDexed->GetTGParameter(Param, nTG)); - pUIMenu->m_pUI->DisplayWrite (TG.c_str (), - pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name, - Value.c_str (), - nValue > rParam.Minimum, nValue < rParam.Maximum); - + pUIMenu->m_pUI->DisplayWrite(TG.c_str(), + pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name, + Value.c_str(), + nValue > rParam.Minimum, nValue < rParam.Maximum); } -void CUIMenu::EditVoiceParameter (CUIMenu *pUIMenu, TMenuEvent Event) +void CUIMenu::EditVoiceParameter(CUIMenu *pUIMenu, TMenuEvent Event) { - unsigned nTG = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth-2]; + unsigned nTG = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth - 2]; unsigned nParam = pUIMenu->m_nCurrentParameter; const TParameter &rParam = s_VoiceParameter[nParam]; - int nValue = pUIMenu->m_pMiniDexed->GetVoiceParameter (nParam, CMiniDexed::NoOP, nTG); + int nValue = pUIMenu->m_pMiniDexed->GetVoiceParameter(nParam, CMiniDexed::NoOP, nTG); switch (Event) { @@ -755,7 +759,7 @@ void CUIMenu::EditVoiceParameter (CUIMenu *pUIMenu, TMenuEvent Event) { nValue = rParam.Minimum; } - pUIMenu->m_pMiniDexed->SetVoiceParameter (nParam, nValue, CMiniDexed::NoOP, nTG); + pUIMenu->m_pMiniDexed->SetVoiceParameter(nParam, nValue, CMiniDexed::NoOP, nTG); break; case MenuEventStepUp: @@ -764,38 +768,38 @@ void CUIMenu::EditVoiceParameter (CUIMenu *pUIMenu, TMenuEvent Event) { nValue = rParam.Maximum; } - pUIMenu->m_pMiniDexed->SetVoiceParameter (nParam, nValue, CMiniDexed::NoOP, nTG); + pUIMenu->m_pMiniDexed->SetVoiceParameter(nParam, nValue, CMiniDexed::NoOP, nTG); break; case MenuEventPressAndStepDown: case MenuEventPressAndStepUp: - pUIMenu->TGShortcutHandler (Event); + pUIMenu->TGShortcutHandler(Event); return; default: return; } - string TG ("TG"); - TG += to_string (nTG+1); + string TG("TG"); + TG += to_string(nTG + 1); - string Value = GetVoiceValueString (nParam, nValue); + string Value = GetVoiceValueString(nParam, nValue); - pUIMenu->m_pUI->DisplayWrite (TG.c_str (), - pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name, - Value.c_str (), - nValue > rParam.Minimum, nValue < rParam.Maximum); + pUIMenu->m_pUI->DisplayWrite(TG.c_str(), + pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name, + Value.c_str(), + nValue > rParam.Minimum, nValue < rParam.Maximum); } -void CUIMenu::EditOPParameter (CUIMenu *pUIMenu, TMenuEvent Event) +void CUIMenu::EditOPParameter(CUIMenu *pUIMenu, TMenuEvent Event) { - unsigned nTG = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth-3]; - unsigned nOP = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth-1]; + unsigned nTG = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth - 3]; + unsigned nOP = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth - 1]; unsigned nParam = pUIMenu->m_nCurrentParameter; const TParameter &rParam = s_OPParameter[nParam]; - int nValue = pUIMenu->m_pMiniDexed->GetVoiceParameter (nParam, nOP, nTG); + int nValue = pUIMenu->m_pMiniDexed->GetVoiceParameter(nParam, nOP, nTG); switch (Event) { @@ -808,7 +812,7 @@ void CUIMenu::EditOPParameter (CUIMenu *pUIMenu, TMenuEvent Event) { nValue = rParam.Minimum; } - pUIMenu->m_pMiniDexed->SetVoiceParameter (nParam, nValue, nOP, nTG); + pUIMenu->m_pMiniDexed->SetVoiceParameter(nParam, nValue, nOP, nTG); break; case MenuEventStepUp: @@ -817,27 +821,27 @@ void CUIMenu::EditOPParameter (CUIMenu *pUIMenu, TMenuEvent Event) { nValue = rParam.Maximum; } - pUIMenu->m_pMiniDexed->SetVoiceParameter (nParam, nValue, nOP, nTG); + pUIMenu->m_pMiniDexed->SetVoiceParameter(nParam, nValue, nOP, nTG); break; case MenuEventPressAndStepDown: case MenuEventPressAndStepUp: - pUIMenu->OPShortcutHandler (Event); + pUIMenu->OPShortcutHandler(Event); return; default: return; } - string OP ("OP"); - OP += to_string (nOP+1); + string OP("OP"); + OP += to_string(nOP + 1); string Value; static const int FixedMultiplier[4] = {1, 10, 100, 1000}; if (nParam == DEXED_OP_FREQ_COARSE) { - if (!pUIMenu->m_pMiniDexed->GetVoiceParameter (DEXED_OP_OSC_MODE, nOP, nTG)) + if (!pUIMenu->m_pMiniDexed->GetVoiceParameter(DEXED_OP_OSC_MODE, nOP, nTG)) { // Ratio if (!nValue) @@ -846,241 +850,245 @@ void CUIMenu::EditOPParameter (CUIMenu *pUIMenu, TMenuEvent Event) } else { - Value = to_string (nValue); + Value = to_string(nValue); Value += ".00"; } } else { // Fixed - Value = to_string (FixedMultiplier[nValue % 4]); + Value = to_string(FixedMultiplier[nValue % 4]); } } else if (nParam == DEXED_OP_FREQ_FINE) { - int nCoarse = pUIMenu->m_pMiniDexed->GetVoiceParameter ( - DEXED_OP_FREQ_COARSE, nOP, nTG); + int nCoarse = pUIMenu->m_pMiniDexed->GetVoiceParameter( + DEXED_OP_FREQ_COARSE, nOP, nTG); char Buffer[20]; - if (!pUIMenu->m_pMiniDexed->GetVoiceParameter (DEXED_OP_OSC_MODE, nOP, nTG)) + if (!pUIMenu->m_pMiniDexed->GetVoiceParameter(DEXED_OP_OSC_MODE, nOP, nTG)) { // Ratio float fValue = 1.0f + nValue / 100.0f; - fValue *= !nCoarse ? 0.5f : (float) nCoarse; - sprintf (Buffer, "%.2f", (double) fValue); + fValue *= !nCoarse ? 0.5f : (float)nCoarse; + sprintf(Buffer, "%.2f", (double)fValue); } else { // Fixed - float fValue = powf (1.023293f, (float) nValue); - fValue *= (float) FixedMultiplier[nCoarse % 4]; - sprintf (Buffer, "%.3fHz", (double) fValue); + float fValue = powf(1.023293f, (float)nValue); + fValue *= (float)FixedMultiplier[nCoarse % 4]; + sprintf(Buffer, "%.3fHz", (double)fValue); } Value = Buffer; } else { - Value = GetOPValueString (nParam, nValue); + Value = GetOPValueString(nParam, nValue); } - pUIMenu->m_pUI->DisplayWrite (OP.c_str (), - pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name, - Value.c_str (), - nValue > rParam.Minimum, nValue < rParam.Maximum); + pUIMenu->m_pUI->DisplayWrite(OP.c_str(), + pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name, + Value.c_str(), + nValue > rParam.Minimum, nValue < rParam.Maximum); } -void CUIMenu::SavePerformance (CUIMenu *pUIMenu, TMenuEvent Event) +void CUIMenu::SavePerformance(CUIMenu *pUIMenu, TMenuEvent Event) { if (Event != MenuEventUpdate) { return; } - bool bOK = pUIMenu->m_pMiniDexed->SavePerformance (pUIMenu->m_nCurrentParameter == 1); + bool bOK = pUIMenu->m_pMiniDexed->SavePerformance(pUIMenu->m_nCurrentParameter == 1); const char *pMenuName = - pUIMenu->m_MenuStackParent[pUIMenu->m_nCurrentMenuDepth-1] - [pUIMenu->m_nMenuStackItem[pUIMenu->m_nCurrentMenuDepth-1]].Name; + pUIMenu->m_MenuStackParent[pUIMenu->m_nCurrentMenuDepth - 1] + [pUIMenu->m_nMenuStackItem[pUIMenu->m_nCurrentMenuDepth - 1]] + .Name; - pUIMenu->m_pUI->DisplayWrite (pMenuName, - pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name, - bOK ? "Completed" : "Error", - false, false); + pUIMenu->m_pUI->DisplayWrite(pMenuName, + pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name, + bOK ? "Completed" : "Error", + false, false); - CTimer::Get ()->StartKernelTimer (MSEC2HZ (1500), TimerHandler, 0, pUIMenu); + CTimer::Get()->StartKernelTimer(MSEC2HZ(1500), TimerHandler, 0, pUIMenu); } -string CUIMenu::GetGlobalValueString (unsigned nParameter, int nValue) +string CUIMenu::GetGlobalValueString(unsigned nParameter, int nValue) { string Result; - assert (nParameter < sizeof CUIMenu::s_GlobalParameter / sizeof CUIMenu::s_GlobalParameter[0]); + assert(nParameter < sizeof CUIMenu::s_GlobalParameter / sizeof CUIMenu::s_GlobalParameter[0]); CUIMenu::TToString *pToString = CUIMenu::s_GlobalParameter[nParameter].ToString; if (pToString) { - Result = (*pToString) (nValue); + Result = (*pToString)(nValue); } else { - Result = to_string (nValue); + Result = to_string(nValue); } return Result; } -string CUIMenu::GetTGValueString (unsigned nTGParameter, int nValue) +string CUIMenu::GetTGValueString(unsigned nTGParameter, int nValue) { string Result; - assert (nTGParameter < sizeof CUIMenu::s_TGParameter / sizeof CUIMenu::s_TGParameter[0]); + assert(nTGParameter < sizeof CUIMenu::s_TGParameter / sizeof CUIMenu::s_TGParameter[0]); CUIMenu::TToString *pToString = CUIMenu::s_TGParameter[nTGParameter].ToString; if (pToString) { - Result = (*pToString) (nValue); + Result = (*pToString)(nValue); } else { - Result = to_string (nValue); + Result = to_string(nValue); } return Result; } -string CUIMenu::GetVoiceValueString (unsigned nVoiceParameter, int nValue) +string CUIMenu::GetVoiceValueString(unsigned nVoiceParameter, int nValue) { string Result; - assert (nVoiceParameter < sizeof CUIMenu::s_VoiceParameter / sizeof CUIMenu::s_VoiceParameter[0]); + assert(nVoiceParameter < sizeof CUIMenu::s_VoiceParameter / sizeof CUIMenu::s_VoiceParameter[0]); CUIMenu::TToString *pToString = CUIMenu::s_VoiceParameter[nVoiceParameter].ToString; if (pToString) { - Result = (*pToString) (nValue); + Result = (*pToString)(nValue); } else { - Result = to_string (nValue); + Result = to_string(nValue); } return Result; } -string CUIMenu::GetOPValueString (unsigned nOPParameter, int nValue) +string CUIMenu::GetOPValueString(unsigned nOPParameter, int nValue) { string Result; - assert (nOPParameter < sizeof CUIMenu::s_OPParameter / sizeof CUIMenu::s_OPParameter[0]); + assert(nOPParameter < sizeof CUIMenu::s_OPParameter / sizeof CUIMenu::s_OPParameter[0]); CUIMenu::TToString *pToString = CUIMenu::s_OPParameter[nOPParameter].ToString; if (pToString) { - Result = (*pToString) (nValue); + Result = (*pToString)(nValue); } else { - Result = to_string (nValue); + Result = to_string(nValue); } return Result; } -string CUIMenu::ToVolume (int nValue) +string CUIMenu::ToVolume(int nValue) { - static const size_t MaxChars = CConfig::LCDColumns-2; - char VolumeBar[MaxChars+1]; - memset (VolumeBar, 0xFF, sizeof VolumeBar); // 0xFF is the block character + static const size_t MaxChars = CConfig::LCDColumns - 2; + char VolumeBar[MaxChars + 1]; + memset(VolumeBar, 0xFF, sizeof VolumeBar); // 0xFF is the block character VolumeBar[nValue * MaxChars / 127] = '\0'; return VolumeBar; } -string CUIMenu::ToPan (int nValue) +string CUIMenu::ToPan(int nValue) { - assert (CConfig::LCDColumns == 16); - static const size_t MaxChars = CConfig::LCDColumns-3; - char PanMarker[MaxChars+1] = "......:......"; + assert(CConfig::LCDColumns == 16); + static const size_t MaxChars = CConfig::LCDColumns - 3; + char PanMarker[MaxChars + 1] = "......:......"; unsigned nIndex = nValue * MaxChars / 127; if (nIndex == MaxChars) { nIndex--; } - PanMarker[nIndex] = '\xFF'; // 0xFF is the block character + PanMarker[nIndex] = '\xFF'; // 0xFF is the block character return PanMarker; } -string CUIMenu::ToMIDIChannel (int nValue) +string CUIMenu::ToMIDIChannel(int nValue) { switch (nValue) { - case CMIDIDevice::OmniMode: return "Omni"; - case CMIDIDevice::Disabled: return "Off"; - default: return to_string (nValue+1); + case CMIDIDevice::OmniMode: + return "Omni"; + case CMIDIDevice::Disabled: + return "Off"; + default: + return to_string(nValue + 1); } } -string CUIMenu::ToAlgorithm (int nValue) +string CUIMenu::ToAlgorithm(int nValue) { - return to_string (nValue + 1); + return to_string(nValue + 1); } -string CUIMenu::ToOnOff (int nValue) +string CUIMenu::ToOnOff(int nValue) { static const char *OnOff[] = {"Off", "On"}; - assert ((unsigned) nValue < sizeof OnOff / sizeof OnOff[0]); + assert((unsigned)nValue < sizeof OnOff / sizeof OnOff[0]); return OnOff[nValue]; } -string CUIMenu::ToLFOWaveform (int nValue) +string CUIMenu::ToLFOWaveform(int nValue) { static const char *Waveform[] = {"Triangle", "Saw down", "Saw up", - "Square", "Sine", "Sample/Hold"}; + "Square", "Sine", "Sample/Hold"}; - assert ((unsigned) nValue < sizeof Waveform / sizeof Waveform[0]); + assert((unsigned)nValue < sizeof Waveform / sizeof Waveform[0]); return Waveform[nValue]; } -string CUIMenu::ToTransposeNote (int nValue) +string CUIMenu::ToTransposeNote(int nValue) { nValue += NoteC3 - 24; - assert ((unsigned) nValue < sizeof s_NoteName / sizeof s_NoteName[0]); + assert((unsigned)nValue < sizeof s_NoteName / sizeof s_NoteName[0]); return s_NoteName[nValue]; } -string CUIMenu::ToBreakpointNote (int nValue) +string CUIMenu::ToBreakpointNote(int nValue) { - assert ((unsigned) nValue < sizeof s_NoteName / sizeof s_NoteName[0]); + assert((unsigned)nValue < sizeof s_NoteName / sizeof s_NoteName[0]); return s_NoteName[nValue]; } -string CUIMenu::ToKeyboardCurve (int nValue) +string CUIMenu::ToKeyboardCurve(int nValue) { static const char *Curve[] = {"-Lin", "-Exp", "+Exp", "+Lin"}; - assert ((unsigned) nValue < sizeof Curve / sizeof Curve[0]); + assert((unsigned)nValue < sizeof Curve / sizeof Curve[0]); return Curve[nValue]; } -string CUIMenu::ToOscillatorMode (int nValue) +string CUIMenu::ToOscillatorMode(int nValue) { static const char *Mode[] = {"Ratio", "Fixed"}; - assert ((unsigned) nValue < sizeof Mode / sizeof Mode[0]); + assert((unsigned)nValue < sizeof Mode / sizeof Mode[0]); return Mode[nValue]; } -string CUIMenu::ToOscillatorDetune (int nValue) +string CUIMenu::ToOscillatorDetune(int nValue) { string Result; @@ -1088,57 +1096,65 @@ string CUIMenu::ToOscillatorDetune (int nValue) if (nValue > 0) { - Result = "+" + to_string (nValue); + Result = "+" + to_string(nValue); } else { - Result = to_string (nValue); + Result = to_string(nValue); } return Result; } -string CUIMenu::ToPortaMode (int nValue) +string CUIMenu::ToPortaMode(int nValue) { switch (nValue) { - case 0: return "Fingered"; - case 1: return "Full time"; - default: return to_string (nValue); + case 0: + return "Fingered"; + case 1: + return "Full time"; + default: + return to_string(nValue); } }; -string CUIMenu::ToPortaGlissando (int nValue) +string CUIMenu::ToPortaGlissando(int nValue) { switch (nValue) { - case 0: return "Off"; - case 1: return "On"; - default: return to_string (nValue); + case 0: + return "Off"; + case 1: + return "On"; + default: + return to_string(nValue); } }; -string CUIMenu::ToPolyMono (int nValue) +string CUIMenu::ToPolyMono(int nValue) { switch (nValue) { - case 0: return "Poly"; - case 1: return "Mono"; - default: return to_string (nValue); + case 0: + return "Poly"; + case 1: + return "Mono"; + default: + return to_string(nValue); } } -void CUIMenu::TGShortcutHandler (TMenuEvent Event) +void CUIMenu::TGShortcutHandler(TMenuEvent Event) { - assert (m_nCurrentMenuDepth >= 2); - assert (m_MenuStackMenu[0] = s_MainMenu); + assert(m_nCurrentMenuDepth >= 2); + assert(m_MenuStackMenu[0] = s_MainMenu); unsigned nTG = m_nMenuStackSelection[0]; - assert (nTG < CConfig::ToneGenerators); - assert (m_nMenuStackItem[1] == nTG); - assert (m_nMenuStackParameter[1] == nTG); + assert(nTG < CConfig::ToneGenerators); + assert(m_nMenuStackItem[1] == nTG); + assert(m_nMenuStackParameter[1] == nTG); - assert ( Event == MenuEventPressAndStepDown - || Event == MenuEventPressAndStepUp); + assert(Event == MenuEventPressAndStepDown || Event == MenuEventPressAndStepUp); if (Event == MenuEventPressAndStepDown) { nTG--; @@ -1154,21 +1170,20 @@ void CUIMenu::TGShortcutHandler (TMenuEvent Event) m_nMenuStackItem[1] = nTG; m_nMenuStackParameter[1] = nTG; - EventHandler (MenuEventUpdate); + EventHandler(MenuEventUpdate); } } -void CUIMenu::OPShortcutHandler (TMenuEvent Event) +void CUIMenu::OPShortcutHandler(TMenuEvent Event) { - assert (m_nCurrentMenuDepth >= 3); - assert (m_MenuStackMenu[m_nCurrentMenuDepth-2] = s_EditVoiceMenu); - unsigned nOP = m_nMenuStackSelection[m_nCurrentMenuDepth-2]; - assert (nOP < 6); - assert (m_nMenuStackItem[m_nCurrentMenuDepth-1] == nOP); - assert (m_nMenuStackParameter[m_nCurrentMenuDepth-1] == nOP); - - assert ( Event == MenuEventPressAndStepDown - || Event == MenuEventPressAndStepUp); + assert(m_nCurrentMenuDepth >= 3); + assert(m_MenuStackMenu[m_nCurrentMenuDepth - 2] = s_EditVoiceMenu); + unsigned nOP = m_nMenuStackSelection[m_nCurrentMenuDepth - 2]; + assert(nOP < 6); + assert(m_nMenuStackItem[m_nCurrentMenuDepth - 1] == nOP); + assert(m_nMenuStackParameter[m_nCurrentMenuDepth - 1] == nOP); + + assert(Event == MenuEventPressAndStepDown || Event == MenuEventPressAndStepUp); if (Event == MenuEventPressAndStepDown) { nOP--; @@ -1180,50 +1195,50 @@ void CUIMenu::OPShortcutHandler (TMenuEvent Event) if (nOP < 6) { - m_nMenuStackSelection[m_nCurrentMenuDepth-2] = nOP; - m_nMenuStackItem[m_nCurrentMenuDepth-1] = nOP; - m_nMenuStackParameter[m_nCurrentMenuDepth-1] = nOP; + m_nMenuStackSelection[m_nCurrentMenuDepth - 2] = nOP; + m_nMenuStackItem[m_nCurrentMenuDepth - 1] = nOP; + m_nMenuStackParameter[m_nCurrentMenuDepth - 1] = nOP; - EventHandler (MenuEventUpdate); + EventHandler(MenuEventUpdate); } } -void CUIMenu::TimerHandler (TKernelTimerHandle hTimer, void *pParam, void *pContext) +void CUIMenu::TimerHandler(TKernelTimerHandle hTimer, void *pParam, void *pContext) { - CUIMenu *pThis = static_cast (pContext); - assert (pThis); + CUIMenu *pThis = static_cast(pContext); + assert(pThis); - pThis->EventHandler (MenuEventBack); + pThis->EventHandler(MenuEventBack); } -void CUIMenu::TimerHandlerNoBack (TKernelTimerHandle hTimer, void *pParam, void *pContext) +void CUIMenu::TimerHandlerNoBack(TKernelTimerHandle hTimer, void *pParam, void *pContext) { - CUIMenu *pThis = static_cast (pContext); - assert (pThis); - + CUIMenu *pThis = static_cast(pContext); + assert(pThis); + pThis->m_bSplashShow = false; - - pThis->EventHandler (MenuEventUpdate); + + pThis->EventHandler(MenuEventUpdate); } -void CUIMenu::PerformanceMenu (CUIMenu *pUIMenu, TMenuEvent Event) +void CUIMenu::PerformanceMenu(CUIMenu *pUIMenu, TMenuEvent Event) { bool bPerformanceSelectToLoad = pUIMenu->m_pMiniDexed->GetPerformanceSelectToLoad(); unsigned nValue = pUIMenu->m_nSelectedPerformanceID; std::string Value; - + if (Event == MenuEventUpdate) { - pUIMenu->m_bPerformanceDeleteMode=false; + pUIMenu->m_bPerformanceDeleteMode = false; } - + if (pUIMenu->m_bSplashShow) { return; - } - - if(!pUIMenu->m_bPerformanceDeleteMode) - { + } + + if (!pUIMenu->m_bPerformanceDeleteMode) + { switch (Event) { case MenuEventUpdate: @@ -1235,39 +1250,39 @@ void CUIMenu::PerformanceMenu (CUIMenu *pUIMenu, TMenuEvent Event) --nValue; } pUIMenu->m_nSelectedPerformanceID = nValue; - if (!bPerformanceSelectToLoad && pUIMenu->m_nCurrentParameter==0) + if (!bPerformanceSelectToLoad && pUIMenu->m_nCurrentParameter == 0) { pUIMenu->m_pMiniDexed->SetNewPerformance(nValue); } break; case MenuEventStepUp: - if (++nValue > (unsigned) pUIMenu->m_pMiniDexed->GetLastPerformance()-1) + if (++nValue > (unsigned)pUIMenu->m_pMiniDexed->GetLastPerformance() - 1) { - nValue = pUIMenu->m_pMiniDexed->GetLastPerformance()-1; + nValue = pUIMenu->m_pMiniDexed->GetLastPerformance() - 1; } pUIMenu->m_nSelectedPerformanceID = nValue; - if (!bPerformanceSelectToLoad && pUIMenu->m_nCurrentParameter==0) + if (!bPerformanceSelectToLoad && pUIMenu->m_nCurrentParameter == 0) { pUIMenu->m_pMiniDexed->SetNewPerformance(nValue); } break; - case MenuEventSelect: + case MenuEventSelect: switch (pUIMenu->m_nCurrentParameter) { case 0: if (bPerformanceSelectToLoad) { - pUIMenu->m_pMiniDexed->SetNewPerformance(nValue); + pUIMenu->m_pMiniDexed->SetNewPerformance(nValue); } break; case 1: if (pUIMenu->m_nSelectedPerformanceID != 0) { - pUIMenu->m_bPerformanceDeleteMode=true; - pUIMenu->m_bConfirmDeletePerformance=false; + pUIMenu->m_bPerformanceDeleteMode = true; + pUIMenu->m_bConfirmDeletePerformance = false; } break; default: @@ -1286,60 +1301,59 @@ void CUIMenu::PerformanceMenu (CUIMenu *pUIMenu, TMenuEvent Event) break; case MenuEventStepDown: - pUIMenu->m_bConfirmDeletePerformance=false; + pUIMenu->m_bConfirmDeletePerformance = false; break; case MenuEventStepUp: - pUIMenu->m_bConfirmDeletePerformance=true; + pUIMenu->m_bConfirmDeletePerformance = true; break; - case MenuEventSelect: - pUIMenu->m_bPerformanceDeleteMode=false; + case MenuEventSelect: + pUIMenu->m_bPerformanceDeleteMode = false; if (pUIMenu->m_bConfirmDeletePerformance) { pUIMenu->m_nSelectedPerformanceID = 0; - pUIMenu->m_bConfirmDeletePerformance=false; - pUIMenu->m_pUI->DisplayWrite ("", "Delete", pUIMenu->m_pMiniDexed->DeletePerformance(nValue) ? "Completed" : "Error", false, false); - pUIMenu->m_bSplashShow=true; - CTimer::Get ()->StartKernelTimer (MSEC2HZ (1500), TimerHandlerNoBack, 0, pUIMenu); + pUIMenu->m_bConfirmDeletePerformance = false; + pUIMenu->m_pUI->DisplayWrite("", "Delete", pUIMenu->m_pMiniDexed->DeletePerformance(nValue) ? "Completed" : "Error", false, false); + pUIMenu->m_bSplashShow = true; + CTimer::Get()->StartKernelTimer(MSEC2HZ(1500), TimerHandlerNoBack, 0, pUIMenu); return; } else { break; } - + default: return; - } + } } - - if(!pUIMenu->m_bPerformanceDeleteMode) + + if (!pUIMenu->m_bPerformanceDeleteMode) { Value = pUIMenu->m_pMiniDexed->GetPerformanceName(nValue); - std::string nPSelected = ""; - if(nValue == pUIMenu->m_pMiniDexed->GetActualPerformanceID()) + if (nValue == pUIMenu->m_pMiniDexed->GetActualPerformanceID()) { - nPSelected= "[L]"; + nPSelected = "[L]"; } - - pUIMenu->m_pUI->DisplayWrite (pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name, nPSelected.c_str(), - Value.c_str (), - (int) nValue > 0, (int) nValue < (int) pUIMenu->m_pMiniDexed->GetLastPerformance()-1); + + pUIMenu->m_pUI->DisplayWrite(pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name, nPSelected.c_str(), + Value.c_str(), + (int)nValue > 0, (int)nValue < (int)pUIMenu->m_pMiniDexed->GetLastPerformance() - 1); } else { - pUIMenu->m_pUI->DisplayWrite ("", "Delete?", pUIMenu->m_bConfirmDeletePerformance ? "Yes" : "No", false, false); + pUIMenu->m_pUI->DisplayWrite("", "Delete?", pUIMenu->m_bConfirmDeletePerformance ? "Yes" : "No", false, false); } } -void CUIMenu::InputTxt (CUIMenu *pUIMenu, TMenuEvent Event) +void CUIMenu::InputTxt(CUIMenu *pUIMenu, TMenuEvent Event) { - unsigned nTG=0; - string TG ("TG"); - + unsigned nTG = 0; + string TG("TG"); + std::string MsgOk; std::string NoValidChars; unsigned MaxChars; @@ -1347,67 +1361,66 @@ void CUIMenu::InputTxt (CUIMenu *pUIMenu, TMenuEvent Event) std::string MenuTitleL; std::string OkTitleL; std::string OkTitleR; - - switch(pUIMenu->m_nCurrentParameter) + + switch (pUIMenu->m_nCurrentParameter) { - case 1: // save new performance - NoValidChars = {92, 47, 58, 42, 63, 34, 60,62, 124}; - MaxChars=14; - MenuTitleL="Performance Name"; - MenuTitleR=""; - OkTitleL="New Performance"; // \E[?25l - OkTitleR=""; - break; - - case 2: // Rename performance - NOT Implemented yet - NoValidChars = {92, 47, 58, 42, 63, 34, 60,62, 124}; - MaxChars=14; - MenuTitleL="Performance Name"; - MenuTitleR=""; - OkTitleL="Rename Perf."; // \E[?25l - OkTitleR=""; + case 1: // save new performance + NoValidChars = {92, 47, 58, 42, 63, 34, 60, 62, 124}; + MaxChars = 14; + MenuTitleL = "Performance Name"; + MenuTitleR = ""; + OkTitleL = "New Performance"; // \E[?25l + OkTitleR = ""; break; - - case 3: // Voice name - nTG = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth-2]; - NoValidChars = {127}; - MaxChars=10; - MenuTitleL="Name"; - TG += to_string (nTG+1); - MenuTitleR=TG; - OkTitleL=""; - OkTitleR=""; + + case 2: // Rename performance - NOT Implemented yet + NoValidChars = {92, 47, 58, 42, 63, 34, 60, 62, 124}; + MaxChars = 14; + MenuTitleL = "Performance Name"; + MenuTitleR = ""; + OkTitleL = "Rename Perf."; // \E[?25l + OkTitleR = ""; break; - - default: + + case 3: // Voice name + nTG = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth - 2]; + NoValidChars = {127}; + MaxChars = 10; + MenuTitleL = "Name"; + TG += to_string(nTG + 1); + MenuTitleR = TG; + OkTitleL = ""; + OkTitleR = ""; + break; + + default: return; } - + bool bOK; unsigned nPosition = pUIMenu->m_InputTextPosition; unsigned nChar = pUIMenu->m_InputText[nPosition]; - switch (Event) { case MenuEventUpdate: - if(pUIMenu->m_nCurrentParameter == 1 || pUIMenu->m_nCurrentParameter == 2) + if (pUIMenu->m_nCurrentParameter == 1 || pUIMenu->m_nCurrentParameter == 2) { pUIMenu->m_InputText = pUIMenu->m_pMiniDexed->GetNewPerformanceDefaultName(); pUIMenu->m_InputText += " "; - pUIMenu->m_InputText = pUIMenu->m_InputText.substr(0,14); - pUIMenu->m_InputTextPosition=0; - nPosition=pUIMenu->m_InputTextPosition; + pUIMenu->m_InputText = pUIMenu->m_InputText.substr(0, 14); + pUIMenu->m_InputTextPosition = 0; + nPosition = pUIMenu->m_InputTextPosition; nChar = pUIMenu->m_InputText[nPosition]; } else { - + pUIMenu->m_InputText = pUIMenu->m_pMiniDexed->GetVoiceName(nTG); pUIMenu->m_InputText += " "; - pUIMenu->m_InputText = pUIMenu->m_InputText.substr(0,10); - pUIMenu->m_InputTextPosition=0; - nPosition=pUIMenu->m_InputTextPosition; + pUIMenu->m_InputText = pUIMenu->m_InputText.substr(0, 10); + pUIMenu->m_InputTextPosition = 0; + nPosition = pUIMenu->m_InputTextPosition; nChar = pUIMenu->m_InputText[nPosition]; } break; @@ -1415,10 +1428,10 @@ void CUIMenu::InputTxt (CUIMenu *pUIMenu, TMenuEvent Event) case MenuEventStepDown: if (nChar > 32) { - do { - --nChar; - } - while (NoValidChars.find(nChar) != std::string::npos); + do + { + --nChar; + } while (NoValidChars.find(nChar) != std::string::npos); } pUIMenu->m_InputTextChar = nChar; break; @@ -1426,42 +1439,40 @@ void CUIMenu::InputTxt (CUIMenu *pUIMenu, TMenuEvent Event) case MenuEventStepUp: if (nChar < 126) { - do { + do + { ++nChar; - } - while (NoValidChars.find(nChar) != std::string::npos); + } while (NoValidChars.find(nChar) != std::string::npos); } pUIMenu->m_InputTextChar = nChar; - break; - - - - case MenuEventSelect: - if(pUIMenu->m_nCurrentParameter == 1) - { + break; + + case MenuEventSelect: + if (pUIMenu->m_nCurrentParameter == 1) + { pUIMenu->m_pMiniDexed->SetNewPerformanceName(pUIMenu->m_InputText); - bOK = pUIMenu->m_pMiniDexed->SavePerformanceNewFile (); - MsgOk=bOK ? "Completed" : "Error"; - pUIMenu->m_pUI->DisplayWrite (OkTitleR.c_str(), OkTitleL.c_str(), MsgOk.c_str(), false, false); - CTimer::Get ()->StartKernelTimer (MSEC2HZ (1500), TimerHandler, 0, pUIMenu); + bOK = pUIMenu->m_pMiniDexed->SavePerformanceNewFile(); + MsgOk = bOK ? "Completed" : "Error"; + pUIMenu->m_pUI->DisplayWrite(OkTitleR.c_str(), OkTitleL.c_str(), MsgOk.c_str(), false, false); + CTimer::Get()->StartKernelTimer(MSEC2HZ(1500), TimerHandler, 0, pUIMenu); return; } else { break; // Voice Name Edit } - + case MenuEventPressAndStepDown: if (nPosition > 0) - { - --nPosition; - } + { + --nPosition; + } pUIMenu->m_InputTextPosition = nPosition; nChar = pUIMenu->m_InputText[nPosition]; break; - + case MenuEventPressAndStepUp: - if (nPosition < MaxChars-1) + if (nPosition < MaxChars - 1) { ++nPosition; } @@ -1472,43 +1483,39 @@ void CUIMenu::InputTxt (CUIMenu *pUIMenu, TMenuEvent Event) default: return; } - - + // \E[2;%dH Cursor move to row %1 and column %2 (starting at 1) // \E[?25h Normal cursor visible // \E[?25l Cursor invisible - - std::string escCursor="\E[?25h\E[2;"; // this is to locate cursor + + std::string escCursor = "\E[?25h\E[2;"; // this is to locate cursor escCursor += to_string(nPosition + 2); escCursor += "H"; - std::string Value = pUIMenu->m_InputText; - Value[nPosition]=nChar; + Value[nPosition] = nChar; pUIMenu->m_InputText = Value; - - if(pUIMenu->m_nCurrentParameter == 3) - { - pUIMenu->m_pMiniDexed->SetVoiceName(pUIMenu->m_InputText, nTG); - } - - Value = Value + " " + escCursor ; - pUIMenu->m_pUI->DisplayWrite (MenuTitleR.c_str(),MenuTitleL.c_str(), Value.c_str(), false, false); - - + + if (pUIMenu->m_nCurrentParameter == 3) + { + pUIMenu->m_pMiniDexed->SetVoiceName(pUIMenu->m_InputText, nTG); + } + + Value = Value + " " + escCursor; + pUIMenu->m_pUI->DisplayWrite(MenuTitleR.c_str(), MenuTitleL.c_str(), Value.c_str(), false, false); } -void CUIMenu::EditTGParameterModulation (CUIMenu *pUIMenu, TMenuEvent Event) +void CUIMenu::EditTGParameterModulation(CUIMenu *pUIMenu, TMenuEvent Event) { - unsigned nTG = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth-3]; - unsigned nController = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth-1]; + unsigned nTG = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth - 3]; + unsigned nController = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth - 1]; unsigned nParameter = pUIMenu->m_nCurrentParameter + nController; - - CMiniDexed::TTGParameter Param = (CMiniDexed::TTGParameter) nParameter; + + CMiniDexed::TTGParameter Param = (CMiniDexed::TTGParameter)nParameter; const TParameter &rParam = s_TGParameter[Param]; - int nValue = pUIMenu->m_pMiniDexed->GetTGParameter (Param, nTG); + int nValue = pUIMenu->m_pMiniDexed->GetTGParameter(Param, nTG); switch (Event) { @@ -1521,7 +1528,7 @@ void CUIMenu::EditTGParameterModulation (CUIMenu *pUIMenu, TMenuEvent Event) { nValue = rParam.Minimum; } - pUIMenu->m_pMiniDexed->SetTGParameter (Param, nValue, nTG); + pUIMenu->m_pMiniDexed->SetTGParameter(Param, nValue, nTG); break; case MenuEventStepUp: @@ -1530,28 +1537,136 @@ void CUIMenu::EditTGParameterModulation (CUIMenu *pUIMenu, TMenuEvent Event) { nValue = rParam.Maximum; } - pUIMenu->m_pMiniDexed->SetTGParameter (Param, nValue, nTG); + pUIMenu->m_pMiniDexed->SetTGParameter(Param, nValue, nTG); break; case MenuEventPressAndStepDown: case MenuEventPressAndStepUp: - pUIMenu->TGShortcutHandler (Event); + pUIMenu->TGShortcutHandler(Event); return; default: return; } - string TG ("TG"); - TG += to_string (nTG+1); + string TG("TG"); + TG += to_string(nTG + 1); + + string Value = GetTGValueString(Param, pUIMenu->m_pMiniDexed->GetTGParameter(Param, nTG)); + + pUIMenu->m_pUI->DisplayWrite(TG.c_str(), + pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name, + Value.c_str(), + nValue > rParam.Minimum, nValue < rParam.Maximum); +} + +// RANDOMIZATION + +int CUIMenu::GetRandomValue(int min, int max) +{ + static std::mt19937 gen(std::chrono::duration_cast(std::chrono::high_resolution_clock::now().time_since_epoch()).count()); + + std::uniform_int_distribution dice(min, max); + + return dice(gen); +} + +void CUIMenu::GenerateRandomOperator(CUIMenu *pUIMenu, TMenuEvent Event) +{ + if (Event != TMenuEvent::MenuEventSelect) + { + return; + } + + size_t nTG = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth - 3]; + size_t nOP = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth - 1]; + + CUIMenu::GenerateRandomOperatorTG(pUIMenu, nTG, nOP); +} + +void CUIMenu::GenerateRandomOperatorTG(CUIMenu *pUIMenu, size_t nTG, size_t nOP) +{ + assert(nTG < CConfig::ToneGenerators); + assert(nOP <= OPERATORS::OP6); + + for (int nParam = DexedVoiceOPParameters::DEXED_OP_EG_R1; nParam <= DexedVoiceOPParameters::DEXED_OP_OSC_DETUNE; ++nParam) + { + TParameter param = CUIMenu::s_OPParameter[nParam]; + uint8_t value = (uint8_t)CUIMenu::GetRandomValue(param.Minimum, param.Maximum); + pUIMenu->m_pMiniDexed->SetVoiceParameter(nParam, value, nOP, nTG); + } +} + +void CUIMenu::GenerateRandomVoice(CUIMenu *pUIMenu, size_t nTG) +{ + assert(nTG < CConfig::ToneGenerators); + + for (size_t nOP = OPERATORS::OP1; nOP <= OPERATORS::OP6; ++nOP) + { + CUIMenu::GenerateRandomOperatorTG(pUIMenu, nTG, nOP); + } + + for (int nParam = DexedVoiceParameters::DEXED_PITCH_EG_R1; nParam < DexedVoiceParameters::DEXED_NAME; ++nParam) + { + TParameter param = CUIMenu::s_VoiceParameter[nParam]; + uint8_t value = (uint8_t)CUIMenu::GetRandomValue(param.Minimum, param.Maximum); + pUIMenu->m_pMiniDexed->SetVoiceParameter(nParam, value, CMiniDexed::NoOP, nTG); + } +} + +void CUIMenu::GenerateRandomPreset(CUIMenu *pUIMenu, TMenuEvent Event) +{ + if (Event != TMenuEvent::MenuEventSelect) + { + return; + } + + size_t nTG = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth - 1]; - string Value = GetTGValueString (Param, pUIMenu->m_pMiniDexed->GetTGParameter (Param, nTG)); + CUIMenu::GenerateRandomPresetTG(pUIMenu, nTG); +} - pUIMenu->m_pUI->DisplayWrite (TG.c_str (), - pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name, - Value.c_str (), - nValue > rParam.Minimum, nValue < rParam.Maximum); - +void CUIMenu::GenerateRandomPresetTG(CUIMenu *pUIMenu, size_t nTG) +{ + assert(nTG < CConfig::ToneGenerators); + + CUIMenu::GenerateRandomVoice(pUIMenu, nTG); + + for (int nParam = CMiniDexed::TTGParameter::TGParameterVolume; nParam < CMiniDexed::TTGParameter::TGParameterUnknown; ++nParam) + { + TParameter param = CUIMenu::s_TGParameter[nParam]; + uint8_t value = (uint8_t)CUIMenu::GetRandomValue(param.Minimum, param.Maximum); + pUIMenu->m_pMiniDexed->SetTGParameter(static_cast(nParam), value, nTG); + } + pUIMenu->m_pMiniDexed->SetTGParameter(CMiniDexed::TTGParameter::TGParameterMIDIChannel, CMIDIDevice::OmniMode, nTG); } +void CUIMenu::GenerateRandomFX(CUIMenu *pUIMenu, TMenuEvent Event) +{ + if (Event != TMenuEvent::MenuEventSelect) + { + return; + } + + for (int nParam = CMiniDexed::TParameter::ParameterCompressorEnable; nParam < CMiniDexed::TParameter::ParameterUnknown; ++nParam) + { + TParameter param = CUIMenu::s_GlobalParameter[nParam]; + uint8_t value = (uint8_t)CUIMenu::GetRandomValue(param.Minimum, param.Maximum); + pUIMenu->m_pMiniDexed->SetParameter(static_cast(nParam), value); + } +} + +void CUIMenu::GenerateRandomPerformance(CUIMenu *pUIMenu, TMenuEvent Event) +{ + if (Event != TMenuEvent::MenuEventSelect) + { + return; + } + for (size_t nTG = 0; nTG < CConfig::ToneGenerators; ++nTG) + { + CUIMenu::GenerateRandomPresetTG(pUIMenu, nTG); + } + + CUIMenu::GenerateRandomFX(pUIMenu, Event); +} diff --git a/src/uimenu.h b/src/uimenu.h index 78384be..de521e3 100644 --- a/src/uimenu.h +++ b/src/uimenu.h @@ -25,6 +25,9 @@ #include #include +#include +#include +#include class CMiniDexed; class CUserInterface; @@ -49,12 +52,12 @@ public: }; public: - CUIMenu (CUserInterface *pUI, CMiniDexed *pMiniDexed); + CUIMenu(CUserInterface *pUI, CMiniDexed *pMiniDexed); + + void EventHandler(TMenuEvent Event); - void EventHandler (TMenuEvent Event); - private: - typedef void TMenuHandler (CUIMenu *pUIMenu, TMenuEvent Event); + typedef void TMenuHandler(CUIMenu *pUIMenu, TMenuEvent Event); struct TMenuItem { @@ -64,7 +67,7 @@ private: unsigned Parameter; }; - typedef std::string TToString (int nValue); + typedef std::string TToString(int nValue); struct TParameter { @@ -75,48 +78,57 @@ private: }; private: - static void MenuHandler (CUIMenu *pUIMenu, TMenuEvent Event); - static void EditGlobalParameter (CUIMenu *pUIMenu, TMenuEvent Event); - static void EditVoiceBankNumber (CUIMenu *pUIMenu, TMenuEvent Event); - static void EditProgramNumber (CUIMenu *pUIMenu, TMenuEvent Event); - static void EditTGParameter (CUIMenu *pUIMenu, TMenuEvent Event); - static void EditVoiceParameter (CUIMenu *pUIMenu, TMenuEvent Event); - static void EditOPParameter (CUIMenu *pUIMenu, TMenuEvent Event); - static void SavePerformance (CUIMenu *pUIMenu, TMenuEvent Event); - static void EditTGParameter2 (CUIMenu *pUIMenu, TMenuEvent Event); - static void EditTGParameterModulation (CUIMenu *pUIMenu, TMenuEvent Event); - static void PerformanceMenu (CUIMenu *pUIMenu, TMenuEvent Event); - static void SavePerformanceNewFile (CUIMenu *pUIMenu, TMenuEvent Event); - - static std::string GetGlobalValueString (unsigned nParameter, int nValue); - static std::string GetTGValueString (unsigned nTGParameter, int nValue); - static std::string GetVoiceValueString (unsigned nVoiceParameter, int nValue); - static std::string GetOPValueString (unsigned nOPParameter, int nValue); - - static std::string ToVolume (int nValue); - static std::string ToPan (int nValue); - static std::string ToMIDIChannel (int nValue); - - static std::string ToAlgorithm (int nValue); - static std::string ToOnOff (int nValue); - static std::string ToLFOWaveform (int nValue); - static std::string ToTransposeNote (int nValue); - static std::string ToBreakpointNote (int nValue); - static std::string ToKeyboardCurve (int nValue); - static std::string ToOscillatorMode (int nValue); - static std::string ToOscillatorDetune (int nValue); - static std::string ToPortaMode (int nValue); - static std::string ToPortaGlissando (int nValue); - static std::string ToPolyMono (int nValue); - - void TGShortcutHandler (TMenuEvent Event); - void OPShortcutHandler (TMenuEvent Event); - - static void TimerHandler (TKernelTimerHandle hTimer, void *pParam, void *pContext); - - static void InputTxt (CUIMenu *pUIMenu, TMenuEvent Event); - static void TimerHandlerNoBack (TKernelTimerHandle hTimer, void *pParam, void *pContext); - + static void MenuHandler(CUIMenu *pUIMenu, TMenuEvent Event); + static void EditGlobalParameter(CUIMenu *pUIMenu, TMenuEvent Event); + static void EditVoiceBankNumber(CUIMenu *pUIMenu, TMenuEvent Event); + static void EditProgramNumber(CUIMenu *pUIMenu, TMenuEvent Event); + static void EditTGParameter(CUIMenu *pUIMenu, TMenuEvent Event); + static void EditVoiceParameter(CUIMenu *pUIMenu, TMenuEvent Event); + static void EditOPParameter(CUIMenu *pUIMenu, TMenuEvent Event); + static void SavePerformance(CUIMenu *pUIMenu, TMenuEvent Event); + static void EditTGParameter2(CUIMenu *pUIMenu, TMenuEvent Event); + static void EditTGParameterModulation(CUIMenu *pUIMenu, TMenuEvent Event); + static void PerformanceMenu(CUIMenu *pUIMenu, TMenuEvent Event); + static void SavePerformanceNewFile(CUIMenu *pUIMenu, TMenuEvent Event); + + static std::string GetGlobalValueString(unsigned nParameter, int nValue); + static std::string GetTGValueString(unsigned nTGParameter, int nValue); + static std::string GetVoiceValueString(unsigned nVoiceParameter, int nValue); + static std::string GetOPValueString(unsigned nOPParameter, int nValue); + + static std::string ToVolume(int nValue); + static std::string ToPan(int nValue); + static std::string ToMIDIChannel(int nValue); + + static std::string ToAlgorithm(int nValue); + static std::string ToOnOff(int nValue); + static std::string ToLFOWaveform(int nValue); + static std::string ToTransposeNote(int nValue); + static std::string ToBreakpointNote(int nValue); + static std::string ToKeyboardCurve(int nValue); + static std::string ToOscillatorMode(int nValue); + static std::string ToOscillatorDetune(int nValue); + static std::string ToPortaMode(int nValue); + static std::string ToPortaGlissando(int nValue); + static std::string ToPolyMono(int nValue); + + void TGShortcutHandler(TMenuEvent Event); + void OPShortcutHandler(TMenuEvent Event); + + static void TimerHandler(TKernelTimerHandle hTimer, void *pParam, void *pContext); + + static void InputTxt(CUIMenu *pUIMenu, TMenuEvent Event); + static void TimerHandlerNoBack(TKernelTimerHandle hTimer, void *pParam, void *pContext); + + static int GetRandomValue(int min, int max); + static void GenerateRandomOperator(CUIMenu *pUIMenu, TMenuEvent Event); + static void GenerateRandomOperatorTG(CUIMenu *pUIMenu, size_t nTG, size_t nOp); + static void GenerateRandomVoice(CUIMenu *pUIMenu, size_t nTG); + static void GenerateRandomPreset(CUIMenu *pUIMenu, TMenuEvent Event); + static void GenerateRandomPresetTG(CUIMenu *pUIMenu, size_t nTG); + static void GenerateRandomFX(CUIMenu *pUIMenu, TMenuEvent Event); + static void GenerateRandomPerformance(CUIMenu *pUIMenu, TMenuEvent Event); + private: CUserInterface *m_pUI; CMiniDexed *m_pMiniDexed; @@ -145,10 +157,10 @@ private: static const TMenuItem s_EditPitchBendMenu[]; static const TMenuItem s_EditPortamentoMenu[]; static const TMenuItem s_PerformanceMenu[]; - + static const TMenuItem s_ModulationMenu[]; static const TMenuItem s_ModulationMenuParameters[]; - + static const TParameter s_GlobalParameter[]; static const TParameter s_TGParameter[]; static const TParameter s_VoiceParameter[]; @@ -156,14 +168,13 @@ private: static const char s_NoteName[100][4]; - std::string m_InputText="1234567890ABCD"; - unsigned m_InputTextPosition=0; - unsigned m_InputTextChar=32; - bool m_bPerformanceDeleteMode=false; - bool m_bConfirmDeletePerformance=false; - unsigned m_nSelectedPerformanceID =0; - bool m_bSplashShow=false; - + std::string m_InputText = "1234567890ABCD"; + unsigned m_InputTextPosition = 0; + unsigned m_InputTextChar = 32; + bool m_bPerformanceDeleteMode = false; + bool m_bConfirmDeletePerformance = false; + unsigned m_nSelectedPerformanceID = 0; + bool m_bSplashShow = false; }; #endif