Replace LCD simulation with new libmt32emu code

This commit is contained in:
Dale Whinham committed 2022-03-10 14:57:16 +00:00
1 parent 31c96afa3c
commit 164174aab4
3 files changed
+12 -83

No files matched your search

+1
View File
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Update to libmt32emu v2.6.1.
* This update adds support for MT-32 ROM versions 2.06, 2.07 and CM-32LN ROM version 1.00 (CM-32LN is untested).
- Update to FluidSynth v2.2.5.
- MT-32 LCD emulation replaced with new libmt32emu v2.6+ display emulation.
### Fixed
-14
View File
@@ -75,26 +75,15 @@ public:
u8 GetMasterVolume() const;
private:
enum class TLCDState
{
DisplayingPartStates,
DisplayingTimbreName,
DisplayingMessage,
};
static constexpr size_t MT32ChannelCount = 9;
// N characters plus null terminator
static constexpr size_t LCDTextBufferSize = 20 + 1;
static constexpr unsigned LCDMessageDisplayTimeMillis = 200;
static constexpr unsigned LCDTimbreDisplayTimeMillis = 1200;
void UpdatePartStateText(bool bNarrow);
void GetPartLevels(unsigned int nTicks, float PartLevels[9], float PartPeaks[9]);
// MT32Emu::ReportHandler
virtual bool onMIDIQueueOverflow() override;
virtual void onProgramChanged(MT32Emu::Bit8u nPartNum, const char* pSoundGroupName, const char* pPatchName) override;
virtual void printDebug(const char* pFmt, va_list pList) override;
virtual void showLCDMessage(const char* pMessage) override;
virtual void onDeviceReset() override;
@@ -116,10 +105,7 @@ private:
const MT32Emu::ROMImage* m_pPCMROMImage;
// LCD state
TLCDState m_LCDState;
unsigned m_nLCDStateTime;
char m_LCDTextBuffer[LCDTextBufferSize];
u8 m_nPreviousMasterVolume;
};
#endif
+11 -69
View File
@@ -55,10 +55,7 @@ CMT32Synth::CMT32Synth(unsigned nSampleRate, float nGain, float nReverbGain, TRe
m_pControlROMImage(nullptr),
m_pPCMROMImage(nullptr),
m_LCDState(TLCDState::DisplayingPartStates),
m_nLCDStateTime(0),
m_LCDTextBuffer{'\0'},
m_nPreviousMasterVolume(0)
m_LCDTextBuffer{'\0'}
{
}
@@ -184,28 +181,8 @@ void CMT32Synth::ReportStatus() const
void CMT32Synth::UpdateLCD(CLCD& LCD, unsigned int nTicks)
{
const u8 nMasterVolume = GetMasterVolume();
const unsigned int nDeltaTicks = nTicks - m_nLCDStateTime;
bool bNarrowPartStateText = false;
// Hide message if master volume changed and message has been displayed long enough
if (m_nPreviousMasterVolume != nMasterVolume)
{
if (m_LCDState != TLCDState::DisplayingMessage || nDeltaTicks >= Utility::MillisToTicks(LCDMessageDisplayTimeMillis))
{
m_nPreviousMasterVolume = nMasterVolume;
m_LCDState = TLCDState::DisplayingPartStates;
m_nLCDStateTime = nTicks;
}
}
// Timbre change timeout
if (m_LCDState == TLCDState::DisplayingTimbreName && nDeltaTicks >= Utility::MillisToTicks(LCDTimbreDisplayTimeMillis))
{
m_LCDState = TLCDState::DisplayingPartStates;
m_nLCDStateTime = nTicks;
}
const u8 nWidth = LCD.Width();
const u8 nHeight = LCD.Height();
u8 nStatusRow, nBarHeight;
@@ -225,12 +202,17 @@ void CMT32Synth::UpdateLCD(CLCD& LCD, unsigned int nTicks)
nBarHeight = nHeight - 16;
}
if (m_LCDState == TLCDState::DisplayingPartStates)
UpdatePartStateText(bNarrowPartStateText);
float PartLevels[9], PartPeaks[9];
GetPartLevels(nTicks, PartLevels, PartPeaks);
CUserInterface::DrawChannelLevels(LCD, nBarHeight, PartLevels, PartPeaks, 9, false);
m_pSynth->getDisplayState(m_LCDTextBuffer, bNarrowPartStateText);
// Remap active part indicator character
for (size_t i = 0; i < Utility::ArraySize(m_LCDTextBuffer) - 1; ++i)
if (m_LCDTextBuffer[i] == 1)
m_LCDTextBuffer[i] = '\xFF';
LCD.Print(m_LCDTextBuffer, 0, nStatusRow, true, false);
}
@@ -309,7 +291,8 @@ const char* CMT32Synth::GetControlROMName() const
size_t nOffset;
// Find version strings from ROMs
if (strstr(pShortName, "cm32l") || strstr(pShortName, "2_04"))
// FIXME: Missing offset for CM-32LN ROM
if (strstr(pShortName, "cm32l") || strstr(pShortName, "2_04") || strstr(pShortName, "2_06") || strstr(pShortName, "2_07"))
nOffset = ROMOffsetVersionStringNew;
else if (strstr(pShortName, "1_07") || strstr(pShortName, "bluer"))
nOffset = ROMOffsetVersionString1_07;
@@ -326,27 +309,6 @@ u8 CMT32Synth::GetMasterVolume() const
return nVolume;
}
void CMT32Synth::UpdatePartStateText(bool bNarrow)
{
const u32 nPartStates = m_pSynth->getPartStates();
// First 5 parts
for (u8 i = 0; i < 5; ++i)
{
const bool bState = (nPartStates >> i) & 1;
m_LCDTextBuffer[i * 2] = bState ? '\xFF' : ('1' + i);
m_LCDTextBuffer[i * 2 + 1] = ' ';
}
// Rhythm
const bool bState = (nPartStates >> 8) & 1;
m_LCDTextBuffer[10] = bState ? '\xFF' : 'R';
m_LCDTextBuffer[11] = ' ';
// Volume
snprintf(m_LCDTextBuffer + 12, sizeof(m_LCDTextBuffer), bNarrow ? "|%3d" : "|vol:%3d", GetMasterVolume());
}
void CMT32Synth::GetPartLevels(unsigned int nTicks, float PartLevels[9], float PartPeaks[9])
{
float ChannelLevels[16], ChannelPeaks[16];
@@ -373,20 +335,6 @@ bool CMT32Synth::onMIDIQueueOverflow()
return false;
}
void CMT32Synth::onProgramChanged(MT32Emu::Bit8u nPartNum, const char* pSoundGroupName, const char* pPatchName)
{
const unsigned nTicks = CTimer::GetClockTicks();
// Bail out if displaying an MT-32 message and it hasn't been on-screen long enough
if (m_LCDState == TLCDState::DisplayingMessage && (nTicks - m_nLCDStateTime) <= Utility::MillisToTicks(LCDMessageDisplayTimeMillis))
return;
snprintf(m_LCDTextBuffer, sizeof(m_LCDTextBuffer), "%d|%s%s", nPartNum + 1, pSoundGroupName, pPatchName);
m_LCDState = TLCDState::DisplayingTimbreName;
m_nLCDStateTime = nTicks;
}
void CMT32Synth::printDebug(const char* pFmt, va_list pList)
{
//CLogger::Get()->WriteV(MT32SynthName, LogDebug, pFmt, pList);
@@ -395,12 +343,6 @@ void CMT32Synth::printDebug(const char* pFmt, va_list pList)
void CMT32Synth::showLCDMessage(const char* pMessage)
{
CLogger::Get()->Write(MT32SynthName, LogNotice, "LCD: %s", pMessage);
const unsigned nTicks = CTimer::GetClockTicks();
snprintf(m_LCDTextBuffer, sizeof(m_LCDTextBuffer), pMessage);
m_LCDState = TLCDState::DisplayingMessage;
m_nLCDStateTime = nTicks;
}
void CMT32Synth::onDeviceReset()