Song progression

This commit is contained in:
Dejvino
2026-03-07 21:27:08 +01:00
parent bbe6c4ff2f
commit 99add4e2ac
8 changed files with 268 additions and 68 deletions
+62 -15
View File
@@ -72,9 +72,34 @@ void UIManager::draw(UIState currentState, int menuSelection,
case UI_EDIT_ROOT:
{
const char* noteNames[] = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"};
drawEditScreen("SET ROOT NOTE", "", noteNames[currentRoot % 12]);
drawEditScreen("SET KEY", "", noteNames[globalRoot % 12]);
}
break;
case UI_EDIT_PROG_ORDER:
drawEditScreen("PROG ORDER", "", (progressionOrder == PROG_ORDER_SEQUENCE) ? "Sequence" : "Random");
break;
case UI_EDIT_PROG_TEMPLATE:
drawEditScreen("APPLY TEMPLATE", "", progressions[templateSelectionIndex].name);
break;
case UI_EDIT_PROG_LENGTH:
drawEditScreen("PROG LENGTH", "Steps: ", currentProgression.length);
break;
case UI_EDIT_PROG_STEP_ROOT:
drawEditScreen("STEP MODULATION", "Semi: ", currentProgression.steps[stepEditIndex/3].rootOffset);
break;
case UI_EDIT_PROG_STEP_TYPE:
{
const char* typeNames[] = {"Chrom", "Major", "Minor", "H.Min", "P.Maj", "P.Min", "ChdMaj", "ChdMin", "ChdDim", "Chd7"};
int type = currentProgression.steps[stepEditIndex/3].scaleType;
if (type >= 0 && type < 10)
drawEditScreen("STEP CHORD", "", typeNames[type]);
else
drawEditScreen("STEP CHORD", "", "?");
}
break;
case UI_EDIT_PROG_STEP_REPS:
drawEditScreen("STEP REPEATS", "Reps: ", currentProgression.steps[stepEditIndex/3].repeats);
break;
case UI_EDIT_INTENSITY:
drawNumberEditor("SET INTENSITY", trackIntensities[randomizeTrack], 1, 10);
break;
@@ -154,6 +179,8 @@ void UIManager::drawMenu(int selection, UIState currentState, int midiChannel, i
if (currentVisualIndex >= startVisualIndex) {
if (y > 55) break;
MenuItemID id = menuItems[i].id;
if (i == selection) {
display.fillRect(0, y, 128, 9, SSD1306_WHITE);
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
@@ -168,21 +195,17 @@ void UIManager::drawMenu(int selection, UIState currentState, int midiChannel, i
display.print(menuItems[i].expanded ? F("v ") : F("> "));
}
display.print(menuItems[i].label);
// Render checkbox for scale types
if (menuItems[i].id >= MENU_ID_SCALE_TYPE_CHROMATIC && menuItems[i].id <= MENU_ID_SCALE_TYPE_CHORD_7) {
int typeIndex = menuItems[i].id - MENU_ID_SCALE_TYPE_CHROMATIC;
bool enabled = (enabledScaleTypes & (1 << typeIndex));
int boxX = x - 10;
display.drawRect(boxX, y + 1, 7, 7, (i == selection) ? SSD1306_BLACK : SSD1306_WHITE);
if (enabled) display.fillRect(boxX + 2, y + 3, 3, 3, (i == selection) ? SSD1306_BLACK : SSD1306_WHITE);
if (typeIndex == currentScaleType) {
display.print(F(" *"));
if (id >= MENU_ID_PROG_STEP_START && id < MENU_ID_PROG_STEP_END) {
int stepIdx = (id - MENU_ID_PROG_STEP_START) / 3;
if (stepIdx == visualProgressionStep) {
display.setCursor(x - 6 * 2, y + 1);
display.print(F("| "));
} else if (stepIdx == queuedProgressionStep) {
display.setCursor(x - 6 * 2, y + 1);
display.print(F(", "));
}
}
MenuItemID id = menuItems[i].id;
display.print(menuItems[i].label);
if (id == MENU_ID_CHANNEL) {
display.print(F(": ")); display.print(midiChannel);
@@ -195,13 +218,37 @@ void UIManager::drawMenu(int selection, UIState currentState, int midiChannel, i
} else if (id == MENU_ID_TEMPO) { display.print(F(": ")); display.print(tempo); }
else if (id == MENU_ID_ROOT) {
const char* noteNames[] = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"};
display.print(F(": ")); display.print(noteNames[currentRoot % 12]);
display.print(F(": ")); display.print(noteNames[globalRoot % 12]);
}
else if (id == MENU_ID_STEPS) { display.print(F(": ")); display.print(currentTrackNumSteps); }
else if (id == MENU_ID_SONG_MODE) { display.print(F(": ")); display.print(songModeEnabled ? F("ON") : F("OFF")); }
else if (id == MENU_ID_TRACK_SELECT) { display.print(F(": ")); display.print(randomizeTrack + 1); }
else if (id == MENU_ID_MUTE) { display.print(F(": ")); display.print(trackMute[randomizeTrack] ? F("YES") : F("NO")); }
else if (id == MENU_ID_FLAVOUR) { display.print(F(": ")); display.print(flavourName); }
else if (id == MENU_ID_PROG_ORDER) { display.print(F(": ")); display.print((progressionOrder == PROG_ORDER_SEQUENCE) ? F("Seq") : F("Rnd")); }
else if (id == MENU_ID_PROG_LENGTH) { display.print(F(": ")); display.print(currentProgression.length); }
else if (id >= MENU_ID_PROG_STEP_START && id < MENU_ID_PROG_STEP_END) {
// Only show steps that are within the current length
int stepIdx = (id - MENU_ID_PROG_STEP_START) / 3;
if (stepIdx >= currentProgression.length) {
continue; // Skip rendering this item
}
int idx = id - MENU_ID_PROG_STEP_START;
int step = idx / 3;
int type = idx % 3; // 0=Root, 1=Type, 2=Reps
display.print(F(": "));
if (type == 1) {
const char* typeNames[] = {"Chrom", "Maj", "Min", "HMin", "PMaj", "PMin", "CMaj", "CMin", "CDim", "C7"};
int t = currentProgression.steps[step].scaleType;
if (t >= 0 && t < 10) display.print(typeNames[t]);
} else if (type == 2) {
display.print(currentProgression.steps[step].repeats);
} else {
int root = currentProgression.steps[step].rootOffset;
if (root > 0) display.print(F("+"));
display.print(root);
}
}
else if (id == MENU_ID_INTENSITY) {
display.print(F(": "));
display.print(trackIntensities[randomizeTrack]);