possibly fix timer issues

issue #2189
This commit is contained in:
tildearrow 2024-12-09 13:56:20 -05:00
parent ed903c6e0a
commit 79167c382f
4 changed files with 49 additions and 1 deletions

View file

@ -1655,6 +1655,7 @@ void DivEngine::playSub(bool preserveDrift, int goalRow) {
ticks=1;
tempoAccum=0;
totalTicks=0;
totalTicksOff=0;
totalSeconds=0;
totalTicksR=0;
curMidiClock=0;
@ -3726,6 +3727,7 @@ void DivEngine::quitDispatch() {
changeOrd=-1;
changePos=0;
totalTicks=0;
totalTicksOff=0;
totalSeconds=0;
totalTicksR=0;
curMidiClock=0;

View file

@ -487,6 +487,7 @@ class DivEngine {
double midiTimeDrift;
int stepPlay;
int changeOrd, changePos, totalSeconds, totalTicks, totalTicksR, curMidiClock, curMidiTime, totalCmds, lastCmds, cmdsPerSecond, globalPitch;
double totalTicksOff;
int curMidiTimePiece, curMidiTimeCode;
unsigned char extValue, pendingMetroTick;
DivGroovePattern speeds;
@ -1451,6 +1452,7 @@ class DivEngine {
lastCmds(0),
cmdsPerSecond(0),
globalPitch(0),
totalTicksOff(0.0),
curMidiTimePiece(0),
curMidiTimeCode(0),
extValue(0),

View file

@ -2000,8 +2000,17 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
if (!freelance) {
if (stepPlay!=1) {
if (!noAccum) {
double dt=divider*tickMult;
if (skipping) {
dt*=(double)virtualTempoN/(double)MAX(1,virtualTempoD);
}
totalTicksR++;
totalTicks+=1000000/(divider*tickMult);
totalTicks+=1000000/dt;
totalTicksOff+=fmod(1000000.0,dt);
while (totalTicksOff>=dt) {
totalTicksOff-=dt;
totalTicks++;
}
}
if (totalTicks>=1000000) {
totalTicks-=1000000;

View file

@ -87,6 +87,41 @@ void FurnaceGUI::drawMobileOrderSel() {
orderScrollLocked=true;
orderScrollTolerance=true;
}
// time
if (e->isPlaying() && settings.playbackTime) {
int totalTicks=e->getTotalTicks();
int totalSeconds=e->getTotalSeconds();
String info="";
if (totalSeconds==0x7fffffff) {
info="";
} else {
if (totalSeconds>=86400) {
int totalDays=totalSeconds/86400;
int totalYears=totalDays/365;
totalDays%=365;
int totalMonths=totalDays/30;
totalDays%=30;
info+=fmt::sprintf("%dy",totalYears);
info+=fmt::sprintf("%dm",totalMonths);
info+=fmt::sprintf("%dd",totalDays);
}
if (totalSeconds>=3600) {
info+=fmt::sprintf("%.2d:",(totalSeconds/3600)%24);
}
info+=fmt::sprintf("%.2d:%.2d.%.2d",(totalSeconds/60)%60,totalSeconds%60,totalTicks/10000);
}
ImVec2 textSize=ImGui::CalcTextSize(info.c_str());
dl->AddRectFilled(ImVec2(11.0f*dpiScale,(size.y*0.5)-(5.0f*dpiScale)),ImVec2((21.0f*dpiScale)+textSize.x,(size.y*0.5)+textSize.y+(5.0f*dpiScale)),ImGui::GetColorU32(ImGuiCol_WindowBg));
dl->AddRect(ImVec2(11.0f*dpiScale,(size.y*0.5)-(5.0f*dpiScale)),ImVec2((21.0f*dpiScale)+textSize.x,(size.y*0.5)+textSize.y+(5.0f*dpiScale)),ImGui::GetColorU32(ImGuiCol_Border),0,0,dpiScale);
dl->AddText(ImVec2(16.0f*dpiScale,(size.y)*0.5),ImGui::GetColorU32(ImGuiCol_Text),info.c_str());
}
}
ImGui::End();
}