add ability to play by one row

This commit is contained in:
tildearrow 2022-02-06 00:42:07 -05:00
parent 107187a20c
commit 8772439d3e
4 changed files with 52 additions and 5 deletions

View file

@ -4756,6 +4756,7 @@ void DivEngine::playSub(bool preserveDrift, int goalRow) {
int goal=curOrder; int goal=curOrder;
curOrder=0; curOrder=0;
curRow=0; curRow=0;
stepPlay=0;
int prevDrift; int prevDrift;
prevDrift=clockDrift; prevDrift=clockDrift;
clockDrift=0; clockDrift=0;
@ -4815,8 +4816,12 @@ int DivEngine::calcFreq(int base, int pitch, bool period, int octave) {
void DivEngine::play() { void DivEngine::play() {
isBusy.lock(); isBusy.lock();
freelance=false; if (stepPlay==0) {
playSub(false); freelance=false;
playSub(false);
} else {
stepPlay=0;
}
isBusy.unlock(); isBusy.unlock();
} }
@ -4827,11 +4832,23 @@ void DivEngine::playToRow(int row) {
isBusy.unlock(); isBusy.unlock();
} }
void DivEngine::stepOne(int row) {
isBusy.lock();
if (!isPlaying()) {
freelance=false;
playSub(false,row);
}
stepPlay=2;
ticks=1;
isBusy.unlock();
}
void DivEngine::stop() { void DivEngine::stop() {
isBusy.lock(); isBusy.lock();
freelance=false; freelance=false;
playing=false; playing=false;
extValuePresent=false; extValuePresent=false;
stepPlay=0;
remainingLoops=-1; remainingLoops=-1;
isBusy.unlock(); isBusy.unlock();
} }
@ -5086,6 +5103,10 @@ bool DivEngine::isPlaying() {
return (playing && !freelance); return (playing && !freelance);
} }
bool DivEngine::isStepping() {
return !(stepPlay==0);
}
bool DivEngine::isChannelMuted(int chan) { bool DivEngine::isChannelMuted(int chan) {
return isMuted[chan]; return isMuted[chan];
} }

View file

@ -150,7 +150,7 @@ class DivEngine {
bool halted; bool halted;
bool forceMono; bool forceMono;
int ticks, curRow, curOrder, remainingLoops, nextSpeed, divider; int ticks, curRow, curOrder, remainingLoops, nextSpeed, divider;
int cycles, clockDrift; int cycles, clockDrift, 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;
unsigned char speed1, speed2; unsigned char speed1, speed2;
@ -288,6 +288,9 @@ class DivEngine {
// play to row // play to row
void playToRow(int row); void playToRow(int row);
// play by one row
void stepOne(int row);
// stop // stop
void stop(); void stop();
@ -406,6 +409,9 @@ class DivEngine {
// is playing // is playing
bool isPlaying(); bool isPlaying();
// is stepping
bool isStepping();
// is exporting // is exporting
bool isExporting(); bool isExporting();
@ -587,6 +593,7 @@ class DivEngine {
divider(60), divider(60),
cycles(0), cycles(0),
clockDrift(0), clockDrift(0),
stepPlay(0),
changeOrd(-1), changeOrd(-1),
changePos(0), changePos(0),
totalSeconds(0), totalSeconds(0),

View file

@ -844,7 +844,7 @@ bool DivEngine::nextTick(bool noAccum) {
} }
if (!freelance) { if (!freelance) {
if (--ticks<=0) { if (stepPlay!=1) if (--ticks<=0) {
ret=endOfSong; ret=endOfSong;
if (endOfSong) { if (endOfSong) {
if (song.loopModality!=2) { if (song.loopModality!=2) {
@ -852,6 +852,7 @@ bool DivEngine::nextTick(bool noAccum) {
} }
} }
endOfSong=false; endOfSong=false;
if (stepPlay==2) stepPlay=1;
nextRow(); nextRow();
} }
// process stuff // process stuff

View file

@ -645,6 +645,10 @@ void FurnaceGUI::drawEditControls() {
if (ImGui::Checkbox("Repeat pattern",&repeatPattern)) { if (ImGui::Checkbox("Repeat pattern",&repeatPattern)) {
e->setRepeatPattern(repeatPattern); e->setRepeatPattern(repeatPattern);
} }
ImGui::SameLine();
if (ImGui::Button(ICON_FA_ARROW_DOWN "##StepOne")) {
e->stepOne(cursor.y);
}
} }
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_EDIT_CONTROLS; if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_EDIT_CONTROLS;
ImGui::End(); ImGui::End();
@ -658,6 +662,10 @@ void FurnaceGUI::drawEditControls() {
if (ImGui::Button(ICON_FA_PLAY "##Play")) { if (ImGui::Button(ICON_FA_PLAY "##Play")) {
play(); play();
} }
ImGui::SameLine();
if (ImGui::Button(ICON_FA_ARROW_DOWN "##StepOne")) {
e->stepOne(cursor.y);
}
ImGui::SameLine(); ImGui::SameLine();
bool repeatPattern=e->getRepeatPattern(); bool repeatPattern=e->getRepeatPattern();
@ -722,6 +730,9 @@ void FurnaceGUI::drawEditControls() {
if (ImGui::Button(ICON_FA_STOP "##Stop")) { if (ImGui::Button(ICON_FA_STOP "##Stop")) {
stop(); stop();
} }
if (ImGui::Button(ICON_FA_ARROW_DOWN "##StepOne")) {
e->stepOne(cursor.y);
}
bool repeatPattern=e->getRepeatPattern(); bool repeatPattern=e->getRepeatPattern();
ImGui::PushStyleColor(ImGuiCol_Button,ImVec4(0.2f,(repeatPattern)?0.6f:0.2f,0.2f,1.0f)); ImGui::PushStyleColor(ImGuiCol_Button,ImVec4(0.2f,(repeatPattern)?0.6f:0.2f,0.2f,1.0f));
@ -792,6 +803,10 @@ void FurnaceGUI::drawEditControls() {
if (ImGui::Button(ICON_FA_PLAY_CIRCLE "##PlayAgain")) { if (ImGui::Button(ICON_FA_PLAY_CIRCLE "##PlayAgain")) {
play(); play();
} }
ImGui::SameLine();
if (ImGui::Button(ICON_FA_ARROW_DOWN "##StepOne")) {
e->stepOne(cursor.y);
}
ImGui::SameLine(); ImGui::SameLine();
ImGui::PushStyleColor(ImGuiCol_Button,ImVec4(0.2f,(edit)?0.6f:0.2f,0.2f,1.0f)); ImGui::PushStyleColor(ImGuiCol_Button,ImVec4(0.2f,(edit)?0.6f:0.2f,0.2f,1.0f));
@ -4719,6 +4734,9 @@ void FurnaceGUI::keyDown(SDL_Event& ev) {
doUndo(); doUndo();
} }
break; break;
case SDLK_RETURN:
e->stepOne(cursor.y);
break;
} }
} else switch (ev.key.keysym.sym) { } else switch (ev.key.keysym.sym) {
case SDLK_F5: case SDLK_F5:
@ -4758,7 +4776,7 @@ void FurnaceGUI::keyDown(SDL_Event& ev) {
} }
break; break;
case SDLK_RETURN: case SDLK_RETURN:
if (e->isPlaying()) { if (e->isPlaying() && !e->isStepping()) {
stop(); stop();
} else { } else {
if (ev.key.keysym.mod&KMOD_SHIFT) { if (ev.key.keysym.mod&KMOD_SHIFT) {