From 7cd0d728b203bb5d6288eea186f65f3ce1cb2f3a Mon Sep 17 00:00:00 2001 From: James Alan Nguyen Date: Sat, 30 Apr 2022 16:11:27 +1000 Subject: [PATCH] Fix GYBv1/2 instrument name read --- src/engine/fileOpsIns.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/engine/fileOpsIns.cpp b/src/engine/fileOpsIns.cpp index 8afbf841..8168ff0a 100644 --- a/src/engine/fileOpsIns.cpp +++ b/src/engine/fileOpsIns.cpp @@ -1227,23 +1227,25 @@ void DivEngine::loadGYB(SafeReader& reader, std::vector& ret, St } // Instrument data - for (int i = 0; i < (insMelodyCount+insDrumCount); ++i) { - // TODO determine if a patch is 'empty' -> ignore and move on + for (int i = 0; i < (insMelodyCount + insDrumCount); ++i) { bool isDrum = (i >= insMelodyCount); - DivInstrument* newIns = readInstrument(reader, (version==2)); + DivInstrument* newIns = readInstrument(reader, (version == 2)); reader.readC(); // skip transpose if (version == 2) { reader.readC(); // skip padding } - - uint8_t nameLen = reader.readC(); - String insName = (nameLen > 0) ? reader.readString(nameLen) : fmt::sprintf("%s [%d]", stripPath, readCount); - - newIns->name = insName; + reader.readC(); insList.push_back(newIns); ++readCount; } + // Instrument name + for (int i = 0; i < (insMelodyCount + insDrumCount); ++i) { + uint8_t nameLen = reader.readC(); + String insName = (nameLen > 0) ? reader.readString(nameLen) : fmt::sprintf("%s [%d]", stripPath, readCount); + insList[i]->name = insName; + } + // Map to note assignment currently not supported. } else { // GYBv3+ @@ -1280,9 +1282,8 @@ void DivEngine::loadGYB(SafeReader& reader, std::vector& ret, St newIns->name = insName; insList.push_back(newIns); } - - reader.seek(0, SEEK_END); } + reader.seek(0, SEEK_END); } } catch (EndOfFileException& e) {