diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 44de597bd..b2d1e5c94 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -2038,7 +2038,15 @@ bool FurnaceGUI::loop() { while (!quit) { SDL_Event ev; + if (e->isPlaying()) { + WAKE_UP; + } + if (--drawHalt<=0) { + drawHalt=0; + if (settings.powerSave) SDL_WaitEventTimeout(NULL,500); + } while (SDL_PollEvent(&ev)) { + WAKE_UP; ImGui_ImplSDL2_ProcessEvent(&ev); switch (ev.type) { case SDL_MOUSEMOTION: { @@ -3425,6 +3433,7 @@ FurnaceGUI::FurnaceGUI(): wantCaptureKeyboard(false), displayNew(false), vgmExportVersion(0x171), + drawHalt(10), curFileDialog(GUI_FILE_OPEN), warnAction(GUI_WARN_OPEN), postWarnAction(GUI_WARN_GENERIC), diff --git a/src/gui/gui.h b/src/gui/gui.h index 447708b12..b6613e9df 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -41,6 +41,7 @@ #define unimportant(x) if (x) {handleUnimportant} #define MARK_MODIFIED modified=true; +#define WAKE_UP drawHalt=16; #define TOGGLE_COLOR(x) ((x)?uiColors[GUI_COLOR_TOGGLE_ON]:uiColors[GUI_COLOR_TOGGLE_OFF]) @@ -715,6 +716,7 @@ class FurnaceGUI { bool displayNew; bool willExport[32]; int vgmExportVersion; + int drawHalt; FurnaceGUIFileDialogs curFileDialog; FurnaceGUIWarnings warnAction; @@ -820,6 +822,7 @@ class FurnaceGUI { int cursorMoveNoScroll; int lowLatency; int notePreviewBehavior; + int powerSave; unsigned int maxUndoSteps; String mainFontPath; String patFontPath; @@ -893,6 +896,7 @@ class FurnaceGUI { cursorMoveNoScroll(0), lowLatency(0), notePreviewBehavior(1), + powerSave(1), maxUndoSteps(100), mainFontPath(""), patFontPath(""), diff --git a/src/gui/osc.cpp b/src/gui/osc.cpp index 266dfa3bf..030a84e9c 100644 --- a/src/gui/osc.cpp +++ b/src/gui/osc.cpp @@ -49,12 +49,19 @@ void FurnaceGUI::readOsc() { for (int i=0; i<512; i++) { int pos=(readPos+(i*total/512))&0x7fff; oscValues[i]=(e->oscBuf[0][pos]+e->oscBuf[1][pos])*0.5f; + if (oscValues[i]>0.001f || oscValues[i]<-0.001f) { + WAKE_UP; + } } float peakDecay=0.05f*60.0f*ImGui::GetIO().DeltaTime; for (int i=0; i<2; i++) { peak[i]*=1.0-peakDecay; - if (peak[i]<0.0001) peak[i]=0.0; + if (peak[i]<0.0001) { + peak[i]=0.0; + } else { + WAKE_UP; + } float newPeak=peak[i]; for (int j=0; jgetConfInt("cursorMoveNoScroll",0); settings.lowLatency=e->getConfInt("lowLatency",0); settings.notePreviewBehavior=e->getConfInt("notePreviewBehavior",1); + settings.powerSave=e->getConfInt("powerSave",POWER_SAVE_DEFAULT); clampSetting(settings.mainFontSize,2,96); clampSetting(settings.patFontSize,2,96); @@ -1686,6 +1702,7 @@ void FurnaceGUI::syncSettings() { clampSetting(settings.cursorMoveNoScroll,0,1); clampSetting(settings.lowLatency,0,1); clampSetting(settings.notePreviewBehavior,0,3); + clampSetting(settings.powerSave,0,1); // keybinds for (int i=0; isetConf("cursorMoveNoScroll",settings.cursorMoveNoScroll); e->setConf("lowLatency",settings.lowLatency); e->setConf("notePreviewBehavior",settings.notePreviewBehavior); + e->setConf("powerSave",settings.powerSave); // colors for (int i=0; i