// // performanceconfig.cpp // // MiniDexed - Dexed FM synthesizer for bare metal Raspberry Pi // Copyright (C) 2022 The MiniDexed Team // // Original author of this class: // R. Stange // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // #include "performanceconfig.h" #include "mididevice.h" CPerformanceConfig::CPerformanceConfig (FATFS *pFileSystem) : m_Properties ("performance.ini", pFileSystem) { } CPerformanceConfig::~CPerformanceConfig (void) { } bool CPerformanceConfig::Load (void) { if (!m_Properties.Load ()) { return false; } bool bResult = false; for (unsigned nTG = 0; nTG < CConfig::ToneGenerators; nTG++) { CString PropertyName; PropertyName.Format ("BankNumber%u", nTG+1); m_nBankNumber[nTG] = m_Properties.GetNumber (PropertyName, 0); PropertyName.Format ("VoiceNumber%u", nTG+1); m_nVoiceNumber[nTG] = m_Properties.GetNumber (PropertyName, 1); if (m_nVoiceNumber[nTG] > 0) { m_nVoiceNumber[nTG]--; } PropertyName.Format ("MIDIChannel%u", nTG+1); unsigned nMIDIChannel = m_Properties.GetNumber (PropertyName, 255); if (nMIDIChannel == 0) { m_nMIDIChannel[nTG] = CMIDIDevice::Disabled; } else if (nMIDIChannel <= CMIDIDevice::Channels) { m_nMIDIChannel[nTG] = nMIDIChannel-1; bResult = true; } else { m_nMIDIChannel[nTG] = CMIDIDevice::OmniMode; bResult = true; } PropertyName.Format ("Volume%u", nTG+1); m_nVolume[nTG] = m_Properties.GetNumber (PropertyName, 100); PropertyName.Format ("Pan%u", nTG+1); m_nPan[nTG] = m_Properties.GetNumber (PropertyName, 64); PropertyName.Format ("Detune%u", nTG+1); m_nDetune[nTG] = m_Properties.GetSignedNumber (PropertyName, 0); PropertyName.Format ("NoteLimitLow%u", nTG+1); m_nNoteLimitLow[nTG] = m_Properties.GetNumber (PropertyName, 0); PropertyName.Format ("NoteLimitHigh%u", nTG+1); m_nNoteLimitHigh[nTG] = m_Properties.GetNumber (PropertyName, 127); PropertyName.Format ("NoteShift%u", nTG+1); m_nNoteShift[nTG] = m_Properties.GetSignedNumber (PropertyName, 0); } return bResult; } unsigned CPerformanceConfig::GetBankNumber (unsigned nTG) const { assert (nTG < CConfig::ToneGenerators); return m_nBankNumber[nTG]; } unsigned CPerformanceConfig::GetVoiceNumber (unsigned nTG) const { assert (nTG < CConfig::ToneGenerators); return m_nVoiceNumber[nTG]; } unsigned CPerformanceConfig::GetMIDIChannel (unsigned nTG) const { assert (nTG < CConfig::ToneGenerators); return m_nMIDIChannel[nTG]; } unsigned CPerformanceConfig::GetVolume (unsigned nTG) const { assert (nTG < CConfig::ToneGenerators); return m_nVolume[nTG]; } unsigned CPerformanceConfig::GetPan (unsigned nTG) const { assert (nTG < CConfig::ToneGenerators); return m_nPan[nTG]; } int CPerformanceConfig::GetDetune (unsigned nTG) const { assert (nTG < CConfig::ToneGenerators); return m_nDetune[nTG]; } unsigned CPerformanceConfig::GetNoteLimitLow (unsigned nTG) const { assert (nTG < CConfig::ToneGenerators); return m_nNoteLimitLow[nTG]; } unsigned CPerformanceConfig::GetNoteLimitHigh (unsigned nTG) const { assert (nTG < CConfig::ToneGenerators); return m_nNoteLimitHigh[nTG]; } int CPerformanceConfig::GetNoteShift (unsigned nTG) const { assert (nTG < CConfig::ToneGenerators); return m_nNoteShift[nTG]; }