WOPN redpath

This commit is contained in:
James Alan Nguyen 2022-05-09 20:06:09 +10:00
parent f8ffe04869
commit 158163312b

View file

@ -1442,8 +1442,7 @@ void DivEngine::loadWOPL(SafeReader& reader, std::vector<DivInstrument*>& ret, S
for (int i : {2, 0, 3, 1}) { // omfg >_< for (int i : {2, 0, 3, 1}) { // omfg >_<
readOpliOp(reader, ins->fm.op[i]); readOpliOp(reader, ins->fm.op[i]);
} }
} } else {
else {
ins->fm.ops = 2; ins->fm.ops = 2;
for (int i : {1, 0}) { for (int i : {1, 0}) {
readOpliOp(reader, ins->fm.op[i]); readOpliOp(reader, ins->fm.op[i]);
@ -1470,8 +1469,7 @@ void DivEngine::loadWOPL(SafeReader& reader, std::vector<DivInstrument*>& ret, S
reader.seek(0, SEEK_END); reader.seek(0, SEEK_END);
ret.push_back(ins); ret.push_back(ins);
} }
} } catch (EndOfFileException& e) {
catch (EndOfFileException& e) {
lastError = "premature end of file"; lastError = "premature end of file";
logE("premature end of file"); logE("premature end of file");
if (ins != NULL) { if (ins != NULL) {
@ -1483,6 +1481,7 @@ void DivEngine::loadWOPL(SafeReader& reader, std::vector<DivInstrument*>& ret, S
void DivEngine::loadWOPN(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath) { void DivEngine::loadWOPN(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath) {
std::vector<DivInstrument*> insList; std::vector<DivInstrument*> insList;
int readCount = 0; int readCount = 0;
bool is_failed = false;
uint16_t version; uint16_t version;
uint16_t meloBankCount; uint16_t meloBankCount;
@ -1625,6 +1624,7 @@ void DivEngine::loadWOPN(SafeReader& reader, std::vector<DivInstrument*>& ret, S
} catch (EndOfFileException& e) { } catch (EndOfFileException& e) {
lastError = "premature end of file"; lastError = "premature end of file";
logE("premature end of file"); logE("premature end of file");
is_failed = true;
} }
for (midibank_t* m : meloMetadata) { for (midibank_t* m : meloMetadata) {
@ -1633,6 +1633,12 @@ void DivEngine::loadWOPN(SafeReader& reader, std::vector<DivInstrument*>& ret, S
for (midibank_t* m : percMetadata) { for (midibank_t* m : percMetadata) {
delete m; delete m;
} }
if (is_failed) {
for (DivInstrument* p : insList) {
delete p;
}
}
} }
std::vector<DivInstrument*> DivEngine::instrumentFromFile(const char* path) { std::vector<DivInstrument*> DivEngine::instrumentFromFile(const char* path) {