Rework MIDI monitor to handle timer wrap

When the 1MHz timer wraps, the MIDI level meters would appear to be
stuck after a while.

Implement some additional state tracking to guard against timer wrap.

Fixes #148.
This commit is contained in:
Dale Whinham committed 2021-07-27 00:16:07 +01:00
1 parent 9a81bea4a5
commit a0ad972cdd
3 files changed
+98 -51

No files matched your search

+10 -2
View File
@@ -49,8 +49,16 @@ private:
static constexpr float PeakHoldTimeMillis = 2000.0f;
static constexpr float PeakFalloffTimeMillis = 1000.0f;
enum class TEnvelopePhase
{
Idle,
NoteOn,
NoteOff,
};
struct TNoteState
{
TEnvelopePhase EnvelopePhase;
unsigned int nNoteOnTime;
unsigned int nNoteOffTime;
u8 nVelocity;
@@ -67,8 +75,8 @@ private:
};
void ProcessCC(u8 nChannel, u8 nCC, u8 nValue, unsigned int nTicks);
inline float ComputeEnvelope(unsigned int nTicks, const TNoteState& NoteState) const;
inline float ComputePercussionEnvelope(unsigned int nTicks, const TNoteState& NoteState) const;
inline float ComputeEnvelope(TNoteState& NoteState) const;
inline float ComputePercussionEnvelope(TNoteState& NoteState) const;
TChannelState m_State[ChannelCount];
float m_PeakLevels[ChannelCount];