From 0be1d998bc16497df15f3b6f688159d104048444 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Tue, 17 May 2022 17:02:53 +0200 Subject: [PATCH] Fix for using the right MIDI channel for SYSEX. Fix for SYSEX MIDI dump output. --- src/mididevice.cpp | 11 +++++------ src/serialmididevice.cpp | 9 +++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/mididevice.cpp b/src/mididevice.cpp index 5daacc1..ce68339 100644 --- a/src/mididevice.cpp +++ b/src/mididevice.cpp @@ -115,15 +115,14 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign { case MIDI_SYSTEM_EXCLUSIVE_BEGIN: printf("SysEx data length: [%d]\n",uint16_t(nLength)); - printf("SysEx data:\n"); + printf("SysEx data:"); for (uint16_t i = 0; i < nLength; i++) { if((i % 8) == 0) - printf("%04d:",i); + printf("\n%04d:",i); printf(" 0x%02x",pMessage[i]); - if((i % 8) == 0) - printf("\n"); } + printf("\n"); break; default: printf("Unhandled MIDI event type %0x02x\n",pMessage[0]); @@ -166,7 +165,7 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign for (unsigned nTG = 0; nTG < CConfig::ToneGenerators; nTG++) { // MIDI SYSEX per MIDI channel - if (ucStatus == MIDI_SYSTEM_EXCLUSIVE_BEGIN && m_ChannelMap[nTG] == pMessage[2] & 0x07) + if (ucStatus == MIDI_SYSTEM_EXCLUSIVE_BEGIN && (m_ChannelMap[nTG] == ((pMessage[2] & 0x07) + 1) || (m_ChannelMap[nTG] > 16 ))) HandleSystemExclusive(pMessage, nLength, nTG); else { @@ -415,7 +414,7 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL LOGNOTE("Currently code for storing a bulk bank upload is missing!"); break; default: - LOGDBG("SysEx voice parameter change: %d value: %d",pMessage[4] + ((pMessage[3] & 0x03) * 128), pMessage[5]); + LOGDBG("SysEx voice parameter change: Parameter %d value: %d",pMessage[4] + ((pMessage[3] & 0x03) * 128), pMessage[5]); m_pSynthesizer->setVoiceDataElement(pMessage[4] + ((pMessage[3] & 0x03) * 128), pMessage[5],nTG); break; } diff --git a/src/serialmididevice.cpp b/src/serialmididevice.cpp index ec819d0..157c6be 100644 --- a/src/serialmididevice.cpp +++ b/src/serialmididevice.cpp @@ -64,17 +64,14 @@ void CSerialMIDIDevice::Process (void) if (m_pConfig->GetMIDIDumpEnabled ()) { - printf("Incoming MIDI data:\n"); + printf("Incoming MIDI data:"); for (uint16_t i = 0; i < nResult; i++) { if((i % 8) == 0) - printf("%04d:",i); + printf("\n%04d:",i); printf(" 0x%02x",Buffer[i]); - if((i > 1 ) && (i % 8) == 0) - printf("\n"); } - if((nResult % 8) != 0) - printf("\n"); + printf("\n"); } // Process MIDI messages