more low-latency mode work
playSub() runs at normal tick rate
This commit is contained in:
parent
98b9bd32b9
commit
b48a2368be
|
@ -853,6 +853,7 @@ void DivEngine::playSub(bool preserveDrift, int goalRow) {
|
||||||
}
|
}
|
||||||
if (!preserveDrift) {
|
if (!preserveDrift) {
|
||||||
ticks=1;
|
ticks=1;
|
||||||
|
subticks=1;
|
||||||
}
|
}
|
||||||
skipping=false;
|
skipping=false;
|
||||||
cmdStream.clear();
|
cmdStream.clear();
|
||||||
|
|
|
@ -1476,15 +1476,17 @@ bool DivEngine::nextTick(bool noAccum) {
|
||||||
bool ret=false;
|
bool ret=false;
|
||||||
if (divider<10) divider=10;
|
if (divider<10) divider=10;
|
||||||
|
|
||||||
if (lowLatency) {
|
if (lowLatency && !skipping) {
|
||||||
tickMult=1000/divider;
|
tickMult=1000/divider;
|
||||||
if (tickMult<1) tickMult=1;
|
if (tickMult<1) tickMult=1;
|
||||||
|
} else {
|
||||||
|
tickMult=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cycles=got.rate*pow(2,MASTER_CLOCK_PREC)/(divider*tickMult);
|
cycles=got.rate*pow(2,MASTER_CLOCK_PREC)/(divider*tickMult);
|
||||||
clockDrift+=fmod(got.rate*pow(2,MASTER_CLOCK_PREC),(double)divider);
|
clockDrift+=fmod(got.rate*pow(2,MASTER_CLOCK_PREC),(double)(divider*tickMult));
|
||||||
if (clockDrift>=divider) {
|
if (clockDrift>=(divider*tickMult)) {
|
||||||
clockDrift-=divider;
|
clockDrift-=(divider*tickMult);
|
||||||
cycles++;
|
cycles++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1078,9 +1078,6 @@ void FurnaceGUI::keyDown(SDL_Event& ev) {
|
||||||
if (edit) {
|
if (edit) {
|
||||||
noteInput(num,key);
|
noteInput(num,key);
|
||||||
}
|
}
|
||||||
if (key!=100 && key!=101 && key!=102) {
|
|
||||||
previewNote(cursor.xCoarse,num);
|
|
||||||
}
|
|
||||||
} catch (std::out_of_range& e) {
|
} catch (std::out_of_range& e) {
|
||||||
}
|
}
|
||||||
} else if (edit) { // value
|
} else if (edit) { // value
|
||||||
|
@ -1184,22 +1181,8 @@ void FurnaceGUI::keyDown(SDL_Event& ev) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// PER-WINDOW PREVIEW KEYS
|
// PER-WINDOW PREVIEW KEYS
|
||||||
|
// TODO: move this to new event handler
|
||||||
switch (curWindow) {
|
switch (curWindow) {
|
||||||
case GUI_WINDOW_INS_EDIT:
|
|
||||||
case GUI_WINDOW_INS_LIST:
|
|
||||||
case GUI_WINDOW_EDIT_CONTROLS:
|
|
||||||
case GUI_WINDOW_SONG_INFO:
|
|
||||||
if (!ev.key.repeat) {
|
|
||||||
try {
|
|
||||||
int key=noteKeys.at(ev.key.keysym.scancode);
|
|
||||||
int num=12*curOctave+key;
|
|
||||||
if (key!=100 && key!=101 && key!=102) {
|
|
||||||
previewNote(cursor.xCoarse,num);
|
|
||||||
}
|
|
||||||
} catch (std::out_of_range& e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GUI_WINDOW_SAMPLE_EDIT:
|
case GUI_WINDOW_SAMPLE_EDIT:
|
||||||
case GUI_WINDOW_SAMPLE_LIST:
|
case GUI_WINDOW_SAMPLE_LIST:
|
||||||
if (!ev.key.repeat) {
|
if (!ev.key.repeat) {
|
||||||
|
@ -1238,19 +1221,7 @@ void FurnaceGUI::keyDown(SDL_Event& ev) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FurnaceGUI::keyUp(SDL_Event& ev) {
|
void FurnaceGUI::keyUp(SDL_Event& ev) {
|
||||||
stopPreviewNote(ev.key.keysym.scancode,true);
|
// nothing for now
|
||||||
if (wavePreviewOn) {
|
|
||||||
if (ev.key.keysym.scancode==wavePreviewKey) {
|
|
||||||
wavePreviewOn=false;
|
|
||||||
e->stopWavePreview();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (samplePreviewOn) {
|
|
||||||
if (ev.key.keysym.scancode==samplePreviewKey) {
|
|
||||||
samplePreviewOn=false;
|
|
||||||
e->stopSamplePreview();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dirExists(String what) {
|
bool dirExists(String what) {
|
||||||
|
@ -2021,7 +1992,47 @@ void FurnaceGUI::editOptions(bool topMenu) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _processEvent(void* instance, SDL_Event* event) {
|
||||||
|
return ((FurnaceGUI*)instance)->processEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
int FurnaceGUI::processEvent(SDL_Event* ev) {
|
||||||
|
if (ev->type==SDL_KEYDOWN) {
|
||||||
|
if (!ev->key.repeat) {
|
||||||
|
try {
|
||||||
|
int key=noteKeys.at(ev->key.keysym.scancode);
|
||||||
|
int num=12*curOctave+key;
|
||||||
|
|
||||||
|
if (num<-60) num=-60; // C-(-5)
|
||||||
|
if (num>119) num=119; // B-9
|
||||||
|
|
||||||
|
if (key!=100 && key!=101 && key!=102) {
|
||||||
|
previewNote(cursor.xCoarse,num);
|
||||||
|
}
|
||||||
|
} catch (std::out_of_range& e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (ev->type==SDL_KEYUP) {
|
||||||
|
stopPreviewNote(ev->key.keysym.scancode,true);
|
||||||
|
if (wavePreviewOn) {
|
||||||
|
if (ev->key.keysym.scancode==wavePreviewKey) {
|
||||||
|
wavePreviewOn=false;
|
||||||
|
e->stopWavePreview();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (samplePreviewOn) {
|
||||||
|
if (ev->key.keysym.scancode==samplePreviewKey) {
|
||||||
|
samplePreviewOn=false;
|
||||||
|
e->stopSamplePreview();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
bool FurnaceGUI::loop() {
|
bool FurnaceGUI::loop() {
|
||||||
|
SDL_SetEventFilter(_processEvent,this);
|
||||||
|
|
||||||
while (!quit) {
|
while (!quit) {
|
||||||
SDL_Event ev;
|
SDL_Event ev;
|
||||||
while (SDL_PollEvent(&ev)) {
|
while (SDL_PollEvent(&ev)) {
|
||||||
|
@ -2131,23 +2142,7 @@ bool FurnaceGUI::loop() {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
if (!ImGui::GetIO().WantCaptureKeyboard) {
|
// for now
|
||||||
keyUp(ev);
|
|
||||||
} else {
|
|
||||||
stopPreviewNote(ev.key.keysym.scancode,true);
|
|
||||||
if (wavePreviewOn) {
|
|
||||||
if (ev.key.keysym.scancode==wavePreviewKey) {
|
|
||||||
wavePreviewOn=false;
|
|
||||||
e->stopWavePreview();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (samplePreviewOn) {
|
|
||||||
if (ev.key.keysym.scancode==samplePreviewKey) {
|
|
||||||
samplePreviewOn=false;
|
|
||||||
e->stopSamplePreview();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case SDL_DROPFILE:
|
case SDL_DROPFILE:
|
||||||
if (ev.drop.file!=NULL) {
|
if (ev.drop.file!=NULL) {
|
||||||
|
|
|
@ -1215,6 +1215,7 @@ class FurnaceGUI {
|
||||||
void addScroll(int amount);
|
void addScroll(int amount);
|
||||||
void setFileName(String name);
|
void setFileName(String name);
|
||||||
void runBackupThread();
|
void runBackupThread();
|
||||||
|
int processEvent(SDL_Event* ev);
|
||||||
bool loop();
|
bool loop();
|
||||||
bool finish();
|
bool finish();
|
||||||
bool init();
|
bool init();
|
||||||
|
|
Loading…
Reference in a new issue