Better arp

This commit is contained in:
Dejvino
2026-02-17 00:49:17 +01:00
parent 6734572a67
commit 225d04a53c
6 changed files with 146 additions and 64 deletions
+21 -37
View File
@@ -34,7 +34,7 @@ UIState currentState = UI_MENU_MAIN;
const char* mainMenu[] = { "Tracker", "Randomize", "Setup" };
const int mainMenuCount = sizeof(mainMenu) / sizeof(char*);
const char* randomizeMenu[] = { "Back", "Scale", "Melody", "Flavour", "Tempo", "Mutation", "Song Mode", "Theme 1", "Theme 2", "Theme 3", "Theme 4", "Theme 5", "Theme 6", "Theme 7" };
const char* randomizeMenu[] = { "Back", "Melody", "Flavour", "Scale", "Tempo", "Mutation", "Song Mode", "Theme 1", "Theme 2", "Theme 3", "Theme 4", "Theme 5", "Theme 6", "Theme 7" };
const int THEME_1_INDEX = 7;
const int randomizeMenuCount = sizeof(randomizeMenu) / sizeof(char*);
const char* setupMenu[] = { "Back", "Channel", "Save", "Load" };
@@ -100,18 +100,6 @@ void readEncoder() {
}
}
void sortArray(int arr[], int size) {
for (int i = 0; i < size - 1; i++) {
for (int j = 0; j < size - i - 1; j++) {
if (arr[j] > arr[j + 1]) {
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
}
void saveSequence(bool quiet = false) {
int addr = 0;
EEPROM.put(addr, EEPROM_MAGIC); addr += sizeof(EEPROM_MAGIC);
@@ -194,18 +182,7 @@ void setup() {
}
void generateRandomScale() {
numScaleNotes = random(3, 13); // 3 to 12 notes
for (int i = 0; i < 12; i++) {
scaleNotes[i] = i; // Fill with all notes
}
// Shuffle
for (int i = 0; i < 12; i++) {
int j = random(12);
int temp = scaleNotes[i];
scaleNotes[i] = scaleNotes[j];
scaleNotes[j] = temp;
}
sortArray(scaleNotes, numScaleNotes);
strategies[currentStrategyIndex]->generateScale(scaleNotes, numScaleNotes);
}
void generateSequenceData(int themeType, Step* target) {
@@ -333,17 +310,6 @@ void handleInput() {
case UI_MENU_RANDOMIZE:
if (menuSelection == 0) { currentState = UI_MENU_MAIN; menuSelection = 1; }
if (menuSelection == 1) {
generateRandomScale(); // Scale
if (isPlaying) {
int theme = (queuedTheme != -1) ? queuedTheme : currentThemeIndex;
midi.lock();
generateSequenceData(theme, nextSequence);
sequenceChangeScheduled = true;
midi.unlock();
}
saveSequence(true);
}
if (menuSelection == 2) {
melodySeed = random(10000); // Melody
if (isPlaying) {
int theme = (queuedTheme != -1) ? queuedTheme : currentThemeIndex;
@@ -354,7 +320,18 @@ void handleInput() {
}
saveSequence(true);
}
if (menuSelection == 3) currentState = UI_EDIT_FLAVOUR;
if (menuSelection == 2) currentState = UI_EDIT_FLAVOUR; // Flavour
if (menuSelection == 3) { // Scale
generateRandomScale();
if (isPlaying) {
int theme = (queuedTheme != -1) ? queuedTheme : currentThemeIndex;
midi.lock();
generateSequenceData(theme, nextSequence);
sequenceChangeScheduled = true;
midi.unlock();
}
saveSequence(true);
}
if (menuSelection == 4) currentState = UI_EDIT_TEMPO;
if (menuSelection == 5) mutationEnabled = !mutationEnabled;
if (menuSelection == 6) {
@@ -398,6 +375,13 @@ void handleInput() {
break;
case UI_EDIT_FLAVOUR:
currentState = UI_MENU_RANDOMIZE;
if (isPlaying) {
queuedTheme = currentThemeIndex;
midi.lock();
generateSequenceData(currentThemeIndex, nextSequence);
sequenceChangeScheduled = true;
midi.unlock();
}
saveSequence(true);
break;
}