improve low-latency mode strategy
This commit is contained in:
parent
eb70086234
commit
45460df96d
|
|
@ -2237,6 +2237,8 @@ bool DivEngine::initAudioBackend() {
|
||||||
if (metroVol<0.0f) metroVol=0.0f;
|
if (metroVol<0.0f) metroVol=0.0f;
|
||||||
if (metroVol>2.0f) metroVol=2.0f;
|
if (metroVol>2.0f) metroVol=2.0f;
|
||||||
|
|
||||||
|
if (lowLatency) logI("using low latency mode.");
|
||||||
|
|
||||||
switch (audioEngine) {
|
switch (audioEngine) {
|
||||||
case DIV_AUDIO_JACK:
|
case DIV_AUDIO_JACK:
|
||||||
#ifndef HAVE_JACK
|
#ifndef HAVE_JACK
|
||||||
|
|
|
||||||
|
|
@ -21,14 +21,19 @@
|
||||||
#include "instrument.h"
|
#include "instrument.h"
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
|
|
||||||
void DivMacroStruct::doMacro(DivInstrumentMacro& source, bool released) {
|
void DivMacroStruct::doMacro(DivInstrumentMacro& source, bool released, bool tick) {
|
||||||
|
if (!tick) {
|
||||||
|
had=false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (finished) {
|
if (finished) {
|
||||||
finished=false;
|
finished=false;
|
||||||
}
|
}
|
||||||
if (had!=has) {
|
if (actualHad!=has) {
|
||||||
finished=true;
|
finished=true;
|
||||||
}
|
}
|
||||||
had=has;
|
actualHad=has;
|
||||||
|
had=actualHad;
|
||||||
if (has) {
|
if (has) {
|
||||||
val=source.val[pos++];
|
val=source.val[pos++];
|
||||||
if (source.rel>=0 && pos>source.rel && !released) {
|
if (source.rel>=0 && pos>source.rel && !released) {
|
||||||
|
|
@ -52,17 +57,18 @@ void DivMacroInt::next() {
|
||||||
if (ins==NULL) return;
|
if (ins==NULL) return;
|
||||||
// run macros
|
// run macros
|
||||||
// TODO: potentially get rid of list to avoid allocations
|
// TODO: potentially get rid of list to avoid allocations
|
||||||
if (--subTick<=0) {
|
subTick--;
|
||||||
|
for (size_t i=0; i<macroListLen; i++) {
|
||||||
|
if (macroList[i]!=NULL && macroSource[i]!=NULL) {
|
||||||
|
macroList[i]->doMacro(*macroSource[i],released,subTick==0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (subTick<=0) {
|
||||||
if (e==NULL) {
|
if (e==NULL) {
|
||||||
subTick=1;
|
subTick=1;
|
||||||
} else {
|
} else {
|
||||||
subTick=e->tickMult;
|
subTick=e->tickMult;
|
||||||
}
|
}
|
||||||
for (size_t i=0; i<macroListLen; i++) {
|
|
||||||
if (macroList[i]!=NULL && macroSource[i]!=NULL) {
|
|
||||||
macroList[i]->doMacro(*macroSource[i],released);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,6 +91,7 @@ void DivMacroInt::init(DivInstrument* which) {
|
||||||
if (macroList[i]!=NULL) macroList[i]->init();
|
if (macroList[i]!=NULL) macroList[i]->init();
|
||||||
}
|
}
|
||||||
macroListLen=0;
|
macroListLen=0;
|
||||||
|
subTick=1;
|
||||||
|
|
||||||
released=false;
|
released=false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,17 +27,17 @@ class DivEngine;
|
||||||
struct DivMacroStruct {
|
struct DivMacroStruct {
|
||||||
int pos;
|
int pos;
|
||||||
int val;
|
int val;
|
||||||
bool has, had, finished, will;
|
bool has, had, actualHad, finished, will;
|
||||||
unsigned int mode;
|
unsigned int mode;
|
||||||
void doMacro(DivInstrumentMacro& source, bool released);
|
void doMacro(DivInstrumentMacro& source, bool released, bool tick);
|
||||||
void init() {
|
void init() {
|
||||||
pos=mode=0;
|
pos=mode=0;
|
||||||
has=had=will=false;
|
has=had=actualHad=will=false;
|
||||||
// TODO: test whether this breaks anything?
|
// TODO: test whether this breaks anything?
|
||||||
val=0;
|
val=0;
|
||||||
}
|
}
|
||||||
void prepare(DivInstrumentMacro& source) {
|
void prepare(DivInstrumentMacro& source) {
|
||||||
has=had=will=true;
|
has=had=actualHad=will=true;
|
||||||
mode=source.mode;
|
mode=source.mode;
|
||||||
}
|
}
|
||||||
DivMacroStruct():
|
DivMacroStruct():
|
||||||
|
|
@ -45,6 +45,7 @@ struct DivMacroStruct {
|
||||||
val(0),
|
val(0),
|
||||||
has(false),
|
has(false),
|
||||||
had(false),
|
had(false),
|
||||||
|
actualHad(false),
|
||||||
finished(false),
|
finished(false),
|
||||||
will(false),
|
will(false),
|
||||||
mode(0) {}
|
mode(0) {}
|
||||||
|
|
@ -128,7 +129,7 @@ class DivMacroInt {
|
||||||
e(NULL),
|
e(NULL),
|
||||||
ins(NULL),
|
ins(NULL),
|
||||||
macroListLen(0),
|
macroListLen(0),
|
||||||
subTick(0),
|
subTick(1),
|
||||||
released(false),
|
released(false),
|
||||||
vol(),
|
vol(),
|
||||||
arp(),
|
arp(),
|
||||||
|
|
|
||||||
|
|
@ -1654,7 +1654,7 @@ bool DivEngine::nextTick(bool noAccum) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (consoleMode) fprintf(stderr,"\x1b[2K> %d:%.2d:%.2d.%.2d %.2x/%.2x:%.3d/%.3d %4dcmd/s\x1b[G",totalSeconds/3600,(totalSeconds/60)%60,totalSeconds%60,totalTicks/10000,curOrder,song.ordersLen,curRow,song.patLen,cmdsPerSecond);
|
if (consoleMode && subticks<=1) fprintf(stderr,"\x1b[2K> %d:%.2d:%.2d.%.2d %.2x/%.2x:%.3d/%.3d %4dcmd/s\x1b[G",totalSeconds/3600,(totalSeconds/60)%60,totalSeconds%60,totalTicks/10000,curOrder,song.ordersLen,curRow,song.patLen,cmdsPerSecond);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (haltOn==DIV_HALT_TICK) halted=true;
|
if (haltOn==DIV_HALT_TICK) halted=true;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue