diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index c56eff9c6..f77ab6350 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -739,6 +739,7 @@ String DivEngine::getWarnings() { } DivInstrument* DivEngine::getIns(int index, DivInstrumentType fallbackType) { + if (index==-2 && tempIns!=NULL) return tempIns; if (index<0 || index>=song.insLen) { switch (fallbackType) { case DIV_INS_OPLL: @@ -1363,6 +1364,15 @@ int DivEngine::addInstrumentPtr(DivInstrument* which) { return song.insLen; } +void DivEngine::loadTempIns(DivInstrument* which) { + BUSY_BEGIN; + if (tempIns==NULL) { + tempIns=new DivInstrument; + } + memcpy(tempIns,which,sizeof(DivInstrument)); + BUSY_END; +} + void DivEngine::delInstrument(int index) { BUSY_BEGIN; saveLock.lock(); diff --git a/src/engine/engine.h b/src/engine/engine.h index 212bf4228..5bbb1060e 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -302,6 +302,7 @@ class DivEngine { public: DivSong song; + DivInstrument* tempIns; DivSystem sysOfChan[DIV_MAX_CHANS]; int dispatchOfChan[DIV_MAX_CHANS]; int dispatchChanOfChan[DIV_MAX_CHANS]; @@ -525,6 +526,9 @@ class DivEngine { // if the returned vector is empty then there was an error. std::vector instrumentFromFile(const char* path); + // load temporary instrument + void loadTempIns(DivInstrument* which); + // delete instrument void delInstrument(int index); @@ -798,6 +802,7 @@ class DivEngine { metroAmp(0.0f), metroVol(1.0f), totalProcessed(0), + tempIns(NULL), oscBuf{NULL,NULL}, oscSize(1), oscReadPos(0), diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index a3c413179..26e414e05 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -2419,7 +2419,7 @@ bool FurnaceGUI::loop() { } } - wantCaptureKeyboard=ImGui::GetIO().WantCaptureKeyboard; + wantCaptureKeyboard=ImGui::GetIO().WantTextInput; while (true) { midiLock.lock();