From d39954d6c532677d36b3abe1a6c03f55f7bd5e9c Mon Sep 17 00:00:00 2001 From: Adam Wonak Date: Sat, 21 Jun 2025 16:44:28 -0700 Subject: [PATCH] Rename from shuffle to swing. Add indicator for aligning swing hits with notes. --- examples/Gravity/Gravity.ino | 4 +-- examples/Gravity/app_state.h | 2 +- examples/Gravity/channel.h | 8 +++--- examples/Gravity/display.h | 43 ++++++++++++++++++++++++--------- examples/Gravity/save_state.cpp | 4 +-- 5 files changed, 40 insertions(+), 21 deletions(-) diff --git a/examples/Gravity/Gravity.ino b/examples/Gravity/Gravity.ino index d49592e..adb4b54 100644 --- a/examples/Gravity/Gravity.ino +++ b/examples/Gravity/Gravity.ino @@ -210,8 +210,8 @@ void editChannelParameter(int val) { case PARAM_CH_OFFSET: ch.setOffset(ch.getOffset() + val); break; - case PARAM_CH_SHUFFLE: - ch.setShuffle(ch.getShuffle() + val); + case PARAM_CH_SWING: + ch.setSwing(ch.getSwing() + val); break; case PARAM_CH_CV_SRC: { int source = static_cast(ch.getCvSource()); diff --git a/examples/Gravity/app_state.h b/examples/Gravity/app_state.h index f7f2d96..06cec2a 100644 --- a/examples/Gravity/app_state.h +++ b/examples/Gravity/app_state.h @@ -38,7 +38,7 @@ enum ParamsChannelPage { PARAM_CH_PROB, PARAM_CH_DUTY, PARAM_CH_OFFSET, - PARAM_CH_SHUFFLE, + PARAM_CH_SWING, PARAM_CH_CV_SRC, PARAM_CH_CV_DEST, PARAM_CH_LAST, diff --git a/examples/Gravity/channel.h b/examples/Gravity/channel.h index d737995..bd42a28 100644 --- a/examples/Gravity/channel.h +++ b/examples/Gravity/channel.h @@ -18,7 +18,7 @@ enum CvDestination { CV_DEST_PROB, CV_DEST_DUTY, CV_DEST_OFFSET, - CV_DEST_SHUFFLE, + CV_DEST_SWING, CV_DEST_LAST, }; @@ -59,7 +59,7 @@ class Channel { void setProbability(int prob) { base_probability = constrain(prob, 0, 100); } void setDutyCycle(int duty) { base_duty_cycle = constrain(duty, 1, 99); } void setOffset(int off) { base_offset = constrain(off, 0, 100); } - void setShuffle(int val) { base_shuffle = constrain(val, 0, 50); } + void setSwing(int val) { base_shuffle = constrain(val, 0, 50); } void setCvSource(CvSource source) { cv_source = source; } 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 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 getShuffle(bool withCvMod = false) const { return withCvMod ? cvmod_shuffle : base_shuffle; } + int getSwing(bool withCvMod = false) const { return withCvMod ? cvmod_shuffle : base_shuffle; } 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; } CvSource getCvSource() { return cv_source; } @@ -144,7 +144,7 @@ class Channel { ? constrain(base_offset + map(value, -512, 512, -50, 50), 0, 99) : base_offset; - cvmod_shuffle = (cv_destination == CV_DEST_SHUFFLE) + cvmod_shuffle = (cv_destination == CV_DEST_SWING) ? constrain(base_shuffle + map(value, -512, 512, -25, 25), 0, 50) : base_shuffle; } diff --git a/examples/Gravity/display.h b/examples/Gravity/display.h index 006915c..c46ce4a 100644 --- a/examples/Gravity/display.h +++ b/examples/Gravity/display.h @@ -96,16 +96,16 @@ void drawRightAlignedText(const char* text, int y) { void drawSelectHero() { gravity.display.setDrawColor(1); const int tickSize = 3; - const int heroWidth = SCREEN_WIDTH/2; + const int heroWidth = SCREEN_WIDTH / 2; const int heroHeight = 49; gravity.display.drawLine(0, 0, tickSize, 0); gravity.display.drawLine(0, 0, 0, tickSize); - gravity.display.drawLine(heroWidth, 0, heroWidth-tickSize, 0); + gravity.display.drawLine(heroWidth, 0, heroWidth - tickSize, 0); gravity.display.drawLine(heroWidth, 0, heroWidth, tickSize); - gravity.display.drawLine(heroWidth, heroHeight, heroWidth, heroHeight-tickSize); - gravity.display.drawLine(heroWidth, heroHeight, heroWidth-tickSize, heroHeight); + gravity.display.drawLine(heroWidth, heroHeight, heroWidth, heroHeight - tickSize); + gravity.display.drawLine(heroWidth, heroHeight, heroWidth - tickSize, heroHeight); gravity.display.drawLine(0, heroHeight, tickSize, heroHeight); - gravity.display.drawLine(0, heroHeight, 0, heroHeight-tickSize); + gravity.display.drawLine(0, heroHeight, 0, heroHeight - tickSize); gravity.display.setDrawColor(2); } @@ -147,6 +147,24 @@ void drawMenuItems(const char* menu_items[], int menu_size) { } } +void swingDivisionMark() { + auto& ch = GetSelectedChannel(); + switch (ch.getSwing() + 50) { + case 58: // 1/32nd + case 66: // 1/16th + case 75: // 1/8th + gravity.display.drawBox(56, 4, 4, 4); + break; + case 54: // 1/32nd tripplet + case 62: // 1/16th tripplet + case 71: // 1/8th tripplet + gravity.display.drawBox(56, 4, 4, 4); + gravity.display.drawBox(57, 5, 2, 2); + break; + + } +} + // Main display functions void DisplayMainPage() { @@ -244,11 +262,12 @@ void DisplayChannelPage() { sprintf(mainText, "%d%%", ch.getOffset(withCvMod)); subText = "SHIFT HIT"; break; - case PARAM_CH_SHUFFLE: - ch.getShuffle() == 0 + case PARAM_CH_SWING: + ch.getSwing() == 0 ? sprintf(mainText, "OFF") - : sprintf(mainText, "%d%%", ch.getShuffle(withCvMod) + 50); - subText = "SHUFFLE"; + : sprintf(mainText, "%d%%", ch.getSwing(withCvMod) + 50); + subText = "DOWN BEAT"; + swingDivisionMark(); break; case PARAM_CH_CV_SRC: { switch (ch.getCvSource()) { @@ -289,9 +308,9 @@ void DisplayChannelPage() { sprintf(mainText, "DEST"); subText = "OFFSET"; break; - case CV_DEST_SHUFFLE: + case CV_DEST_SWING: sprintf(mainText, "DEST"); - subText = "SHUFFLE"; + subText = "SWING"; break; } break; @@ -303,7 +322,7 @@ void DisplayChannelPage() { // Draw Channel Page menu items const char* menu_items[PARAM_CH_LAST] = { - "MOD", "PROBABILITY", "DUTY", "OFFSET", "SHUFFLE", "CV SOURCE", "CV DEST"}; + "MOD", "PROBABILITY", "DUTY", "OFFSET", "SWING", "CV SOURCE", "CV DEST"}; drawMenuItems(menu_items, PARAM_CH_LAST); } diff --git a/examples/Gravity/save_state.cpp b/examples/Gravity/save_state.cpp index ee39dc3..f7529ed 100644 --- a/examples/Gravity/save_state.cpp +++ b/examples/Gravity/save_state.cpp @@ -27,7 +27,7 @@ bool StateManager::initialize(AppState& app) { ch.setProbability(saved_ch_state.base_probability); ch.setDutyCycle(saved_ch_state.base_duty_cycle); ch.setOffset(saved_ch_state.base_offset); - ch.setShuffle(saved_ch_state.base_shuffle); + ch.setSwing(saved_ch_state.base_shuffle); ch.setCvSource(static_cast(saved_ch_state.cv_source)); ch.setCvDestination(static_cast(saved_ch_state.cv_destination)); } @@ -106,7 +106,7 @@ void StateManager::_saveState(const AppState& app) { save_ch.base_probability = ch.getProbability(false); save_ch.base_duty_cycle = ch.getDutyCycle(false); save_ch.base_offset = ch.getOffset(false); - save_ch.base_shuffle = ch.getShuffle(); + save_ch.base_shuffle = ch.getSwing(); save_ch.cv_source = static_cast(ch.getCvSource()); save_ch.cv_destination = static_cast(ch.getCvDestination()); }