mirror of https://github.com/probonopd/MiniDexed
Load performance config from performance.ini (#54)
parent
7519da5e13
commit
2199208d34
@ -0,0 +1,75 @@ |
|||||||
|
# |
||||||
|
# performance.ini |
||||||
|
# |
||||||
|
|
||||||
|
# TG# |
||||||
|
#BankNumber#=0 # 0 .. 127 |
||||||
|
#VoiceNumber#=1 # 1 .. 32 |
||||||
|
#MIDIChannel#=1 # 1 .. 16, 0: off, >16: omni mode |
||||||
|
#Volume#=100 # 0 .. 127 |
||||||
|
#Pan#=64 # 0 .. 127 |
||||||
|
#Detune#=0 # -99 .. 99 |
||||||
|
|
||||||
|
# TG1 |
||||||
|
BankNumber1=0 |
||||||
|
VoiceNumber1=1 |
||||||
|
MIDIChannel1=255 |
||||||
|
Volume1=100 |
||||||
|
Pan1=64 |
||||||
|
Detune1=0 |
||||||
|
|
||||||
|
# TG2 |
||||||
|
BankNumber2=0 |
||||||
|
VoiceNumber2=1 |
||||||
|
MIDIChannel2=0 |
||||||
|
Volume2=100 |
||||||
|
Pan2=64 |
||||||
|
Detune2=0 |
||||||
|
|
||||||
|
# TG3 |
||||||
|
BankNumber3=0 |
||||||
|
VoiceNumber3=1 |
||||||
|
MIDIChannel3=0 |
||||||
|
Volume3=100 |
||||||
|
Pan3=64 |
||||||
|
Detune3=0 |
||||||
|
|
||||||
|
# TG4 |
||||||
|
BankNumber4=0 |
||||||
|
VoiceNumber4=1 |
||||||
|
MIDIChannel4=0 |
||||||
|
Volume4=100 |
||||||
|
Pan4=64 |
||||||
|
Detune4=0 |
||||||
|
|
||||||
|
# TG5 |
||||||
|
BankNumber5=0 |
||||||
|
VoiceNumber5=1 |
||||||
|
MIDIChannel5=0 |
||||||
|
Volume5=100 |
||||||
|
Pan5=64 |
||||||
|
Detune5=0 |
||||||
|
|
||||||
|
# TG6 |
||||||
|
BankNumber6=0 |
||||||
|
VoiceNumber6=1 |
||||||
|
MIDIChannel6=0 |
||||||
|
Volume6=100 |
||||||
|
Pan6=64 |
||||||
|
Detune6=0 |
||||||
|
|
||||||
|
# TG7 |
||||||
|
BankNumber7=0 |
||||||
|
VoiceNumber7=1 |
||||||
|
MIDIChannel7=0 |
||||||
|
Volume7=100 |
||||||
|
Pan7=64 |
||||||
|
Detune7=0 |
||||||
|
|
||||||
|
# TG8 |
||||||
|
BankNumber8=0 |
||||||
|
VoiceNumber8=1 |
||||||
|
MIDIChannel8=0 |
||||||
|
Volume8=100 |
||||||
|
Pan8=64 |
||||||
|
Detune8=0 |
@ -0,0 +1,122 @@ |
|||||||
|
//
|
||||||
|
// performanceconfig.cpp
|
||||||
|
//
|
||||||
|
// MiniDexed - Dexed FM synthesizer for bare metal Raspberry Pi
|
||||||
|
// Copyright (C) 2022 The MiniDexed Team
|
||||||
|
//
|
||||||
|
// Original author of this class:
|
||||||
|
// R. Stange <rsta2@o2online.de>
|
||||||
|
//
|
||||||
|
// 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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
#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); |
||||||
|
} |
||||||
|
|
||||||
|
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]; |
||||||
|
} |
@ -0,0 +1,57 @@ |
|||||||
|
//
|
||||||
|
// performanceconfig.h
|
||||||
|
//
|
||||||
|
// MiniDexed - Dexed FM synthesizer for bare metal Raspberry Pi
|
||||||
|
// Copyright (C) 2022 The MiniDexed Team
|
||||||
|
//
|
||||||
|
// Original author of this class:
|
||||||
|
// R. Stange <rsta2@o2online.de>
|
||||||
|
//
|
||||||
|
// 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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
#ifndef _performanceconfig_h |
||||||
|
#define _performanceconfig_h |
||||||
|
|
||||||
|
#include "config.h" |
||||||
|
#include <fatfs/ff.h> |
||||||
|
#include <Properties/propertiesfatfsfile.h> |
||||||
|
|
||||||
|
class CPerformanceConfig // Performance configuration
|
||||||
|
{ |
||||||
|
public: |
||||||
|
CPerformanceConfig (FATFS *pFileSystem); |
||||||
|
~CPerformanceConfig (void); |
||||||
|
|
||||||
|
bool Load (void); |
||||||
|
|
||||||
|
// TG#
|
||||||
|
unsigned GetBankNumber (unsigned nTG) const; // 0 .. 127
|
||||||
|
unsigned GetVoiceNumber (unsigned nTG) const; // 0 .. 31
|
||||||
|
unsigned GetMIDIChannel (unsigned nTG) const; // 0 .. 15, omni, off
|
||||||
|
unsigned GetVolume (unsigned nTG) const; // 0 .. 127
|
||||||
|
unsigned GetPan (unsigned nTG) const; // 0 .. 127
|
||||||
|
int GetDetune (unsigned nTG) const; // -99 .. 99
|
||||||
|
|
||||||
|
private: |
||||||
|
CPropertiesFatFsFile m_Properties; |
||||||
|
|
||||||
|
unsigned m_nBankNumber[CConfig::ToneGenerators]; |
||||||
|
unsigned m_nVoiceNumber[CConfig::ToneGenerators]; |
||||||
|
unsigned m_nMIDIChannel[CConfig::ToneGenerators]; |
||||||
|
unsigned m_nVolume[CConfig::ToneGenerators]; |
||||||
|
unsigned m_nPan[CConfig::ToneGenerators]; |
||||||
|
int m_nDetune[CConfig::ToneGenerators]; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif |
Loading…
Reference in new issue