Load performance config from performance.ini (#54)

pull/55/head
Rene Stange 3 years ago committed by GitHub
parent 7519da5e13
commit 2199208d34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/Makefile
  2. 3
      src/kernel.cpp
  3. 20
      src/minidexed.cpp
  4. 5
      src/minidexed.h
  5. 75
      src/performance.ini
  6. 122
      src/performanceconfig.cpp
  7. 57
      src/performanceconfig.h

@ -8,7 +8,7 @@ CMSIS_DIR = ../CMSIS_5/CMSIS
OBJS = main.o kernel.o minidexed.o config.o userinterface.o \
mididevice.o midikeyboard.o serialmididevice.o pckeyboard.o \
sysexfileloader.o perftimer.o
sysexfileloader.o performanceconfig.o perftimer.o
include ./Synth_Dexed.mk
include ./Rules.mk

@ -64,7 +64,8 @@ bool CKernel::Initialize (void)
m_Config.Load ();
m_pDexed = new CMiniDexed (&m_Config, &mInterrupt, &m_GPIOManager, &m_I2CMaster);
m_pDexed = new CMiniDexed (&m_Config, &mInterrupt, &m_GPIOManager, &m_I2CMaster,
&mFileSystem);
assert (m_pDexed);
if (!m_pDexed->Initialize ())

@ -30,13 +30,14 @@
LOGMODULE ("minidexed");
CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt,
CGPIOManager *pGPIOManager, CI2CMaster *pI2CMaster)
CGPIOManager *pGPIOManager, CI2CMaster *pI2CMaster, FATFS *pFileSystem)
:
#ifdef ARM_ALLOW_MULTI_CORE
CMultiCoreSupport (CMemorySystem::Get ()),
#endif
m_pConfig (pConfig),
m_UI (this, pGPIOManager, pConfig),
m_PerformanceConfig (pFileSystem),
m_PCKeyboard (this, pConfig),
m_SerialMIDI (this, pInterrupt, pConfig),
m_bUseSerial (false),
@ -137,7 +138,22 @@ bool CMiniDexed::Initialize (void)
m_pTG[i]->setMWController (99, 7, 0);
}
SetMIDIChannel (CMIDIDevice::OmniMode, 0);
if (m_PerformanceConfig.Load ())
{
for (unsigned nTG = 0; nTG < CConfig::ToneGenerators; nTG++)
{
BankSelectLSB (m_PerformanceConfig.GetBankNumber (nTG), nTG);
ProgramChange (m_PerformanceConfig.GetVoiceNumber (nTG), nTG);
SetMIDIChannel (m_PerformanceConfig.GetMIDIChannel (nTG), nTG);
SetVolume (m_PerformanceConfig.GetVolume (nTG), nTG);
SetPan (m_PerformanceConfig.GetPan (nTG), nTG);
SetMasterTune (m_PerformanceConfig.GetDetune (nTG), nTG);
}
}
else
{
SetMIDIChannel (CMIDIDevice::OmniMode, 0);
}
// setup and start the sound device
if (!m_pSoundDevice->AllocateQueueFrames (m_pConfig->GetChunkSize ()))

@ -24,10 +24,12 @@
#include "config.h"
#include "userinterface.h"
#include "sysexfileloader.h"
#include "performanceconfig.h"
#include "midikeyboard.h"
#include "pckeyboard.h"
#include "serialmididevice.h"
#include "perftimer.h"
#include <fatfs/ff.h>
#include <stdint.h>
#include <string>
#include <circle/types.h>
@ -44,7 +46,7 @@ class CMiniDexed
{
public:
CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt,
CGPIOManager *pGPIOManager, CI2CMaster *pI2CMaster);
CGPIOManager *pGPIOManager, CI2CMaster *pI2CMaster, FATFS *pFileSystem);
bool Initialize (void);
@ -96,6 +98,7 @@ private:
CUserInterface m_UI;
CSysExFileLoader m_SysExFileLoader;
CPerformanceConfig m_PerformanceConfig;
CMIDIKeyboard *m_pMIDIKeyboard[CConfig::MaxUSBMIDIDevices];
CPCKeyboard m_PCKeyboard;

@ -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…
Cancel
Save