Skip to content

Commit 8b6d979

Browse files
authored
Merge pull request #619 from schollz:schollz/issue618
ectocore: tap+mode is a reset to first beat
2 parents 67ee50d + baf538e commit 8b6d979

File tree

1 file changed

+37
-27
lines changed

1 file changed

+37
-27
lines changed

lib/ectocore.h

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -855,27 +855,7 @@ void input_handling() {
855855
clock_in_activator = 0;
856856
clock_in_do = false;
857857
} else if (!clock_input_absent) {
858-
// pressing clock while clock is active will reset to beat 1
859-
// after determining whether the press is closer to the last
860-
// clock or the next clock (i.e. we are either early or late)
861-
uint32_t next_time =
862-
clock_in_last_time + (clock_in_last_time - clock_in_last_last_time);
863-
uint32_t now_time = time_us_32();
864-
// ---|-----------|-----------|-------
865-
// --lastlast----last---NOW--next
866-
// determine if we are in the first half or the second half
867-
if (now_time > clock_in_last_time +
868-
(clock_in_last_time - clock_in_last_last_time) / 2) {
869-
// we are in the second half
870-
// the next clock is going to be the first beat
871-
// reset it to -1, so that when it increments it will be at 0
872-
clock_in_beat_total = -1;
873-
} else {
874-
// we are in the first half
875-
// the next clock is going to be the second beat
876-
// reset it to 0, so that when it increments it will be at 1
877-
clock_in_beat_total = 0;
878-
}
858+
// do nothing (this is handled in TAP+MODE now)
879859
} else {
880860
val = TapTempo_tap(taptempo);
881861
if (val > 0) {
@@ -1145,13 +1125,43 @@ void input_handling() {
11451125
set_audio_variant(audio_variant_num);
11461126
}
11471127
} else if (gpio_btn_state[BTN_TAPTEMPO] == 1) {
1148-
// A+B
11491128
if (val == 1) {
1150-
// reset tempo to the tempo of the current sample
1151-
int16_t new_tempo =
1152-
banks[sel_bank_cur]->sample[sel_sample_cur].snd[FILEZERO]->bpm;
1153-
if (new_tempo >= 60 && new_tempo <= 300) {
1154-
sf->bpm_tempo = new_tempo;
1129+
// TAP + MODE resets to original bpm if no clock is present
1130+
// otherwise it resets the pattern to beat 1
1131+
if (!clock_input_absent) {
1132+
printf("resetting pattern to beat 1\n");
1133+
// pressing clock while clock is active will reset to beat 1
1134+
// after determining whether the press is closer to the last
1135+
// clock or the next clock (i.e. we are either early or late)
1136+
uint32_t next_time =
1137+
clock_in_last_time +
1138+
(clock_in_last_time - clock_in_last_last_time);
1139+
uint32_t now_time = time_us_32();
1140+
// ---|-----------|-----------|-------
1141+
// --lastlast----last---NOW--next
1142+
// determine if we are in the first half or the second half
1143+
if (now_time >
1144+
clock_in_last_time +
1145+
(clock_in_last_time - clock_in_last_last_time) / 2) {
1146+
// we are in the second half
1147+
// the next clock is going to be the first beat
1148+
// reset it to -1, so that when it increments it will be at 0
1149+
clock_in_beat_total = -1;
1150+
} else {
1151+
// we are in the first half
1152+
// the next clock is going to be the second beat
1153+
// reset it to 0, so that when it increments it will be at 1
1154+
clock_in_beat_total = 0;
1155+
}
1156+
} else {
1157+
// reset tempo to the tempo of the current sample
1158+
int16_t new_tempo = banks[sel_bank_cur]
1159+
->sample[sel_sample_cur]
1160+
.snd[FILEZERO]
1161+
->bpm;
1162+
if (new_tempo >= 60 && new_tempo <= 300) {
1163+
sf->bpm_tempo = new_tempo;
1164+
}
11551165
}
11561166
}
11571167
} else {

0 commit comments

Comments
 (0)