ZSM export: handle Virtual Tempo quantization

This commit is contained in:
MooingLemur 2023-07-28 01:36:38 -07:00 committed by tildearrow
parent b41d8fe208
commit 7aa3aec20e
1 changed files with 12 additions and 3 deletions

View File

@ -94,6 +94,7 @@ SafeWriter* DivEngine::saveZSM(unsigned int zsmrate, bool loop) {
playSub(false); playSub(false);
//size_t tickCount=0; //size_t tickCount=0;
bool done=false; bool done=false;
bool loopNow=false;
int loopPos=-1; int loopPos=-1;
int fracWait=0; // accumulates fractional ticks int fracWait=0; // accumulates fractional ticks
if (VERA>=0) disCont[VERA].dispatch->toggleRegisterDump(true); if (VERA>=0) disCont[VERA].dispatch->toggleRegisterDump(true);
@ -109,9 +110,17 @@ SafeWriter* DivEngine::saveZSM(unsigned int zsmrate, bool loop) {
while (!done) { while (!done) {
if (loopPos==-1) { if (loopPos==-1) {
if (loopOrder==curOrder && loopRow==curRow && ticks==1 && loop) { if (loopOrder==curOrder && loopRow==curRow && loop)
loopPos=zsm.getoffset(); loopNow=true;
zsm.setLoopPoint(); if (loopNow) {
// If Virtual Tempo is in use, our exact loop point
// might be skipped to quantization error.
// If this happens, the tick immediately following is our loop point.
if (ticks==1 || !(loopOrder==curOrder && loopRow==curRow)) {
loopPos=zsm.getoffset();
zsm.setLoopPoint();
loopNow=false;
}
} }
} }
if (nextTick() || !playing) { if (nextTick() || !playing) {