Skip to content

Commit

Permalink
Merge pull request #12 from charasyn/fix-state-bug
Browse files Browse the repository at this point in the history
Fix state bug with empty tracks
  • Loading branch information
ChrisBlueStone authored Jan 10, 2022
2 parents a0b5a20 + 48d00df commit 27d8145
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/tracker.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,16 @@ static void goto_order(int pos) {
int i;
initialize_state();
for (i = 0; i < pos; i++) {
int ch;
for (ch = 0; ch < 8 && state.chan[ch].ptr != NULL; ch++)
// an empty pattern will loop forever, so skip it
if (ch != 8) {
while (do_cycle_no_sound(&state));
// If there are any non-null tracks in this pattern, then
// we want to step through the whole pattern once by calling
// `do_cycle_no_sound` until it returns false.
for (int ch = 0; ch < 8; ch++) {
if (state.chan[ch].ptr != NULL) {
// We've found a non-null track. Simulate the current pattern.
while (do_cycle_no_sound(&state));
// We're done with the current pattern. Move on to the next one.
break;
}
}
load_pattern();
}
Expand Down

0 comments on commit 27d8145

Please sign in to comment.