From 4195715dc0fa69f14a50b1a512c27e40fe396aa1 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 21 Apr 2022 02:29:20 -0500 Subject: [PATCH] use good default instrument when adding ins --- src/engine/engine.cpp | 15 ++++++++++++--- src/engine/song.h | 2 ++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 98cd8454c..905ba8aa5 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -742,11 +742,9 @@ DivInstrument* DivEngine::getIns(int index, DivInstrumentType fallbackType) { if (index<0 || index>=song.insLen) { switch (fallbackType) { case DIV_INS_OPLL: - logV("returning the OPLL null instrument"); return &song.nullInsOPLL; break; case DIV_INS_OPL: - logV("returning the OPL null instrument"); return &song.nullInsOPL; break; default: @@ -1310,8 +1308,19 @@ int DivEngine::addInstrument(int refChan) { BUSY_BEGIN; DivInstrument* ins=new DivInstrument; int insCount=(int)song.ins.size(); + DivInstrumentType prefType=getPreferInsType(refChan); + switch (prefType) { + case DIV_INS_OPLL: + *ins=song.nullInsOPLL; + break; + case DIV_INS_OPL: + *ins=song.nullInsOPL; + break; + default: + break; + } ins->name=fmt::sprintf("Instrument %d",insCount); - ins->type=getPreferInsType(refChan); + ins->type=prefType; saveLock.lock(); song.ins.push_back(ins); song.insLen=insCount+1; diff --git a/src/engine/song.h b/src/engine/song.h index 82d219338..20b17ae60 100644 --- a/src/engine/song.h +++ b/src/engine/song.h @@ -422,6 +422,7 @@ struct DivSong { nullInsOPLL.fm.opllPreset=7; nullInsOPLL.fm.op[1].tl=0; + nullInsOPLL.name="This is a bug! Report!"; nullInsOPL.fm.alg=0; nullInsOPL.fm.fb=7; @@ -434,6 +435,7 @@ struct DivSong { nullInsOPL.fm.op[1].dr=3; nullInsOPL.fm.op[1].rr=12; nullInsOPL.fm.op[1].mult=1; + nullInsOPL.name="This is a bug! Report!"; } };