auto-determine ins type when adding

This commit is contained in:
tildearrow 2022-01-09 23:50:26 -05:00
parent 7d336d61f7
commit d0a2a0f902
3 changed files with 14 additions and 4 deletions

View File

@ -2486,12 +2486,22 @@ void DivEngine::muteChannel(int chan, bool mute) {
isBusy.unlock(); isBusy.unlock();
} }
int DivEngine::addInstrument() { int DivEngine::addInstrument(int refChan) {
isBusy.lock(); isBusy.lock();
DivInstrument* ins=new DivInstrument; DivInstrument* ins=new DivInstrument;
int insCount=(int)song.ins.size(); int insCount=(int)song.ins.size();
ins->name=fmt::sprintf("Instrument %d",insCount); ins->name=fmt::sprintf("Instrument %d",insCount);
ins->mode=isFMSystem(song.system[0]); if (getChannelType(refChan)==0) {
ins->type=DIV_INS_FM;
} else {
ins->type=DIV_INS_STD;
if (song.system[dispatchOfChan[refChan]]==DIV_SYSTEM_GB) {
ins->type=DIV_INS_GB;
}
if (song.system[dispatchOfChan[refChan]]==DIV_SYSTEM_C64_8580 || song.system[dispatchOfChan[refChan]]==DIV_SYSTEM_C64_6581) {
ins->type=DIV_INS_C64;
}
}
song.ins.push_back(ins); song.ins.push_back(ins);
song.insLen=insCount+1; song.insLen=insCount+1;
isBusy.unlock(); isBusy.unlock();

View File

@ -317,7 +317,7 @@ class DivEngine {
bool isPlaying(); bool isPlaying();
// add instrument // add instrument
int addInstrument(); int addInstrument(int refChan=0);
// delete instrument // delete instrument
void delInstrument(int index); void delInstrument(int index);

View File

@ -506,7 +506,7 @@ void FurnaceGUI::drawInsList() {
if (!insListOpen) return; if (!insListOpen) return;
if (ImGui::Begin("Instruments",&insListOpen)) { if (ImGui::Begin("Instruments",&insListOpen)) {
if (ImGui::Button(ICON_FA_PLUS "##InsAdd")) { if (ImGui::Button(ICON_FA_PLUS "##InsAdd")) {
curIns=e->addInstrument(); curIns=e->addInstrument(cursor.xCoarse);
modified=true; modified=true;
} }
ImGui::SameLine(); ImGui::SameLine();