You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
MiniDexed/src/uimenu.h

183 lines
5.6 KiB

//
// uimenu.h
//
// MiniDexed - Dexed FM synthesizer for bare metal Raspberry Pi
// Copyright (C) 2022 The MiniDexed Team
//
// Original author of this class:
// R. Stange <rsta2@o2online.de>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#ifndef _uimenu_h
#define _uimenu_h
#include <string>
#include <circle/timer.h>
#include "config.h"
class CMiniDexed;
class CUserInterface;
class CUIMenu
{
private:
static const unsigned MaxMenuDepth = 5;
public:
enum TMenuEvent
{
MenuEventUpdate,
MenuEventSelect,
MenuEventBack,
MenuEventHome,
MenuEventStepDown,
MenuEventStepUp,
MenuEventPressAndStepDown,
MenuEventPressAndStepUp,
MenuEventPgmUp,
MenuEventPgmDown,
MenuEventTGUp,
MenuEventTGDown,
MenuEventUnknown
};
public:
CUIMenu (CUserInterface *pUI, CMiniDexed *pMiniDexed, CConfig *pConfig);
void EventHandler (TMenuEvent Event);
private:
typedef void TMenuHandler (CUIMenu *pUIMenu, TMenuEvent Event);
struct TMenuItem
{
const char *Name;
TMenuHandler *Handler;
const TMenuItem *MenuItem;
unsigned Parameter;
};
typedef std::string TToString (int nValue);
struct TParameter
{
int Minimum;
int Maximum;
int Increment;
TToString *ToString;
};
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);
Performance file handling (#581) Implements #580 * Initial update in performance file handling. This change makes the 6-digit number in the filename indicate a performance "voice number" in MiniDexed. The external filename numbers will now match any Program Change messages using the common MIDI concept of user selecting 1..128 whilst internally they are treated as 0..127. Note: in the case of performances, performance 1 (index 0) is the Default "performance.ini" file for backwards compatibility. Also note that in this version, new performances, when saved, cannot occupy free slots between other performances - they are added to the end. Even though the filename standard gives 6 digit numbers, the actual number of performances is still limited to 256. * Start of subdirectory implementation for performance banks. * Initial version with performance banks, selectable over MIDI only. * Initial implementation of performance bank switching in the UI menu. * Remove debug information, fix few bugs, including PgmUpDown handling and performance numbers out of range. * Bugfixes for legacy cases when no performance directory exists plus some extra checks for saving and deleting performances. * Remove verbose debug options (doh!) * Fix a minor off-by-one error found in review. * Bugfix - removed redundant legacy check that results in out of order performance files being skipped on load. * Fix bug in MIDI button handling commands. * Fix for issue where wrong performance is selected [L] on new save. * Suggested update to UI to show bank/performance numbers. * Make performance bank select asynchronous to MIDI and UI to stop corruptions on loading performances. * Fix an assert that should be a run-time test. * Ensure bank selection works when PCCH is not enabled, and that UI remains consistent when changing banks. --------- Co-authored-by: Kevin <68612569+diyelectromusic@users.noreply.github.com>
10 months ago
static void EditPerformanceBankNumber (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);
void PgmUpDownHandler (TMenuEvent Event);
void TGUpDownHandler (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);
private:
CUserInterface *m_pUI;
CMiniDexed *m_pMiniDexed;
CConfig *m_pConfig;
unsigned m_nToneGenerators;
const TMenuItem *m_pParentMenu;
const TMenuItem *m_pCurrentMenu;
unsigned m_nCurrentMenuItem;
unsigned m_nCurrentSelection;
unsigned m_nCurrentParameter;
const TMenuItem *m_MenuStackParent[MaxMenuDepth];
const TMenuItem *m_MenuStackMenu[MaxMenuDepth];
unsigned m_nMenuStackItem[MaxMenuDepth];
unsigned m_nMenuStackSelection[MaxMenuDepth];
unsigned m_nMenuStackParameter[MaxMenuDepth];
unsigned m_nCurrentMenuDepth;
static const TMenuItem s_MenuRoot[];
static const TMenuItem s_MainMenu[];
static const TMenuItem s_TGMenu[];
static const TMenuItem s_EffectsMenu[];
static const TMenuItem s_ReverbMenu[];
static const TMenuItem s_EditVoiceMenu[];
static const TMenuItem s_OperatorMenu[];
static const TMenuItem s_SaveMenu[];
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[];
static const TParameter s_OPParameter[];
static const char s_NoteName[100][5];
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;
Performance file handling (#581) Implements #580 * Initial update in performance file handling. This change makes the 6-digit number in the filename indicate a performance "voice number" in MiniDexed. The external filename numbers will now match any Program Change messages using the common MIDI concept of user selecting 1..128 whilst internally they are treated as 0..127. Note: in the case of performances, performance 1 (index 0) is the Default "performance.ini" file for backwards compatibility. Also note that in this version, new performances, when saved, cannot occupy free slots between other performances - they are added to the end. Even though the filename standard gives 6 digit numbers, the actual number of performances is still limited to 256. * Start of subdirectory implementation for performance banks. * Initial version with performance banks, selectable over MIDI only. * Initial implementation of performance bank switching in the UI menu. * Remove debug information, fix few bugs, including PgmUpDown handling and performance numbers out of range. * Bugfixes for legacy cases when no performance directory exists plus some extra checks for saving and deleting performances. * Remove verbose debug options (doh!) * Fix a minor off-by-one error found in review. * Bugfix - removed redundant legacy check that results in out of order performance files being skipped on load. * Fix bug in MIDI button handling commands. * Fix for issue where wrong performance is selected [L] on new save. * Suggested update to UI to show bank/performance numbers. * Make performance bank select asynchronous to MIDI and UI to stop corruptions on loading performances. * Fix an assert that should be a run-time test. * Ensure bank selection works when PCCH is not enabled, and that UI remains consistent when changing banks. --------- Co-authored-by: Kevin <68612569+diyelectromusic@users.noreply.github.com>
10 months ago
unsigned m_nSelectedPerformanceBankID =0;
bool m_bSplashShow=false;
};
#endif