From bebf9cec95c6cd6b3271b24390c0197d6c042c2a Mon Sep 17 00:00:00 2001 From: soyer Date: Tue, 22 Apr 2025 20:15:51 +0200 Subject: [PATCH] Fix op ordering and reenabling (#870) * fix op ordering The ops are in reverse order in the OPMask as well * reset OPMask after voice load If you change a voice, Dexed enables all operator. Do the same in MiniDexed. --- src/minidexed.cpp | 25 +++++++++++++++++-------- src/minidexed.h | 1 + 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/minidexed.cpp b/src/minidexed.cpp index de48840..ebe9e1b 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -658,6 +658,7 @@ void CMiniDexed::ProgramChange (unsigned nProgram, unsigned nTG) assert (m_pTG[nTG]); m_pTG[nTG]->loadVoiceParameters (Buffer); + setOPMask(0b111111, nTG); if (m_pConfig->GetMIDIAutoVoiceDumpOnPC()) { @@ -1178,23 +1179,22 @@ void CMiniDexed::SetVoiceParameter (uint8_t uchOffset, uint8_t uchValue, unsigne if (nOP < 6) { + nOP = 5 - nOP; // OPs are in reverse order + if (uchOffset == DEXED_OP_ENABLE) { if (uchValue) { - m_uchOPMask[nTG] |= 1 << nOP; + setOPMask(m_uchOPMask[nTG] | 1 << nOP, nTG); } else { - m_uchOPMask[nTG] &= ~(1 << nOP); + setOPMask(m_uchOPMask[nTG] & ~(1 << nOP), nTG); } - m_pTG[nTG]->setOPAll (m_uchOPMask[nTG]); return; - } - - nOP = 5 - nOP; // OPs are in reverse order + } } uchOffset += nOP * 21; @@ -1213,12 +1213,12 @@ uint8_t CMiniDexed::GetVoiceParameter (uint8_t uchOffset, unsigned nOP, unsigned if (nOP < 6) { + nOP = 5 - nOP; // OPs are in reverse order + if (uchOffset == DEXED_OP_ENABLE) { return !!(m_uchOPMask[nTG] & (1 << nOP)); } - - nOP = 5 - nOP; // OPs are in reverse order } uchOffset += nOP * 21; @@ -1792,6 +1792,8 @@ void CMiniDexed::loadVoiceParameters(const uint8_t* data, uint8_t nTG) m_pTG[nTG]->loadVoiceParameters(&voice[6]); m_pTG[nTG]->doRefreshVoice(); + setOPMask(0b111111, nTG); + m_UI.ParameterChanged (); } @@ -1848,6 +1850,12 @@ void CMiniDexed::getSysExVoiceDump(uint8_t* dest, uint8_t nTG) dest[162] = 0xF7; // SysEx end } +void CMiniDexed::setOPMask(uint8_t uchOPMask, uint8_t nTG) +{ + m_uchOPMask[nTG] = uchOPMask; + m_pTG[nTG]->setOPAll (m_uchOPMask[nTG]); +} + void CMiniDexed::setMasterVolume(float32_t vol) { if (vol < 0.0) @@ -2022,6 +2030,7 @@ void CMiniDexed::LoadPerformanceParameters(void) { uint8_t* tVoiceData = m_PerformanceConfig.GetVoiceDataFromTxt(nTG); m_pTG[nTG]->loadVoiceParameters(tVoiceData); + setOPMask(0b111111, nTG); } setMonoMode(m_PerformanceConfig.GetMonoMode(nTG) ? 1 : 0, nTG); SetReverbSend (m_PerformanceConfig.GetReverbSend (nTG), nTG); diff --git a/src/minidexed.h b/src/minidexed.h index b382f7e..4193ad8 100644 --- a/src/minidexed.h +++ b/src/minidexed.h @@ -122,6 +122,7 @@ public: void loadVoiceParameters(const uint8_t* data, uint8_t nTG); void setVoiceDataElement(uint8_t data, uint8_t number, uint8_t nTG); void getSysExVoiceDump(uint8_t* dest, uint8_t nTG); + void setOPMask(uint8_t uchOPMask, uint8_t nTG); void setModController (unsigned controller, unsigned parameter, uint8_t value, uint8_t nTG); unsigned getModController (unsigned controller, unsigned parameter, uint8_t nTG);