Add per-channel Swing configuration (#7)
Select swing amount from a percentage range of the beat starting a 50% (unchanged) to a max swing amount of 95% (about 1/32nd note before end of period). Swing percentage shows an indicator marker when the percentage lines up with a quantized note on the grid. This is probably going to be the last feature because it is pushing up against the limits of available dynamic memory. Out of scope changes: - selecting parameters / values no longer wraps - reduce dynamic memory used in processClockTick - various readability formatting Reviewed-on: https://git.pinkduck.xyz/adam/libGravity/pulls/7 Co-authored-by: Adam Wonak <adam.wonak@gmail.com> Co-committed-by: Adam Wonak <adam.wonak@gmail.com>
This commit is contained in:
@ -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) {
|
||||
}
|
||||
}
|
||||
|
||||
// Display an indicator when swing percentage matches a musical note.
|
||||
void swingDivisionMark() {
|
||||
auto& ch = GetSelectedChannel();
|
||||
switch (ch.getSwing()) {
|
||||
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,6 +262,13 @@ void DisplayChannelPage() {
|
||||
sprintf(mainText, "%d%%", ch.getOffset(withCvMod));
|
||||
subText = "SHIFT HIT";
|
||||
break;
|
||||
case PARAM_CH_SWING:
|
||||
ch.getSwing() == 50
|
||||
? sprintf(mainText, "OFF")
|
||||
: sprintf(mainText, "%d%%", ch.getSwing(withCvMod));
|
||||
subText = "DOWN BEAT";
|
||||
swingDivisionMark();
|
||||
break;
|
||||
case PARAM_CH_CV_SRC: {
|
||||
switch (ch.getCvSource()) {
|
||||
case CV_NONE:
|
||||
@ -283,6 +308,10 @@ void DisplayChannelPage() {
|
||||
sprintf(mainText, "DEST");
|
||||
subText = "OFFSET";
|
||||
break;
|
||||
case CV_DEST_SWING:
|
||||
sprintf(mainText, "DEST");
|
||||
subText = "SWING";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -293,7 +322,7 @@ void DisplayChannelPage() {
|
||||
|
||||
// Draw Channel Page menu items
|
||||
const char* menu_items[PARAM_CH_LAST] = {
|
||||
"MOD", "PROBABILITY", "DUTY", "OFFSET", "CV SOURCE", "CV DEST"};
|
||||
"MOD", "PROBABILITY", "DUTY", "OFFSET", "SWING", "CV SOURCE", "CV DEST"};
|
||||
drawMenuItems(menu_items, PARAM_CH_LAST);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user