Fix for Serial Midi In double triggering notes (#216)

Thanks @dcoredump
pull/223/head
Holger 3 years ago committed by GitHub
parent 6d14da8604
commit 52b8900293
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      src/mididevice.cpp
  2. 1
      src/minidexed.cpp
  3. 5
      src/serialmididevice.cpp

@ -49,7 +49,8 @@ LOGMODULE ("mididevice");
#define MIDI_PROGRAM_CHANGE 0b1100 #define MIDI_PROGRAM_CHANGE 0b1100
#define MIDI_PITCH_BEND 0b1110 #define MIDI_PITCH_BEND 0b1110
#define MIDI_SYSTEM_EXCLUSIVE 0xF0 #define MIDI_SYSTEM_EXCLUSIVE_BEGIN 0xF0
#define MIDI_SYSTEM_EXCLUSIVE_END 0xF7
#define MIDI_TIMING_CLOCK 0xF8 #define MIDI_TIMING_CLOCK 0xF8
#define MIDI_ACTIVE_SENSING 0xFE #define MIDI_ACTIVE_SENSING 0xFE
@ -112,7 +113,7 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
default: default:
switch(pMessage[0]) switch(pMessage[0])
{ {
case MIDI_SYSTEM_EXCLUSIVE: case MIDI_SYSTEM_EXCLUSIVE_BEGIN:
printf("SysEx data length: [%d]\n",uint16_t(nLength)); printf("SysEx data length: [%d]\n",uint16_t(nLength));
printf("SysEx data:\n"); printf("SysEx data:\n");
for (uint16_t i = 0; i < nLength; i++) for (uint16_t i = 0; i < nLength; i++)
@ -145,6 +146,7 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
if (nLength < 2) if (nLength < 2)
{ {
LOGERR("MIDI message is shorter than 2 bytes!");
return; return;
} }
@ -153,7 +155,7 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
u8 ucType = ucStatus >> 4; u8 ucType = ucStatus >> 4;
// GLOBAL MIDI SYSEX // GLOBAL MIDI SYSEX
if (pMessage[0] == MIDI_SYSTEM_EXCLUSIVE && pMessage[3] == 0x04 && pMessage[4] == 0x01 && pMessage[nLength-1] == 0xF7) // MASTER VOLUME if (pMessage[0] == MIDI_SYSTEM_EXCLUSIVE_BEGIN && pMessage[3] == 0x04 && pMessage[4] == 0x01 && pMessage[nLength-1] == MIDI_SYSTEM_EXCLUSIVE_END) // MASTER VOLUME
{ {
float32_t nMasterVolume=(pMessage[5] & (pMessage[6]<<7))/(1<<14); float32_t nMasterVolume=(pMessage[5] & (pMessage[6]<<7))/(1<<14);
LOGNOTE("Master volume: %f",nMasterVolume); LOGNOTE("Master volume: %f",nMasterVolume);
@ -164,7 +166,7 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
for (unsigned nTG = 0; nTG < CConfig::ToneGenerators; nTG++) for (unsigned nTG = 0; nTG < CConfig::ToneGenerators; nTG++)
{ {
// MIDI SYSEX per MIDI channel // MIDI SYSEX per MIDI channel
if (ucStatus == MIDI_SYSTEM_EXCLUSIVE && m_ChannelMap[nTG] == pMessage[2] & 0x07) if (ucStatus == MIDI_SYSTEM_EXCLUSIVE_BEGIN && m_ChannelMap[nTG] == pMessage[2] & 0x07)
HandleSystemExclusive(pMessage, nLength, nTG); HandleSystemExclusive(pMessage, nLength, nTG);
else else
{ {

@ -256,7 +256,6 @@ void CMiniDexed::Process (bool bPlugAndPlayUpdated)
if (m_bUseSerial) if (m_bUseSerial)
{ {
m_SerialMIDI.Process (); m_SerialMIDI.Process ();
m_SerialMIDI.Process ();
} }
m_UI.Process (); m_UI.Process ();

@ -144,6 +144,11 @@ void CSerialMIDIDevice::Process (void)
m_nSerialState = 1; m_nSerialState = 1;
goto DATABytes; goto DATABytes;
} }
else
{
m_nSerialState = 0;
goto MIDIRestart;
}
break; break;
default: default:
assert (0); assert (0);

Loading…
Cancel
Save