Skip to content

Commit

Permalink
Merge branch 'main' into setVelocityScale
Browse files Browse the repository at this point in the history
  • Loading branch information
probonopd authored May 29, 2023
2 parents e0ec1dd + 87dc5ce commit b22b9ae
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 33 deletions.
5 changes: 4 additions & 1 deletion src/mididevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,10 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
break;

case MIDI_CC_ALL_NOTES_OFF:
if (!m_pConfig->GetIgnoreAllNotesOff ())
// As per "MIDI 1.0 Detailed Specification" v4.2
// From "ALL NOTES OFF" states:
// "Receivers should ignore an All Notes Off message while Omni is on (Modes 1 & 2)"
if (!m_pConfig->GetIgnoreAllNotesOff () && m_ChannelMap[nTG] != OmniMode)
{
m_pSynthesizer->notesOff (pMessage[2], nTG);
}
Expand Down
2 changes: 1 addition & 1 deletion src/minidexed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,7 @@ bool CMiniDexed::DoSetNewPerformance (void)

bool CMiniDexed::SavePerformanceNewFile ()
{
m_bSavePerformanceNewFile = m_PerformanceConfig.GetInternalFolderOk();
m_bSavePerformanceNewFile = m_PerformanceConfig.GetInternalFolderOk() && m_PerformanceConfig.CheckFreePerformanceSlot();
return m_bSavePerformanceNewFile;
}

Expand Down
56 changes: 42 additions & 14 deletions src/performanceconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#include <circle/logger.h>
#include "performanceconfig.h"
#include "mididevice.h"
#include <cstring>
#include <algorithm>
#include <algorithm>

LOGMODULE ("Performance");

CPerformanceConfig::CPerformanceConfig (FATFS *pFileSystem)
: m_Properties ("performance.ini", pFileSystem)
Expand Down Expand Up @@ -747,8 +750,27 @@ bool CPerformanceConfig::GetInternalFolderOk()
return nInternalFolderOk;
}

bool CPerformanceConfig::CheckFreePerformanceSlot(void)
{
if (nLastPerformance < NUM_PERFORMANCES)
{
// There is a free slot...
return true;
}
else
{
return false;
}
}

bool CPerformanceConfig::CreateNewPerformanceFile(void)
{
if (nLastPerformance >= NUM_PERFORMANCES) {
// No space left for new performances
LOGWARN ("No space left for new performance");
return false;
}

std::string sPerformanceName = NewPerformanceName;
NewPerformanceName="";
nActualPerformance=nLastPerformance;
Expand Down Expand Up @@ -829,19 +851,23 @@ bool CPerformanceConfig::ListPerformances()
Result = f_findfirst (&Directory, &FileInfo, "SD:/" PERFORMANCE_DIR, "*.ini");
for (unsigned i = 0; Result == FR_OK && FileInfo.fname[0]; i++)
{
if (!(FileInfo.fattrib & (AM_HID | AM_SYS)))
{
std::string FileName = FileInfo.fname;
size_t nLen = FileName.length();
if ( nLen > 8 && nLen <26 && strcmp(FileName.substr(6,1).c_str(), "_")==0)
{
nPIndex=stoi(FileName.substr(0,6));
if(nPIndex > nLastFileIndex)
{
nLastFileIndex=nPIndex;
}

m_nPerformanceFileName[nLastPerformance++]= FileName;
if (nLastPerformance >= NUM_PERFORMANCES) {
LOGNOTE ("Skipping performance %s", FileInfo.fname);
} else {
if (!(FileInfo.fattrib & (AM_HID | AM_SYS)))
{
std::string FileName = FileInfo.fname;
size_t nLen = FileName.length();
if ( nLen > 8 && nLen <26 && strcmp(FileName.substr(6,1).c_str(), "_")==0)
{
nPIndex=stoi(FileName.substr(0,6));
if(nPIndex > nLastFileIndex)
{
nLastFileIndex=nPIndex;
}

m_nPerformanceFileName[nLastPerformance++]= FileName;
}
}
}

Expand All @@ -854,6 +880,8 @@ bool CPerformanceConfig::ListPerformances()
}
}

LOGNOTE ("Number of Performances: %d", nLastPerformance);

return nInternalFolderOk;
}

Expand Down
4 changes: 3 additions & 1 deletion src/performanceconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <Properties/propertiesfatfsfile.h>
#define NUM_VOICE_PARAM 156
#define PERFORMANCE_DIR "performance"
#define NUM_PERFORMANCES 256

class CPerformanceConfig // Performance configuration
{
Expand Down Expand Up @@ -131,6 +132,7 @@ class CPerformanceConfig // Performance configuration
std::string GetNewPerformanceDefaultName(void);
void SetNewPerformanceName(std::string nName);
bool DeletePerformance(unsigned nID);
bool CheckFreePerformanceSlot(void);

private:
CPropertiesFatFsFile m_Properties;
Expand Down Expand Up @@ -168,7 +170,7 @@ class CPerformanceConfig // Performance configuration
unsigned nLastFileIndex;
unsigned nActualPerformance = 0;
//unsigned nMenuSelectedPerformance = 0;
std::string m_nPerformanceFileName[1024];
std::string m_nPerformanceFileName[NUM_PERFORMANCES];
FATFS *m_pFileSystem;

bool nInternalFolderOk=false;
Expand Down
10 changes: 5 additions & 5 deletions src/sysexfileloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void CSysExFileLoader::Load (bool bHeaderlessSysExVoices)
{
LoadBank(m_DirName.c_str (), pEntry->d_name, bHeaderlessSysExVoices, 0);
}
LOGDBG ("%u Banks loaded. Highest Bank loaded: #%u", m_nBanksLoaded, m_nNumHighestBank);
LOGDBG ("%u Banks loaded. Highest Bank loaded: #%u", m_nBanksLoaded, m_nNumHighestBank+1);

closedir (pDirectory);
}
Expand Down Expand Up @@ -189,10 +189,10 @@ void CSysExFileLoader::LoadBank (const char * sDirName, const char * sBankName,
//LOGDBG ("Bank #%u successfully loaded", nBank);

m_BankFileName[nBankIdx] = sBankName;
if (nBank > m_nNumHighestBank)
if (nBankIdx > m_nNumHighestBank)
{
// This is the bank ID of the highest loaded bank
m_nNumHighestBank = nBank;
m_nNumHighestBank = nBankIdx;
}
m_nBanksLoaded++;
bBankLoaded = true;
Expand Down Expand Up @@ -221,10 +221,10 @@ void CSysExFileLoader::LoadBank (const char * sDirName, const char * sBankName,
m_pVoiceBank[nBankIdx]->StatusEnd = 0xF7;

m_BankFileName[nBankIdx] = sBankName;
if (nBank > m_nNumHighestBank)
if (nBankIdx > m_nNumHighestBank)
{
// This is the bank ID of the highest loaded bank
m_nNumHighestBank = nBank;
m_nNumHighestBank = nBankIdx;
}
bBankLoaded = true;
m_nBanksLoaded++;
Expand Down
13 changes: 2 additions & 11 deletions src/uimenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,6 @@ void CUIMenu::EditVoiceBankNumber (CUIMenu *pUIMenu, TMenuEvent Event)
void CUIMenu::EditProgramNumber (CUIMenu *pUIMenu, TMenuEvent Event)
{
unsigned nTG = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth-1];
int nHighestBank = pUIMenu->m_pMiniDexed->GetSysExFileLoader ()->GetNumHighestBank();

int nValue = pUIMenu->m_pMiniDexed->GetTGParameter (CMiniDexed::TGParameterProgram, nTG);

Expand All @@ -578,11 +577,7 @@ void CUIMenu::EditProgramNumber (CUIMenu *pUIMenu, TMenuEvent Event)
// Switch down a voice bank and set to the last voice
nValue = CSysExFileLoader::VoicesPerBank-1;
int nVB = pUIMenu->m_pMiniDexed->GetTGParameter(CMiniDexed::TGParameterVoiceBank, nTG);
if (--nVB < 0)
{
// Wrap around to last loaded bank
nVB = nHighestBank;
}
nVB = pUIMenu->m_pMiniDexed->GetSysExFileLoader ()->GetNextBankDown(nVB);
pUIMenu->m_pMiniDexed->SetTGParameter (CMiniDexed::TGParameterVoiceBank, nVB, nTG);
}
pUIMenu->m_pMiniDexed->SetTGParameter (CMiniDexed::TGParameterProgram, nValue, nTG);
Expand All @@ -594,11 +589,7 @@ void CUIMenu::EditProgramNumber (CUIMenu *pUIMenu, TMenuEvent Event)
// Switch up a voice bank and reset to voice 0
nValue = 0;
int nVB = pUIMenu->m_pMiniDexed->GetTGParameter(CMiniDexed::TGParameterVoiceBank, nTG);
if (++nVB > (int) nHighestBank)
{
// Wrap around to first bank
nVB = 0;
}
nVB = pUIMenu->m_pMiniDexed->GetSysExFileLoader ()->GetNextBankUp(nVB);
pUIMenu->m_pMiniDexed->SetTGParameter (CMiniDexed::TGParameterVoiceBank, nVB, nTG);
}
pUIMenu->m_pMiniDexed->SetTGParameter (CMiniDexed::TGParameterProgram, nValue, nTG);
Expand Down

0 comments on commit b22b9ae

Please sign in to comment.