Initial implementation of system-level, i.e. all TG, MIDI control maps

pull/704/head
Kevin 10 months ago
parent e03122a3d2
commit 470306aa9b
  1. 23
      src/config.cpp
  2. 10
      src/config.h
  3. 51
      src/mididevice.cpp
  4. 4
      src/mididevice.h

@ -108,6 +108,10 @@ void CConfig::Load (void)
m_bMIDIAutoVoiceDumpOnPC = m_Properties.GetNumber ("MIDIAutoVoiceDumpOnPC", 0) != 0;
m_bHeaderlessSysExVoices = m_Properties.GetNumber ("HeaderlessSysExVoices", 0) != 0;
m_bExpandPCAcrossBanks = m_Properties.GetNumber ("ExpandPCAcrossBanks", 1) != 0;
m_nMIDISystemCCVol = m_Properties.GetNumber ("MIDISystemCCVol", 0);
m_nMIDISystemCCPan = m_Properties.GetNumber ("MIDISystemCCPan", 0);
m_nMIDISystemCCDetune = m_Properties.GetNumber ("MIDISystemCCDetune", 0);
m_bLCDEnabled = m_Properties.GetNumber ("LCDEnabled", 0) != 0;
m_nLCDPinEnable = m_Properties.GetNumber ("LCDPinEnable", 4);
@ -283,6 +287,11 @@ unsigned CConfig::GetEngineType (void) const
return m_EngineType;
}
bool CConfig::GetQuadDAC8Chan (void) const
{
return m_bQuadDAC8Chan;
}
unsigned CConfig::GetMIDIBaudRate (void) const
{
return m_nMIDIBaudRate;
@ -323,9 +332,19 @@ bool CConfig::GetExpandPCAcrossBanks (void) const
return m_bExpandPCAcrossBanks;
}
bool CConfig::GetQuadDAC8Chan (void) const
unsigned CConfig::GetMIDISystemCCVol (void) const
{
return m_bQuadDAC8Chan;
return m_nMIDISystemCCVol;
}
unsigned CConfig::GetMIDISystemCCPan (void) const
{
return m_nMIDISystemCCPan;
}
unsigned CConfig::GetMIDISystemCCDetune (void) const
{
return m_nMIDISystemCCDetune;
}
bool CConfig::GetLCDEnabled (void) const

@ -117,6 +117,7 @@ public:
unsigned GetDACI2CAddress (void) const; // 0 for auto probing
bool GetChannelsSwapped (void) const;
unsigned GetEngineType (void) const;
bool GetQuadDAC8Chan (void) const; // false if not specified
// MIDI
unsigned GetMIDIBaudRate (void) const;
@ -127,7 +128,9 @@ public:
bool GetMIDIAutoVoiceDumpOnPC (void) const; // false if not specified
bool GetHeaderlessSysExVoices (void) const; // false if not specified
bool GetExpandPCAcrossBanks (void) const; // true if not specified
bool GetQuadDAC8Chan (void) const; // false if not specified
unsigned GetMIDISystemCCVol (void) const;
unsigned GetMIDISystemCCPan (void) const;
unsigned GetMIDISystemCCDetune (void) const;
// HD44780 LCD
// GPIO pin numbers are chip numbers, not header positions
@ -245,6 +248,7 @@ private:
unsigned m_nDACI2CAddress;
bool m_bChannelsSwapped;
unsigned m_EngineType;
bool m_bQuadDAC8Chan;
unsigned m_nMIDIBaudRate;
std::string m_MIDIThruIn;
@ -254,7 +258,9 @@ private:
bool m_bMIDIAutoVoiceDumpOnPC;
bool m_bHeaderlessSysExVoices;
bool m_bExpandPCAcrossBanks;
bool m_bQuadDAC8Chan;
unsigned m_nMIDISystemCCVol;
unsigned m_nMIDISystemCCPan;
unsigned m_nMIDISystemCCDetune;
bool m_bLCDEnabled;
unsigned m_nLCDPinEnable;

@ -53,6 +53,21 @@ LOGMODULE ("mididevice");
#define MIDI_PROGRAM_CHANGE 0b1100
#define MIDI_PITCH_BEND 0b1110
// MIDI "System" level (i.e. all TG) custom CC maps
// Note: Even if number of TGs is not 8, there are only 8
// available to be used in the mappings here.
#define NUM_MIDI_CC_MAPS 8
const unsigned MIDISystemCCMap[NUM_MIDI_CC_MAPS][8] = {
{0,0,0,0,0,0,0,0}, // 0 = disabled
{16,17,18,19,80,81,82,83}, // 1 = General Purpose Controllers 1-8
{20,21,22,23,24,25,26,27},
{52,53,54,55,56,57,58,59},
{102,103,104,105,106,107,108,109},
{110,111,112,113,114,115,116,117},
{3,9,14,15,28,29,30,31},
{35,41,46,47,60,61,62,63}
};
#define MIDI_SYSTEM_EXCLUSIVE_BEGIN 0xF0
#define MIDI_SYSTEM_EXCLUSIVE_END 0xF7
#define MIDI_TIMING_CLOCK 0xF8
@ -69,6 +84,10 @@ CMIDIDevice::CMIDIDevice (CMiniDexed *pSynthesizer, CConfig *pConfig, CUserInter
{
m_ChannelMap[nTG] = Disabled;
}
m_nMIDISystemCCVol = m_pConfig->GetMIDISystemCCVol();
m_nMIDISystemCCPan = m_pConfig->GetMIDISystemCCPan();
m_nMIDISystemCCDetune = m_pConfig->GetMIDISystemCCDetune();
}
CMIDIDevice::~CMIDIDevice (void)
@ -373,6 +392,38 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
m_pSynthesizer->notesOff (pMessage[2], nTG);
}
break;
default:
// Check for "system" CC mappings if enabled that can control any TG
if (m_pConfig->GetToneGenerators() >= 8) {
// This only makes sense when there are at least 8 TGs.
// Note: If more than 8 TGs then only 8 TGs are controllable this way.
for (unsigned tg=0; tg<8; tg++) {
if (m_nMIDISystemCCVol != 0) {
if (pMessage[1] == MIDISystemCCMap[m_nMIDISystemCCVol][tg]) {
m_pSynthesizer->SetVolume (pMessage[2], tg);
}
}
if (m_nMIDISystemCCPan != 0) {
if (pMessage[1] == MIDISystemCCMap[m_nMIDISystemCCPan][tg]) {
m_pSynthesizer->SetPan (pMessage[2], tg);
}
}
if (m_nMIDISystemCCDetune != 0) {
if (pMessage[1] == MIDISystemCCMap[m_nMIDISystemCCDetune][tg]) {
if (pMessage[2] == 0)
{
m_pSynthesizer->SetMasterTune (0, tg);
}
else
{
m_pSynthesizer->SetMasterTune (maplong (pMessage[2], 1, 127, -99, 99), tg);
}
}
}
}
}
break;
}
break;

@ -66,6 +66,10 @@ private:
CUserInterface *m_pUI;
u8 m_ChannelMap[CConfig::AllToneGenerators];
unsigned m_nMIDISystemCCVol;
unsigned m_nMIDISystemCCPan;
unsigned m_nMIDISystemCCDetune;
std::string m_DeviceName;

Loading…
Cancel
Save