Add ability to configure default synth

This commit is contained in:
Dale Whinham committed 2020-11-22 23:16:44 +00:00
1 parent 2705788391
commit 5da2eca00e
5 files changed
+22 -3

No files matched your search

+1
View File
@@ -14,6 +14,7 @@
#endif
BEGIN_SECTION(system)
CFG(default_synth, TSystemDefaultSynth, SystemDefaultSynth, TSystemDefaultSynth::MT32 )
CFG(i2c_baud_rate, int, SystemI2CBaudRate, 400000 )
CFG(power_save_timeout, int, SystemPowerSaveTimeout, 300 )
END_SECTION
+6
View File
@@ -29,6 +29,10 @@
class CConfig
{
public:
#define ENUM_SYSTEMDEFAULTSYNTH(ENUM) \
ENUM(MT32, mt32) \
ENUM(SoundFont, soundfont)
#define ENUM_AUDIOOUTPUTDEVICE(ENUM) \
ENUM(PWM, pwm) \
ENUM(I2SDAC, i2s)
@@ -49,6 +53,7 @@ public:
ENUM(HD44780I2C, hd44780_i2c) \
ENUM(SSD1306I2C, ssd1306_i2c)
CONFIG_ENUM(TSystemDefaultSynth, ENUM_SYSTEMDEFAULTSYNTH);
CONFIG_ENUM(TAudioOutputDevice, ENUM_AUDIOOUTPUTDEVICE);
CONFIG_ENUM(TAudioI2CDACInit, ENUM_AUDIOI2CDACINIT);
CONFIG_ENUM(TLCDType, ENUM_LCDTYPE);
@@ -68,6 +73,7 @@ private:
// Overloaded function to parse config options based on their types specified in the definition file
static bool ParseOption(const char* pString, bool* pOut);
static bool ParseOption(const char* pString, int* pOut, bool bHex = false);
static bool ParseOption(const char* pString, TSystemDefaultSynth* pOut);
static bool ParseOption(const char* pString, TAudioOutputDevice* pOut);
static bool ParseOption(const char* pString, TAudioI2CDACInit* pOut);
static bool ParseOption(const char* pString, TMT32EmuResamplerQuality* pOut);
+8
View File
@@ -14,6 +14,14 @@
# -----------------------------------------------------------------------------
[system]
# Set the default synthesizer to be made active on startup.
#
# Values: mt32*, soundfont
#
# mt32: Use mt32emu (Munt) for Roland MT-32 emulation
# soundfont: Use FluidSynth for SoundFont synthesis
default_synth = mt32
# Set the I2C baud rate/clock speed for all peripherals (Hz).
#
# Most peripherals will work fine at the default speed (400KHz "fast mode"),
+2
View File
@@ -54,6 +54,7 @@ const char* TrueStrings[] = {"true", "on", "1"};
const char* FalseStrings[] = {"false", "off", "0"};
// Enum string tables
CONFIG_ENUM_STRINGS(TSystemDefaultSynth, ENUM_SYSTEMDEFAULTSYNTH);
CONFIG_ENUM_STRINGS(TAudioOutputDevice, ENUM_AUDIOOUTPUTDEVICE);
CONFIG_ENUM_STRINGS(TAudioI2CDACInit, ENUM_AUDIOI2CDACINIT);
CONFIG_ENUM_STRINGS(TMT32EmuResamplerQuality, ENUM_RESAMPLERQUALITY);
@@ -136,6 +137,7 @@ bool CConfig::ParseOption(const char* pString, int* pOutInt, bool bHex)
}
// Define template function wrappers for parsing enums
CONFIG_ENUM_PARSER(TSystemDefaultSynth);
CONFIG_ENUM_PARSER(TAudioOutputDevice);
CONFIG_ENUM_PARSER(TAudioI2CDACInit);
CONFIG_ENUM_PARSER(TMT32EmuResamplerQuality);
+5 -3
View File
@@ -152,13 +152,15 @@ bool CMT32Pi::Initialize(bool bSerialMIDIEnabled)
m_pSoundFontSynth = nullptr;
}
// TODO: Config option
// Set initial synthesizer
m_pCurrentSynth = m_pMT32Synth;
if (config.SystemDefaultSynth == CConfig::TSystemDefaultSynth::MT32)
m_pCurrentSynth = m_pMT32Synth;
else if (config.SystemDefaultSynth == CConfig::TSystemDefaultSynth::SoundFont)
m_pCurrentSynth = m_pSoundFontSynth;
if (!m_pCurrentSynth)
{
logger.Write(MT32PiName, LogError, "No synthesizers initialized successfully");
logger.Write(MT32PiName, LogError, "Preferred synth failed to initialize successfully");
LCDLog(TLCDLogType::Startup, "Synth init failed!");
return false;
}