diff options
author | Vitaly Novichkov <Wohlstand@users.noreply.github.com> | 2018-07-04 00:12:35 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-04 00:12:35 +0300 |
commit | 0c080d6a4d843f37f17441bb7ea628c9bfa09119 (patch) | |
tree | 6de9f5b6e356aa34a3bec4ae662b591488eff16d | |
parent | b2bb93418e81123878e0ded97ec528a48f44ace6 (diff) | |
parent | cd307098b7cf846b74f265d1d59285b2a6f81ada (diff) | |
download | libADLMIDI-0c080d6a4d843f37f17441bb7ea628c9bfa09119.tar.gz libADLMIDI-0c080d6a4d843f37f17441bb7ea628c9bfa09119.tar.bz2 libADLMIDI-0c080d6a4d843f37f17441bb7ea628c9bfa09119.zip |
Merge pull request #127 from jpcima/describe-channels
fix indexing errors in channel description
-rw-r--r-- | src/adlmidi_midiplay.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/adlmidi_midiplay.cpp b/src/adlmidi_midiplay.cpp index e01a1b8..b256d79 100644 --- a/src/adlmidi_midiplay.cpp +++ b/src/adlmidi_midiplay.cpp @@ -1731,32 +1731,32 @@ void MIDIplay::describeChannels(char *str, char *attr, size_t size) uint32_t numChannels = synth.m_numChannels; uint32_t index = 0; - for(uint32_t i = 0; index < numChannels && index < size - 1; ++i) + while(index < numChannels && index < size - 1) { - const AdlChannel &adlChannel = m_chipChannels[i]; + const AdlChannel &adlChannel = m_chipChannels[index]; AdlChannel::LocationData *loc = adlChannel.users_first; if(!loc) // off { - str[index++] = '-'; + str[index] = '-'; } else if(loc->next) // arpeggio { - str[index++] = '@'; + str[index] = '@'; } else // on { - switch(synth.m_channelCategory[i]) + switch(synth.m_channelCategory[index]) { case OPL3::ChanCat_Regular: - str[index++] = '+'; + str[index] = '+'; break; case OPL3::ChanCat_4op_Master: case OPL3::ChanCat_4op_Slave: - str[index++] = '#'; + str[index] = '#'; break; default: // rhythm-mode percussion - str[index++] = 'r'; + str[index] = 'r'; break; } } @@ -1766,6 +1766,7 @@ void MIDIplay::describeChannels(char *str, char *attr, size_t size) attribute |= (uint8_t)(loc->loc.MidCh & 0xF); attr[index] = (char)attribute; + ++index; } str[index] = 0; |