From ded7db2d3589f4821e8238b455cb081e26db5662 Mon Sep 17 00:00:00 2001 From: probonopd Date: Wed, 20 Apr 2022 06:57:49 +0000 Subject: [PATCH 1/6] Allow enabling and disabling operators, closes #111 Thanks @rsta2 --- src/dexedadapter.h | 2 ++ src/minidexed.cpp | 20 ++++++++++++++++++-- src/minidexed.h | 3 ++- src/uimenu.cpp | 4 +++- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/dexedadapter.h b/src/dexedadapter.h index be04f42d..573e80ef 100644 --- a/src/dexedadapter.h +++ b/src/dexedadapter.h @@ -25,6 +25,8 @@ #include #include +#define DEXED_OP_ENABLE (DEXED_OP_OSC_DETUNE + 1) + // Some Dexed methods require to be guarded from being interrupted // by other Dexed calls. This is done herein. diff --git a/src/minidexed.cpp b/src/minidexed.cpp index 0858c540..dccc2f89 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -68,6 +68,7 @@ CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt, m_nNoteShift[i] = 0; m_nReverbSend[i] = 0; + m_uchOPMask[i] = 0b111111; // All operators on m_pTG[i] = new CDexedAdapter (CConfig::MaxNotes, pConfig->GetSampleRate ()); assert (m_pTG[i]); @@ -682,7 +683,14 @@ void CMiniDexed::SetVoiceParameter (uint8_t uchOffset, uint8_t uchValue, unsigne uchOffset += nOP * 21; assert (uchOffset < 156); - m_pTG[nTG]->setVoiceDataElement (uchOffset, uchValue); + if (nOP < 6 && uchOffset == DEXED_OP_ENABLE) + { + // https://github.com/probonopd/MiniDexed/issues/111#issuecomment-1103319499 + m_pTG[nTG]->setVoiceDataElement (uchOffset, uchValue); + m_pTG[nTG]->setOPAll(m_uchOPMask[nTG]); + } else { + m_pTG[nTG]->setVoiceDataElement (uchOffset, uchValue); + } } uint8_t CMiniDexed::GetVoiceParameter (uint8_t uchOffset, unsigned nOP, unsigned nTG) @@ -699,7 +707,15 @@ uint8_t CMiniDexed::GetVoiceParameter (uint8_t uchOffset, unsigned nOP, unsigned uchOffset += nOP * 21; assert (uchOffset < 156); - return m_pTG[nTG]->getVoiceDataElement (uchOffset); + if (nOP < 6 && uchOffset == DEXED_OP_ENABLE) + { + // https://github.com/probonopd/MiniDexed/issues/111#issuecomment-1103319499 + // In this case the bit for the respective operator + // in m_uchOPMask[] must be returned (0 or 1) + return 1 == ( (m_pTG[nTG]->getVoiceDataElement (uchOffset) >> nTG) & 1); + } else { + return m_pTG[nTG]->getVoiceDataElement (uchOffset); + } } std::string CMiniDexed::GetVoiceName (unsigned nTG) diff --git a/src/minidexed.h b/src/minidexed.h index ade7ddbd..c941ea9f 100644 --- a/src/minidexed.h +++ b/src/minidexed.h @@ -81,7 +81,8 @@ class CMiniDexed void ControllersRefresh (unsigned nTG); void SetReverbSend (unsigned nReverbSend, unsigned nTG); // 0 .. 127 - + uint8_t m_uchOPMask[CConfig::ToneGenerators]; + enum TParameter { ParameterCompressorEnable, diff --git a/src/uimenu.cpp b/src/uimenu.cpp index b03b6aa9..1dc3c58d 100644 --- a/src/uimenu.cpp +++ b/src/uimenu.cpp @@ -151,6 +151,7 @@ const CUIMenu::TMenuItem CUIMenu::s_OperatorMenu[] = {"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}, {0} }; @@ -234,7 +235,8 @@ const CUIMenu::TParameter CUIMenu::s_OPParameter[] = {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, 14, 1, ToOscillatorDetune}, // DEXED_OP_OSC_DETUNE + {0, 1, 1, ToOnOff} // DEXED_OP_ENABLE }; const char CUIMenu::s_NoteName[100][4] = From cbe6c2d7ca1972f7329e6e8cc5e03ad59427606e Mon Sep 17 00:00:00 2001 From: probonopd Date: Wed, 20 Apr 2022 19:51:52 +0200 Subject: [PATCH 2/6] Fix CMiniDexed::SetVoiceParameter() and CMiniDexed::GetVoiceParameter() https://github.com/probonopd/MiniDexed/issues/111#issuecomment-1104236141 Thanks @rsta2 [ci skip] --- src/minidexed.cpp | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/minidexed.cpp b/src/minidexed.cpp index dccc2f89..1361aa36 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -677,20 +677,29 @@ void CMiniDexed::SetVoiceParameter (uint8_t uchOffset, uint8_t uchValue, unsigne if (nOP < 6) { + if (uchOffset == DEXED_OP_ENABLE) + { + if (uchValue) + { + m_uchOPMask[nTG] |= 1 << nOP; + } + else + { + m_uchOPMask[nTG] &= ~(1 << nOP); + } + + m_pTG[nTG]->setOPAll (m_uchOPMask[nTG]); + + return; + } + nOP = 5 - nOP; // OPs are in reverse order } uchOffset += nOP * 21; assert (uchOffset < 156); - if (nOP < 6 && uchOffset == DEXED_OP_ENABLE) - { - // https://github.com/probonopd/MiniDexed/issues/111#issuecomment-1103319499 - m_pTG[nTG]->setVoiceDataElement (uchOffset, uchValue); - m_pTG[nTG]->setOPAll(m_uchOPMask[nTG]); - } else { - m_pTG[nTG]->setVoiceDataElement (uchOffset, uchValue); - } + m_pTG[nTG]->setVoiceDataElement (uchOffset, uchValue); } uint8_t CMiniDexed::GetVoiceParameter (uint8_t uchOffset, unsigned nOP, unsigned nTG) @@ -701,21 +710,18 @@ uint8_t CMiniDexed::GetVoiceParameter (uint8_t uchOffset, unsigned nOP, unsigned if (nOP < 6) { + if (uchOffset == DEXED_OP_ENABLE) + { + return !!(m_uchOPMask[nTG] & (1 << nOP)); + } + nOP = 5 - nOP; // OPs are in reverse order } uchOffset += nOP * 21; assert (uchOffset < 156); - if (nOP < 6 && uchOffset == DEXED_OP_ENABLE) - { - // https://github.com/probonopd/MiniDexed/issues/111#issuecomment-1103319499 - // In this case the bit for the respective operator - // in m_uchOPMask[] must be returned (0 or 1) - return 1 == ( (m_pTG[nTG]->getVoiceDataElement (uchOffset) >> nTG) & 1); - } else { - return m_pTG[nTG]->getVoiceDataElement (uchOffset); - } + return m_pTG[nTG]->getVoiceDataElement (uchOffset); } std::string CMiniDexed::GetVoiceName (unsigned nTG) From 37ec291a6de39f46fe2d195034d06d8969be7ad5 Mon Sep 17 00:00:00 2001 From: probonopd Date: Wed, 20 Apr 2022 19:53:21 +0200 Subject: [PATCH 3/6] Move m_uchOPMask[] to the private section of the class https://github.com/probonopd/MiniDexed/issues/111#issuecomment-1104236141 Thanks @rsta2 --- src/minidexed.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/minidexed.h b/src/minidexed.h index c941ea9f..d1f228ac 100644 --- a/src/minidexed.h +++ b/src/minidexed.h @@ -81,7 +81,6 @@ class CMiniDexed void ControllersRefresh (unsigned nTG); void SetReverbSend (unsigned nReverbSend, unsigned nTG); // 0 .. 127 - uint8_t m_uchOPMask[CConfig::ToneGenerators]; enum TParameter { @@ -127,7 +126,8 @@ class CMiniDexed private: int16_t ApplyNoteLimits (int16_t pitch, unsigned nTG); // returns < 0 to ignore note - + uint8_t m_uchOPMask[CConfig::ToneGenerators]; + void ProcessSound (void); #ifdef ARM_ALLOW_MULTI_CORE From ab75698508180ca698afe40a7fc9c609f402237f Mon Sep 17 00:00:00 2001 From: probonopd Date: Wed, 20 Apr 2022 20:08:12 +0200 Subject: [PATCH 4/6] Whitespace [ci skip] --- src/minidexed.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/minidexed.h b/src/minidexed.h index d1f228ac..9e54cf8c 100644 --- a/src/minidexed.h +++ b/src/minidexed.h @@ -81,7 +81,7 @@ class CMiniDexed void ControllersRefresh (unsigned nTG); void SetReverbSend (unsigned nReverbSend, unsigned nTG); // 0 .. 127 - + enum TParameter { ParameterCompressorEnable, From 214d9f0a511aed5a8544ac49e6d42464e1f8a44d Mon Sep 17 00:00:00 2001 From: probonopd Date: Wed, 20 Apr 2022 20:11:27 +0200 Subject: [PATCH 5/6] Reorder --- src/uimenu.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/uimenu.cpp b/src/uimenu.cpp index 1dc3c58d..eacca625 100644 --- a/src/uimenu.cpp +++ b/src/uimenu.cpp @@ -130,6 +130,7 @@ const CUIMenu::TMenuItem CUIMenu::s_EditVoiceMenu[] = const CUIMenu::TMenuItem CUIMenu::s_OperatorMenu[] = { + {"Enable", EditOPParameter, 0, DEXED_OP_ENABLE}, {"Output Level",EditOPParameter, 0, DEXED_OP_OUTPUT_LEV}, {"Freq Coarse", EditOPParameter, 0, DEXED_OP_FREQ_COARSE}, {"Freq Fine", EditOPParameter, 0, DEXED_OP_FREQ_FINE}, @@ -151,7 +152,6 @@ const CUIMenu::TMenuItem CUIMenu::s_OperatorMenu[] = {"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}, {0} }; @@ -215,6 +215,7 @@ const CUIMenu::TParameter CUIMenu::s_VoiceParameter[] = // must match DexedVoiceOPParameters in Synth_Dexed const CUIMenu::TParameter CUIMenu::s_OPParameter[] = { + {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 @@ -235,8 +236,7 @@ const CUIMenu::TParameter CUIMenu::s_OPParameter[] = {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, 14, 1, ToOscillatorDetune} // DEXED_OP_OSC_DETUNE }; const char CUIMenu::s_NoteName[100][4] = From f7fb986869a1fdabaeed3b10573f3f53ce9479fd Mon Sep 17 00:00:00 2001 From: probonopd Date: Wed, 20 Apr 2022 20:56:35 +0200 Subject: [PATCH 6/6] Revert reorder Would need a change in Synth_Dexed: CUIMenu::s_VoiceParameter[] "must match DexedVoiceOPParameters in Synth_Dexed" --- src/uimenu.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/uimenu.cpp b/src/uimenu.cpp index eacca625..1dc3c58d 100644 --- a/src/uimenu.cpp +++ b/src/uimenu.cpp @@ -130,7 +130,6 @@ const CUIMenu::TMenuItem CUIMenu::s_EditVoiceMenu[] = const CUIMenu::TMenuItem CUIMenu::s_OperatorMenu[] = { - {"Enable", EditOPParameter, 0, DEXED_OP_ENABLE}, {"Output Level",EditOPParameter, 0, DEXED_OP_OUTPUT_LEV}, {"Freq Coarse", EditOPParameter, 0, DEXED_OP_FREQ_COARSE}, {"Freq Fine", EditOPParameter, 0, DEXED_OP_FREQ_FINE}, @@ -152,6 +151,7 @@ const CUIMenu::TMenuItem CUIMenu::s_OperatorMenu[] = {"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}, {0} }; @@ -215,7 +215,6 @@ const CUIMenu::TParameter CUIMenu::s_VoiceParameter[] = // must match DexedVoiceOPParameters in Synth_Dexed const CUIMenu::TParameter CUIMenu::s_OPParameter[] = { - {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 @@ -236,7 +235,8 @@ const CUIMenu::TParameter CUIMenu::s_OPParameter[] = {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, 14, 1, ToOscillatorDetune}, // DEXED_OP_OSC_DETUNE + {0, 1, 1, ToOnOff} // DEXED_OP_ENABLE }; const char CUIMenu::s_NoteName[100][4] =