Add per-channel Swing configuration #7

Merged
awonak merged 9 commits from refs/pull/7/head into main 2025-06-22 18:38:51 +00:00
6 changed files with 46 additions and 7 deletions
Showing only changes of commit 0452006e67 - Show all commits

View File

@ -18,6 +18,7 @@ enum CvDestination {
CV_DEST_PROB, CV_DEST_PROB,
CV_DEST_DUTY, CV_DEST_DUTY,
CV_DEST_OFFSET, CV_DEST_OFFSET,
CV_DEST_SHUFFLE,
CV_DEST_LAST, CV_DEST_LAST,
}; };
@ -39,14 +40,15 @@ class Channel {
base_probability = 100; base_probability = 100;
base_duty_cycle = 50; base_duty_cycle = 50;
base_offset = 0; base_offset = 0;
base_shuffle = 0;
cv_source = CV_NONE; cv_source = CV_NONE;
cv_destination = CV_DEST_NONE; cv_destination = CV_DEST_NONE;
base_shuffle = 0;
cvmod_clock_mod_index = base_clock_mod_index; cvmod_clock_mod_index = base_clock_mod_index;
cvmod_probability = base_probability; cvmod_probability = base_probability;
cvmod_duty_cycle = base_duty_cycle; cvmod_duty_cycle = base_duty_cycle;
cvmod_offset = base_offset; cvmod_offset = base_offset;
cvmod_shuffle = base_shuffle;
} }
// Setters (Set the BASE value) // Setters (Set the BASE value)
@ -66,7 +68,7 @@ class Channel {
int getProbability(bool withCvMod = false) const { return withCvMod ? cvmod_probability : base_probability; } int getProbability(bool withCvMod = false) const { return withCvMod ? cvmod_probability : base_probability; }
int getDutyCycle(bool withCvMod = false) const { return withCvMod ? cvmod_duty_cycle : base_duty_cycle; } int getDutyCycle(bool withCvMod = false) const { return withCvMod ? cvmod_duty_cycle : base_duty_cycle; }
int getOffset(bool withCvMod = false) const { return withCvMod ? cvmod_offset : base_offset; } int getOffset(bool withCvMod = false) const { return withCvMod ? cvmod_offset : base_offset; }
int getShuffle() const { return base_shuffle; } int getShuffle(bool withCvMod = false) const { return withCvMod ? cvmod_shuffle : base_shuffle; }
int getClockMod(bool withCvMod = false) const { return clock_mod[getClockModIndex(withCvMod)]; } int getClockMod(bool withCvMod = false) const { return clock_mod[getClockModIndex(withCvMod)]; }
int getClockModIndex(bool withCvMod = false) const { return withCvMod ? cvmod_clock_mod_index : base_clock_mod_index; } int getClockModIndex(bool withCvMod = false) const { return withCvMod ? cvmod_clock_mod_index : base_clock_mod_index; }
CvSource getCvSource() { return cv_source; } CvSource getCvSource() { return cv_source; }
@ -87,7 +89,7 @@ class Channel {
uint32_t shuffle_pulses = 0; uint32_t shuffle_pulses = 0;
// Check step increment for odd beats. // Check step increment for odd beats.
if ((tick / mod_pulses) % 2 == 1) { if ((tick / mod_pulses) % 2 == 1) {
shuffle_pulses = (long)((mod_pulses * (100L - base_shuffle)) / 100L); shuffle_pulses = (long)((mod_pulses * (100L - cvmod_shuffle)) / 100L);
} }
const uint32_t current_tick_offset = tick + offset_pulses + shuffle_pulses; const uint32_t current_tick_offset = tick + offset_pulses + shuffle_pulses;
@ -116,6 +118,7 @@ class Channel {
cvmod_probability = base_probability; cvmod_probability = base_probability;
cvmod_duty_cycle = base_duty_cycle; cvmod_duty_cycle = base_duty_cycle;
cvmod_offset = base_offset; cvmod_offset = base_offset;
cvmod_shuffle = base_shuffle;
return; return;
} }
@ -140,6 +143,10 @@ class Channel {
cvmod_offset = (cv_destination == CV_DEST_OFFSET) cvmod_offset = (cv_destination == CV_DEST_OFFSET)
? constrain(base_offset + map(value, -512, 512, -50, 50), 0, 99) ? constrain(base_offset + map(value, -512, 512, -50, 50), 0, 99)
: base_offset; : base_offset;
cvmod_shuffle = (cv_destination == CV_DEST_SHUFFLE)
? constrain(base_shuffle + map(value, -512, 512, -25, 25), 0, 50)
: base_shuffle;
} }
private: private:
@ -155,6 +162,7 @@ class Channel {
byte cvmod_probability; byte cvmod_probability;
byte cvmod_duty_cycle; byte cvmod_duty_cycle;
byte cvmod_offset; byte cvmod_offset;
byte cvmod_shuffle;
// CV configuration // CV configuration
CvSource cv_source = CV_NONE; CvSource cv_source = CV_NONE;

View File

@ -247,7 +247,7 @@ void DisplayChannelPage() {
case PARAM_CH_SHUFFLE: case PARAM_CH_SHUFFLE:
ch.getShuffle() == 0 ch.getShuffle() == 0
? sprintf(mainText, "OFF") ? sprintf(mainText, "OFF")
: sprintf(mainText, "%d%%", ch.getShuffle() + 50); : sprintf(mainText, "%d%%", ch.getShuffle(withCvMod) + 50);
subText = "SHUFFLE"; subText = "SHUFFLE";
break; break;
case PARAM_CH_CV_SRC: { case PARAM_CH_CV_SRC: {
@ -289,6 +289,10 @@ void DisplayChannelPage() {
sprintf(mainText, "DEST"); sprintf(mainText, "DEST");
subText = "OFFSET"; subText = "OFFSET";
break; break;
case CV_DEST_SHUFFLE:
sprintf(mainText, "DEST");
subText = "SHUFFLE";
break;
} }
break; break;
} }