Skip to content

Commit 1fcbbbf

Browse files
committed
ectocore: bipolar amen (<0 trigs on time, >0 trigs on voltage change)
Fixes #657
1 parent 30dedcd commit 1fcbbbf

File tree

2 files changed

+36
-14
lines changed

2 files changed

+36
-14
lines changed

lib/ectocore.h

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,8 @@ void input_handling() {
580580
mute_soft = true;
581581
#endif
582582

583+
int cv_amen_last_value = 0;
584+
583585
while (1) {
584586
#ifdef INCLUDE_MIDI
585587
tud_task();
@@ -769,19 +771,39 @@ void input_handling() {
769771
val -= 512;
770772
}
771773
}
772-
cv_beat_current_override = linlin(val, -512, 512,
773-
cv_start *
774-
banks[sel_bank_cur]
775-
->sample[sel_sample_cur]
776-
.snd[FILEZERO]
777-
->slice_num /
778-
1000,
779-
cv_stop *
780-
banks[sel_bank_cur]
781-
->sample[sel_sample_cur]
782-
.snd[FILEZERO]
783-
->slice_num /
784-
1000);
774+
if (val >= 0) {
775+
if (cv_amen_last_value - val > 3 || val - cv_amen_last_value > 3) {
776+
printf("CV_AMEN val: %d\n", val);
777+
cv_amen_last_value = val;
778+
cv_beat_current_override = linlin(val, 0, 512,
779+
cv_start *
780+
banks[sel_bank_cur]
781+
->sample[sel_sample_cur]
782+
.snd[FILEZERO]
783+
->slice_num /
784+
1000,
785+
cv_stop *
786+
banks[sel_bank_cur]
787+
->sample[sel_sample_cur]
788+
.snd[FILEZERO]
789+
->slice_num /
790+
1000);
791+
}
792+
} else {
793+
cv_beat_current_override = linlin(val, -512, 0,
794+
cv_start *
795+
banks[sel_bank_cur]
796+
->sample[sel_sample_cur]
797+
.snd[FILEZERO]
798+
->slice_num /
799+
1000,
800+
cv_stop *
801+
banks[sel_bank_cur]
802+
->sample[sel_sample_cur]
803+
.snd[FILEZERO]
804+
->slice_num /
805+
1000);
806+
}
785807

786808
} else if (i == CV_BREAK) {
787809
// printf("[ectocore] cv_break %d\n", val);

main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ bool repeating_timer_callback(struct repeating_timer *t) {
512512
if (cv_beat_current_override > 0) {
513513
beat_current = cv_beat_current_override;
514514
cv_beat_current_override = -1;
515-
printf("[main] cv_beat_current_override: %d\n", beat_current);
515+
// printf("[main] cv_beat_current_override: %d\n", beat_current);
516516
}
517517
#endif
518518
// printf("beat_current: %d\n", beat_current);

0 commit comments

Comments
 (0)