From d40051c7c2f594294ef3f1b51ef536cd16d9c44f Mon Sep 17 00:00:00 2001 From: probonopd Date: Sat, 26 Feb 2022 10:27:43 +0100 Subject: [PATCH] Fix Program Change numbering and voice name printing https://github.com/probonopd/MiniDexed/issues/11 --- src/minidexed.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/minidexed.cpp b/src/minidexed.cpp index d8851ae..ddf1e28 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -146,10 +146,13 @@ void CMiniDexed::MIDIPacketHandler (unsigned nCable, u8 *pPacket, unsigned nLeng if (pPacket[0] == MIDI_PROGRAM_CHANGE) { + if(pPacket[1] < 1 || pPacket[1] > 32) { + return; + } printf ("Loading voice %d\n", (unsigned) pPacket[1]); - s_pThis->loadVoiceParameters(voices_bank[0][(unsigned) pPacket[1]]); - // FIXME: The following 3 lines do not work yet + s_pThis->loadVoiceParameters(voices_bank[0][(unsigned) pPacket[1] - 1]); char buf_name[11]; + memset(reinterpret_cast(buf_name), 0, 11); // Initialize with 0x00 chars s_pThis->setName(buf_name); printf ("%s\n", buf_name); return;