Maintain voice bank number per TG

pull/50/head
Rene Stange 3 years ago
parent 0045c6012e
commit 8789dca1ec
  1. 12
      src/minidexed.cpp
  2. 1
      src/minidexed.h
  3. 23
      src/sysexfileloader.cpp
  4. 7
      src/sysexfileloader.h

@ -49,6 +49,8 @@ CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt,
for (unsigned i = 0; i < CConfig::ToneGenerators; i++)
{
m_nVoiceBankID[i] = 0;
m_pTG[i] = new CDexedAdapter (CConfig::MaxNotes, pConfig->GetSampleRate ());
assert (m_pTG[i]);
@ -250,7 +252,10 @@ void CMiniDexed::BankSelectLSB (unsigned nBankLSB)
return;
}
m_SysExFileLoader.SelectVoiceBank (nBankLSB);
for (unsigned i = 0; i < CConfig::ToneGenerators; i++)
{
m_nVoiceBankID[i] = nBankLSB;
}
m_UI.BankSelected (nBankLSB);
}
@ -262,10 +267,11 @@ void CMiniDexed::ProgramChange (unsigned nProgram)
return;
}
uint8_t Buffer[156];
m_SysExFileLoader.GetVoice (nProgram, Buffer);
for (unsigned i = 0; i < CConfig::ToneGenerators; i++)
{
uint8_t Buffer[156];
m_SysExFileLoader.GetVoice (m_nVoiceBankID[i], nProgram, Buffer);
assert (m_pTG[i]);
m_pTG[i]->loadVoiceParameters (Buffer);
}

@ -88,6 +88,7 @@ private:
CConfig *m_pConfig;
CDexedAdapter *m_pTG[CConfig::ToneGenerators];
unsigned m_nVoiceBankID[CConfig::ToneGenerators];
CUserInterface m_UI;
CSysExFileLoader m_SysExFileLoader;

@ -45,8 +45,7 @@ uint8_t CSysExFileLoader::s_DefaultVoice[SizeSingleVoice] = // FM-Piano
};
CSysExFileLoader::CSysExFileLoader (const char *pDirName)
: m_DirName (pDirName),
m_nBankID (0)
: m_DirName (pDirName)
{
m_DirName += "/voice";
@ -168,22 +167,14 @@ std::string CSysExFileLoader::GetBankName (unsigned nBankID)
return "NO NAME";
}
void CSysExFileLoader::SelectVoiceBank (unsigned nBankID)
void CSysExFileLoader::GetVoice (unsigned nBankID, unsigned nVoiceID, uint8_t *pVoiceData)
{
if (nBankID <= MaxVoiceBankID)
{
m_nBankID = nBankID;
}
}
void CSysExFileLoader::GetVoice (unsigned nVoiceID, uint8_t *pVoiceData)
{
if (nVoiceID <= VoicesPerBank)
if ( nBankID <= MaxVoiceBankID
&& nVoiceID <= VoicesPerBank)
{
assert (m_nBankID <= MaxVoiceBankID);
if (m_pVoiceBank[m_nBankID])
if (m_pVoiceBank[nBankID])
{
DecodePackedVoice (m_pVoiceBank[m_nBankID]->Voice[nVoiceID], pVoiceData);
DecodePackedVoice (m_pVoiceBank[nBankID]->Voice[nVoiceID], pVoiceData);
return;
}
@ -191,7 +182,7 @@ void CSysExFileLoader::GetVoice (unsigned nVoiceID, uint8_t *pVoiceData)
{
// Use default voices_bank instead of s_DefaultVoice for bank 0,
// if the bank was not successfully loaded from disk.
if (m_nBankID == 0)
if (nBankID == 0)
{
memcpy (pVoiceData, voices_bank[0][nVoiceID], SizeSingleVoice);

@ -58,9 +58,8 @@ public:
std::string GetBankName (unsigned nBankID); // 0 .. 127
void SelectVoiceBank (unsigned nBankID); // 0 .. 127
void GetVoice (unsigned nVoiceID, // 0 .. 31
void GetVoice (unsigned nBankID, // 0 .. 127
unsigned nVoiceID, // 0 .. 31
uint8_t *pVoiceData); // returns unpacked format (156 bytes)
private:
@ -72,8 +71,6 @@ private:
TVoiceBank *m_pVoiceBank[MaxVoiceBankID+1];
std::string m_BankFileName[MaxVoiceBankID+1];
unsigned m_nBankID;
static uint8_t s_DefaultVoice[SizeSingleVoice];
};

Loading…
Cancel
Save