diff --git a/src/state.c b/src/state.c index 43d5df7..2d43b2b 100644 --- a/src/state.c +++ b/src/state.c @@ -287,6 +287,7 @@ bool state_background_midi_write(SharedContext *context, update_values(context, state_config, midi); last_active = false; + last_change = false; while (!context->stop) { beat_active = tempo_progress(context->tempo, 1.0) < 0.25; diff --git a/src/tempo.c b/src/tempo.c index ba9e3bb..5515cff 100644 --- a/src/tempo.c +++ b/src/tempo.c @@ -36,13 +36,13 @@ Tempo tempo_init() { } static bool is_chain_active(Tempo tempo, long t) { - return tempo.last_tap + MAX_BEAT_LENGTH > t && - tempo.last_tap + (tempo.beat_length * BEATS_UNTIL_CHAIN_RESET) > t; + return (tempo.last_tap + MAX_BEAT_LENGTH) > t && + (tempo.last_tap + (tempo.beat_length * BEATS_UNTIL_CHAIN_RESET)) > t; } -static unsigned long get_average_tap_duration(Tempo tempo) { +static long get_average_tap_duration(Tempo tempo) { unsigned int amount, i; - unsigned long running_total, average_tap_duration; + long running_total, average_tap_duration; amount = tempo.taps_in_chain - 1; if (amount > TOTAL_TAP_VALUES) { diff --git a/src/types.h b/src/types.h index fc089f3..4fe61d7 100644 --- a/src/types.h +++ b/src/types.h @@ -136,7 +136,7 @@ typedef struct Tempo { unsigned int tap_duration_index; unsigned int tap_durations[MAX_TAP_VALUES]; bool last_tap_skipped; - unsigned long beat_length; + long beat_length; float tempo; } Tempo;