fix metronome in virtual tempo

This commit is contained in:
tildearrow 2022-11-09 23:52:10 -05:00
parent d944b97913
commit baa3989502
3 changed files with 16 additions and 11 deletions

View file

@ -2358,6 +2358,7 @@ void DivEngine::reset() {
firstTick=false; firstTick=false;
shallStop=false; shallStop=false;
shallStopSched=false; shallStopSched=false;
pendingMetroTick=0;
nextSpeed=speed1; nextSpeed=speed1;
divider=60; divider=60;
if (curSubSong->customTempo) { if (curSubSong->customTempo) {

View file

@ -358,7 +358,7 @@ class DivEngine {
double clockDrift; double clockDrift;
int stepPlay; int stepPlay;
int changeOrd, changePos, totalSeconds, totalTicks, totalTicksR, totalCmds, lastCmds, cmdsPerSecond, globalPitch; int changeOrd, changePos, totalSeconds, totalTicks, totalTicksR, totalCmds, lastCmds, cmdsPerSecond, globalPitch;
unsigned char extValue; unsigned char extValue, pendingMetroTick;
unsigned char speed1, speed2; unsigned char speed1, speed2;
short tempoAccum; short tempoAccum;
DivStatusView view; DivStatusView view;
@ -1073,6 +1073,7 @@ class DivEngine {
cmdsPerSecond(0), cmdsPerSecond(0),
globalPitch(0), globalPitch(0),
extValue(0), extValue(0),
pendingMetroTick(0),
speed1(3), speed1(3),
speed2(3), speed2(3),
tempoAccum(0), tempoAccum(0),

View file

@ -963,6 +963,13 @@ void DivEngine::nextRow() {
printf("| %.2x:%s | \x1b[1;33m%3d%s\x1b[m\n",curOrder,pb1,curRow,pb3); printf("| %.2x:%s | \x1b[1;33m%3d%s\x1b[m\n",curOrder,pb1,curRow,pb3);
} }
if (curSubSong->hilightA>0) {
if ((curRow%curSubSong->hilightA)==0) pendingMetroTick=1;
}
if (curSubSong->hilightB>0) {
if ((curRow%curSubSong->hilightB)==0) pendingMetroTick=2;
}
prevOrder=curOrder; prevOrder=curOrder;
prevRow=curRow; prevRow=curRow;
@ -1597,16 +1604,6 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
// 2. check whether we gonna tick // 2. check whether we gonna tick
if (cycles<=0) { if (cycles<=0) {
// we have to tick // we have to tick
if (!freelance && stepPlay!=-1 && subticks==1) {
unsigned int realPos=size-(runLeftG>>MASTER_CLOCK_PREC);
if (realPos>=size) realPos=size-1;
if (curSubSong->hilightA>0) {
if ((curRow%curSubSong->hilightA)==0 && ticks==1) metroTick[realPos]=1;
}
if (curSubSong->hilightB>0) {
if ((curRow%curSubSong->hilightB)==0 && ticks==1) metroTick[realPos]=2;
}
}
if (nextTick()) { if (nextTick()) {
lastLoopPos=size-(runLeftG>>MASTER_CLOCK_PREC); lastLoopPos=size-(runLeftG>>MASTER_CLOCK_PREC);
logD("last loop pos: %d for a size of %d and runLeftG of %d",lastLoopPos,size,runLeftG); logD("last loop pos: %d for a size of %d and runLeftG of %d",lastLoopPos,size,runLeftG);
@ -1623,6 +1620,12 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
} }
} }
} }
if (pendingMetroTick) {
unsigned int realPos=size-(runLeftG>>MASTER_CLOCK_PREC);
if (realPos>=size) realPos=size-1;
metroTick[realPos]=pendingMetroTick;
pendingMetroTick=0;
}
} else { } else {
// 3. tick the clock and fill buffers as needed // 3. tick the clock and fill buffers as needed
if (cycles<runLeftG) { if (cycles<runLeftG) {