Update to fix bank numbers. Bank file numbers now start from 00001 and show as 1-indexed in the UI. But internally and via MIDI are still 0-indexed as per MIDI spec.

pull/473/head
diyelectromusic 2 years ago
parent 7d2b2e035d
commit 6c77b369f7
  1. 54
      src/sysexfileloader.cpp
  2. 2
      src/uimenu.cpp

@ -144,22 +144,28 @@ void CSysExFileLoader::LoadBank (const char * sDirName, const char * sBankName,
return;
}
if (nBank > MaxVoiceBankID)
// File and UI handling requires banks to be 1..indexed.
// Internally (and via MIDI) we need 0..indexed.
// Any mention of a BankID internally is assumed to be 0..indexed.
unsigned nBankIdx = nBank - 1;
// BankIdx goes from 0 to MaxVoiceBankID inclusive
if (nBankIdx > MaxVoiceBankID)
{
LOGWARN ("Bank #%u is not supported", nBank);
return;
}
if (m_pVoiceBank[nBank])
if (m_pVoiceBank[nBankIdx])
{
LOGWARN ("Bank #%u already loaded", nBank);
return;
}
m_pVoiceBank[nBank] = new TVoiceBank;
assert (m_pVoiceBank[nBank]);
m_pVoiceBank[nBankIdx] = new TVoiceBank;
assert (m_pVoiceBank[nBankIdx]);
assert (sizeof(TVoiceBank) == VoiceSysExHdrSize + VoiceSysExSize);
std::string Filename (sDirName);
@ -170,11 +176,11 @@ void CSysExFileLoader::LoadBank (const char * sDirName, const char * sBankName,
if (pFile)
{
bool bBankLoaded = false;
if ( fread (m_pVoiceBank[nBank], VoiceSysExHdrSize+VoiceSysExSize, 1, pFile) == 1
&& m_pVoiceBank[nBank]->StatusStart == 0xF0
&& m_pVoiceBank[nBank]->CompanyID == 0x43
&& m_pVoiceBank[nBank]->Format == 0x09
&& m_pVoiceBank[nBank]->StatusEnd == 0xF7)
if ( fread (m_pVoiceBank[nBankIdx], VoiceSysExHdrSize+VoiceSysExSize, 1, pFile) == 1
&& m_pVoiceBank[nBankIdx]->StatusStart == 0xF0
&& m_pVoiceBank[nBankIdx]->CompanyID == 0x43
&& m_pVoiceBank[nBankIdx]->Format == 0x09
&& m_pVoiceBank[nBankIdx]->StatusEnd == 0xF7)
{
if (m_nBanksLoaded % 100 == 0)
{
@ -182,7 +188,7 @@ void CSysExFileLoader::LoadBank (const char * sDirName, const char * sBankName,
}
//LOGDBG ("Bank #%u successfully loaded", nBank);
m_BankFileName[nBank] = sBankName;
m_BankFileName[nBankIdx] = sBankName;
if (nBank > m_nNumHighestBank)
{
// This is the bank ID of the highest loaded bank
@ -196,7 +202,7 @@ void CSysExFileLoader::LoadBank (const char * sDirName, const char * sBankName,
// Config says to accept headerless SysEx Voice Banks
// so reset file pointer and try again.
fseek (pFile, 0, SEEK_SET);
if (fread (m_pVoiceBank[nBank]->Voice, VoiceSysExSize, 1, pFile) == 1)
if (fread (m_pVoiceBank[nBankIdx]->Voice, VoiceSysExSize, 1, pFile) == 1)
{
if (m_nBanksLoaded % 100 == 0)
{
@ -206,15 +212,15 @@ void CSysExFileLoader::LoadBank (const char * sDirName, const char * sBankName,
// Add in the missing header items.
// Naturally it isn't possible to validate these!
m_pVoiceBank[nBank]->StatusStart = 0xF0;
m_pVoiceBank[nBank]->CompanyID = 0x43;
m_pVoiceBank[nBank]->Format = 0x09;
m_pVoiceBank[nBank]->ByteCountMS = 0x20;
m_pVoiceBank[nBank]->ByteCountLS = 0x00;
m_pVoiceBank[nBank]->Checksum = 0x00;
m_pVoiceBank[nBank]->StatusEnd = 0xF7;
m_BankFileName[nBank] = sBankName;
m_pVoiceBank[nBankIdx]->StatusStart = 0xF0;
m_pVoiceBank[nBankIdx]->CompanyID = 0x43;
m_pVoiceBank[nBankIdx]->Format = 0x09;
m_pVoiceBank[nBankIdx]->ByteCountMS = 0x20;
m_pVoiceBank[nBankIdx]->ByteCountLS = 0x00;
m_pVoiceBank[nBankIdx]->Checksum = 0x00;
m_pVoiceBank[nBankIdx]->StatusEnd = 0xF7;
m_BankFileName[nBankIdx] = sBankName;
if (nBank > m_nNumHighestBank)
{
// This is the bank ID of the highest loaded bank
@ -229,16 +235,16 @@ void CSysExFileLoader::LoadBank (const char * sDirName, const char * sBankName,
{
LOGWARN ("%s: Invalid size or format", Filename.c_str ());
delete m_pVoiceBank[nBank];
m_pVoiceBank[nBank] = nullptr;
delete m_pVoiceBank[nBankIdx];
m_pVoiceBank[nBankIdx] = nullptr;
}
fclose (pFile);
}
else
{
delete m_pVoiceBank[nBank];
m_pVoiceBank[nBank] = nullptr;
delete m_pVoiceBank[nBankIdx];
m_pVoiceBank[nBankIdx] = nullptr;
}
}

@ -519,7 +519,7 @@ void CUIMenu::EditVoiceBankNumber (CUIMenu *pUIMenu, TMenuEvent Event)
string TG ("TG");
TG += to_string (nTG+1);
string Value = to_string (nValue) + "="
string Value = to_string (nValue+1) + "="
+ pUIMenu->m_pMiniDexed->GetSysExFileLoader ()->GetBankName (nValue);
pUIMenu->m_pUI->DisplayWrite (TG.c_str (),

Loading…
Cancel
Save