mirror of
https://github.com/tildearrow/furnace.git
synced 2025-01-03 22:21:09 +00:00
GUI: add ability to play from cursor position
Shift-Enter or F7
This commit is contained in:
parent
9091081b9f
commit
107187a20c
4 changed files with 33 additions and 8 deletions
|
@ -4748,7 +4748,7 @@ void* DivEngine::getDispatchChanState(int ch) {
|
||||||
return disCont[dispatchOfChan[ch]].dispatch->getChanState(dispatchChanOfChan[ch]);
|
return disCont[dispatchOfChan[ch]].dispatch->getChanState(dispatchChanOfChan[ch]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivEngine::playSub(bool preserveDrift) {
|
void DivEngine::playSub(bool preserveDrift, int goalRow) {
|
||||||
reset();
|
reset();
|
||||||
if (preserveDrift && curOrder==0) return;
|
if (preserveDrift && curOrder==0) return;
|
||||||
bool oldRepeatPattern=repeatPattern;
|
bool oldRepeatPattern=repeatPattern;
|
||||||
|
@ -4774,8 +4774,13 @@ void DivEngine::playSub(bool preserveDrift) {
|
||||||
while (curOrder<goal) {
|
while (curOrder<goal) {
|
||||||
if (nextTick(preserveDrift)) break;
|
if (nextTick(preserveDrift)) break;
|
||||||
}
|
}
|
||||||
|
int oldOrder=curOrder;
|
||||||
|
while (curRow<goalRow) {
|
||||||
|
if (nextTick(preserveDrift)) break;
|
||||||
|
if (oldOrder!=curOrder) break;
|
||||||
|
}
|
||||||
for (int i=0; i<song.systemLen; i++) disCont[i].dispatch->setSkipRegisterWrites(false);
|
for (int i=0; i<song.systemLen; i++) disCont[i].dispatch->setSkipRegisterWrites(false);
|
||||||
if (goal>0) {
|
if (goal>0 || goalRow>0) {
|
||||||
for (int i=0; i<song.systemLen; i++) disCont[i].dispatch->forceIns();
|
for (int i=0; i<song.systemLen; i++) disCont[i].dispatch->forceIns();
|
||||||
}
|
}
|
||||||
repeatPattern=oldRepeatPattern;
|
repeatPattern=oldRepeatPattern;
|
||||||
|
@ -4815,6 +4820,13 @@ void DivEngine::play() {
|
||||||
isBusy.unlock();
|
isBusy.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DivEngine::playToRow(int row) {
|
||||||
|
isBusy.lock();
|
||||||
|
freelance=false;
|
||||||
|
playSub(false,row);
|
||||||
|
isBusy.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
void DivEngine::stop() {
|
void DivEngine::stop() {
|
||||||
isBusy.lock();
|
isBusy.lock();
|
||||||
freelance=false;
|
freelance=false;
|
||||||
|
|
|
@ -206,7 +206,7 @@ class DivEngine {
|
||||||
void recalcChans();
|
void recalcChans();
|
||||||
void renderSamples();
|
void renderSamples();
|
||||||
void reset();
|
void reset();
|
||||||
void playSub(bool preserveDrift);
|
void playSub(bool preserveDrift, int goalRow=0);
|
||||||
|
|
||||||
bool loadDMF(unsigned char* file, size_t len);
|
bool loadDMF(unsigned char* file, size_t len);
|
||||||
bool loadFur(unsigned char* file, size_t len);
|
bool loadFur(unsigned char* file, size_t len);
|
||||||
|
@ -285,6 +285,9 @@ class DivEngine {
|
||||||
// play
|
// play
|
||||||
void play();
|
void play();
|
||||||
|
|
||||||
|
// play to row
|
||||||
|
void playToRow(int row);
|
||||||
|
|
||||||
// stop
|
// stop
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
|
|
|
@ -4630,9 +4630,13 @@ void FurnaceGUI::doRedo() {
|
||||||
redoHist.pop_back();
|
redoHist.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FurnaceGUI::play() {
|
void FurnaceGUI::play(int row) {
|
||||||
e->walkSong(loopOrder,loopRow,loopEnd);
|
e->walkSong(loopOrder,loopRow,loopEnd);
|
||||||
e->play();
|
if (row>0) {
|
||||||
|
e->playToRow(row);
|
||||||
|
} else {
|
||||||
|
e->play();
|
||||||
|
}
|
||||||
curNibble=false;
|
curNibble=false;
|
||||||
orderNibble=false;
|
orderNibble=false;
|
||||||
activeNotes.clear();
|
activeNotes.clear();
|
||||||
|
@ -4726,7 +4730,9 @@ void FurnaceGUI::keyDown(SDL_Event& ev) {
|
||||||
play();
|
play();
|
||||||
break;
|
break;
|
||||||
case SDLK_F7:
|
case SDLK_F7:
|
||||||
play();
|
if (!e->isPlaying()) {
|
||||||
|
play(cursor.y);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SDLK_F8:
|
case SDLK_F8:
|
||||||
stop();
|
stop();
|
||||||
|
@ -4755,7 +4761,11 @@ void FurnaceGUI::keyDown(SDL_Event& ev) {
|
||||||
if (e->isPlaying()) {
|
if (e->isPlaying()) {
|
||||||
stop();
|
stop();
|
||||||
} else {
|
} else {
|
||||||
play();
|
if (ev.key.keysym.mod&KMOD_SHIFT) {
|
||||||
|
play(cursor.y);
|
||||||
|
} else {
|
||||||
|
play();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -383,7 +383,7 @@ class FurnaceGUI {
|
||||||
void doUndo();
|
void doUndo();
|
||||||
void doRedo();
|
void doRedo();
|
||||||
|
|
||||||
void play();
|
void play(int row=0);
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
void previewNote(int refChan, int note);
|
void previewNote(int refChan, int note);
|
||||||
|
|
Loading…
Reference in a new issue