Fix swing offset, update additional var names from shuffle to swing.

This commit is contained in:
2025-06-21 21:33:51 -07:00
parent d39954d6c5
commit afcda2d911
2 changed files with 19 additions and 18 deletions

View File

@ -40,7 +40,7 @@ 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; base_swing = 50;
cv_source = CV_NONE; cv_source = CV_NONE;
cv_destination = CV_DEST_NONE; cv_destination = CV_DEST_NONE;
@ -48,7 +48,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; cvmod_swing = base_swing;
} }
// Setters (Set the BASE value) // Setters (Set the BASE value)
@ -58,8 +58,8 @@ class Channel {
} }
void setProbability(int prob) { base_probability = constrain(prob, 0, 100); } void setProbability(int prob) { base_probability = constrain(prob, 0, 100); }
void setDutyCycle(int duty) { base_duty_cycle = constrain(duty, 1, 99); } void setDutyCycle(int duty) { base_duty_cycle = constrain(duty, 1, 99); }
void setOffset(int off) { base_offset = constrain(off, 0, 100); } void setOffset(int off) { base_offset = constrain(off, 0, 99); }
void setSwing(int val) { base_shuffle = constrain(val, 0, 50); } void setSwing(int val) { base_swing = constrain(val, 50, 95); }
void setCvSource(CvSource source) { cv_source = source; } void setCvSource(CvSource source) { cv_source = source; }
void setCvDestination(CvDestination dest) { cv_destination = dest; } void setCvDestination(CvDestination dest) { cv_destination = dest; }
@ -68,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 getSwing(bool withCvMod = false) const { return withCvMod ? cvmod_shuffle : base_shuffle; } int getSwing(bool withCvMod = false) const { return withCvMod ? cvmod_swing : base_swing; }
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; }
@ -86,13 +86,14 @@ class Channel {
const uint32_t duty_pulses = max((long)((mod_pulses * (100L - cvmod_duty_cycle)) / 100L), 1L); const uint32_t duty_pulses = max((long)((mod_pulses * (100L - cvmod_duty_cycle)) / 100L), 1L);
const uint32_t offset_pulses = (long)((mod_pulses * (100L - cvmod_offset)) / 100L); const uint32_t offset_pulses = (long)((mod_pulses * (100L - cvmod_offset)) / 100L);
uint32_t shuffle_pulses = 0; uint32_t swing_pulses = 0;
// Check step increment for odd beats. // Check step increment for odd beats.
if ((tick / mod_pulses) % 2 == 1) { if (cvmod_swing > 50 && (tick / mod_pulses) % 2 == 1) {
shuffle_pulses = (long)((mod_pulses * (100L - cvmod_shuffle)) / 100L); int shifted_swing = cvmod_swing - 50;
swing_pulses = (long)((mod_pulses * (100L - shifted_swing)) / 100L);
} }
const uint32_t current_tick_offset = tick + offset_pulses + shuffle_pulses; const uint32_t current_tick_offset = tick + offset_pulses + swing_pulses;
// Step check // Step check
if (!output.On()) { if (!output.On()) {
@ -118,7 +119,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; cvmod_swing = base_swing;
return; return;
} }
@ -144,9 +145,9 @@ class Channel {
? 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_SWING) cvmod_swing = (cv_destination == CV_DEST_SWING)
? constrain(base_shuffle + map(value, -512, 512, -25, 25), 0, 50) ? constrain(base_swing + map(value, -512, 512, -25, 25), 50, 95)
: base_shuffle; : base_swing;
} }
private: private:
@ -155,14 +156,14 @@ class Channel {
byte base_probability; byte base_probability;
byte base_duty_cycle; byte base_duty_cycle;
byte base_offset; byte base_offset;
byte base_shuffle; byte base_swing;
// Base value with cv mod applied. // Base value with cv mod applied.
byte cvmod_clock_mod_index; byte cvmod_clock_mod_index;
byte cvmod_probability; byte cvmod_probability;
byte cvmod_duty_cycle; byte cvmod_duty_cycle;
byte cvmod_offset; byte cvmod_offset;
byte cvmod_shuffle; byte cvmod_swing;
// CV configuration // CV configuration
CvSource cv_source = CV_NONE; CvSource cv_source = CV_NONE;

View File

@ -149,7 +149,7 @@ void drawMenuItems(const char* menu_items[], int menu_size) {
void swingDivisionMark() { void swingDivisionMark() {
auto& ch = GetSelectedChannel(); auto& ch = GetSelectedChannel();
switch (ch.getSwing() + 50) { switch (ch.getSwing()) {
case 58: // 1/32nd case 58: // 1/32nd
case 66: // 1/16th case 66: // 1/16th
case 75: // 1/8th case 75: // 1/8th
@ -263,9 +263,9 @@ void DisplayChannelPage() {
subText = "SHIFT HIT"; subText = "SHIFT HIT";
break; break;
case PARAM_CH_SWING: case PARAM_CH_SWING:
ch.getSwing() == 0 ch.getSwing() == 50
? sprintf(mainText, "OFF") ? sprintf(mainText, "OFF")
: sprintf(mainText, "%d%%", ch.getSwing(withCvMod) + 50); : sprintf(mainText, "%d%%", ch.getSwing(withCvMod));
subText = "DOWN BEAT"; subText = "DOWN BEAT";
swingDivisionMark(); swingDivisionMark();
break; break;