use good default instrument when adding ins

This commit is contained in:
tildearrow 2022-04-21 02:29:20 -05:00
parent 79fa8f1d02
commit 4195715dc0
2 changed files with 14 additions and 3 deletions

View File

@ -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;

View File

@ -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!";
}
};