Implement Poly Mode (CC 127) support and fix OMNI mode channel memory

more-midi-functions
probonopd 4 days ago
parent 9987e03b71
commit 7510e8e613
  1. 14
      src/mididevice.cpp
  2. 1
      src/mididevice.h

@ -88,6 +88,7 @@ CMIDIDevice::CMIDIDevice (CMiniDexed *pSynthesizer, CConfig *pConfig, CUserInter
for (unsigned nTG = 0; nTG < CConfig::AllToneGenerators; nTG++) for (unsigned nTG = 0; nTG < CConfig::AllToneGenerators; nTG++)
{ {
m_ChannelMap[nTG] = Disabled; m_ChannelMap[nTG] = Disabled;
m_PreviousChannelMap[nTG] = Disabled; // Initialize previous channel map
} }
m_nMIDISystemCCVol = m_pConfig->GetMIDISystemCCVol(); m_nMIDISystemCCVol = m_pConfig->GetMIDISystemCCVol();
@ -136,6 +137,12 @@ CMIDIDevice::~CMIDIDevice (void)
void CMIDIDevice::SetChannel (u8 ucChannel, unsigned nTG) void CMIDIDevice::SetChannel (u8 ucChannel, unsigned nTG)
{ {
assert (nTG < CConfig::AllToneGenerators); assert (nTG < CConfig::AllToneGenerators);
// When changing to OMNI mode, store the previous channel
if (ucChannel == OmniMode && m_ChannelMap[nTG] != OmniMode) {
m_PreviousChannelMap[nTG] = m_ChannelMap[nTG];
}
m_ChannelMap[nTG] = ucChannel; m_ChannelMap[nTG] = ucChannel;
} }
@ -536,8 +543,11 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
case MIDI_CC_OMNI_MODE_OFF: case MIDI_CC_OMNI_MODE_OFF:
// Sets to "Omni Off" mode // Sets to "Omni Off" mode
if (m_ChannelMap[nTG] == OmniMode) { if (m_ChannelMap[nTG] == OmniMode) {
m_pSynthesizer->SetMIDIChannel(ucChannel, nTG); // Restore the previous channel if available, otherwise use current channel
LOGDBG("Omni Mode Off: TG %d set to MIDI channel %d", nTG, ucChannel+1); u8 channelToRestore = (m_PreviousChannelMap[nTG] != Disabled) ?
m_PreviousChannelMap[nTG] : ucChannel;
m_pSynthesizer->SetMIDIChannel(channelToRestore, nTG);
LOGDBG("Omni Mode Off: TG %d restored to MIDI channel %d", nTG, channelToRestore+1);
} }
break; break;

@ -70,6 +70,7 @@ private:
CUserInterface *m_pUI; CUserInterface *m_pUI;
u8 m_ChannelMap[CConfig::AllToneGenerators]; u8 m_ChannelMap[CConfig::AllToneGenerators];
u8 m_PreviousChannelMap[CConfig::AllToneGenerators]; // Store previous channels for OMNI OFF restore
unsigned m_nMIDISystemCCVol; unsigned m_nMIDISystemCCVol;
unsigned m_nMIDISystemCCPan; unsigned m_nMIDISystemCCPan;

Loading…
Cancel
Save