Presets patches
This commit is contained in:
@@ -24,6 +24,8 @@ static void drawUI();
|
||||
static void updateLeds();
|
||||
static void generateTrackData(int track, int themeType, Step (*target)[NUM_STEPS]);
|
||||
static void generateSequenceData(int themeType, Step (*target)[NUM_STEPS]);
|
||||
static void savePatch(int bank, int slot);
|
||||
static void loadPatch(int bank, int slot);
|
||||
|
||||
void saveSequence(bool quiet) {
|
||||
midi.lock();
|
||||
@@ -86,6 +88,57 @@ bool loadSequence() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static void savePatch(int bank, int slot) {
|
||||
int patchIndex = bank * 4 + slot;
|
||||
int addr = 512 + patchIndex * 128; // Start after main save, 128 bytes per patch
|
||||
|
||||
midi.lock();
|
||||
EEPROM.put(addr, numScaleNotes); addr += sizeof(numScaleNotes);
|
||||
for (int i = 0; i < 12; i++) {
|
||||
EEPROM.put(addr, scaleNotes[i]); addr += sizeof(int);
|
||||
}
|
||||
EEPROM.put(addr, currentStrategyIndices); addr += sizeof(currentStrategyIndices);
|
||||
EEPROM.put(addr, melodySeeds); addr += sizeof(melodySeeds);
|
||||
EEPROM.put(addr, (int)numSteps); addr += sizeof(int);
|
||||
bool mutes[NUM_TRACKS];
|
||||
for(int i=0; i<NUM_TRACKS; i++) mutes[i] = trackMute[i];
|
||||
EEPROM.put(addr, mutes); addr += sizeof(mutes);
|
||||
midi.unlock();
|
||||
EEPROM.commit();
|
||||
ui.showMessage("PATCH SAVED!");
|
||||
}
|
||||
|
||||
static void loadPatch(int bank, int slot) {
|
||||
int patchIndex = bank * 4 + slot;
|
||||
int addr = 512 + patchIndex * 128;
|
||||
|
||||
midi.lock();
|
||||
EEPROM.get(addr, numScaleNotes); addr += sizeof(numScaleNotes);
|
||||
for (int i = 0; i < 12; i++) {
|
||||
EEPROM.get(addr, scaleNotes[i]); addr += sizeof(int);
|
||||
}
|
||||
EEPROM.get(addr, currentStrategyIndices); addr += sizeof(currentStrategyIndices);
|
||||
EEPROM.get(addr, melodySeeds); addr += sizeof(melodySeeds);
|
||||
int t;
|
||||
EEPROM.get(addr, t); addr += sizeof(int);
|
||||
numSteps = t;
|
||||
if (numSteps <= 0 || numSteps >= NUM_STEPS) numSteps = NUM_STEPS;
|
||||
|
||||
bool mutes[NUM_TRACKS];
|
||||
EEPROM.get(addr, mutes); addr += sizeof(mutes);
|
||||
for(int i=0; i<NUM_TRACKS; i++) trackMute[i] = mutes[i];
|
||||
|
||||
if (isPlaying) {
|
||||
generateSequenceData(currentThemeIndex, nextSequence);
|
||||
sequenceChangeScheduled = true;
|
||||
} else {
|
||||
generateSequenceData(currentThemeIndex, local_sequence);
|
||||
memcpy(sequence, local_sequence, sizeof(local_sequence));
|
||||
}
|
||||
midi.unlock();
|
||||
ui.showMessage("PATCH LOADED!");
|
||||
}
|
||||
|
||||
void factoryReset() {
|
||||
ui.showMessage("RESETTING...");
|
||||
uint32_t magic = 0;
|
||||
@@ -312,6 +365,15 @@ static void handleInput() {
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (menuItems[menuSelection].id >= MENU_ID_PATCH_ACTIONS_START) {
|
||||
int offset = menuItems[menuSelection].id - MENU_ID_PATCH_ACTIONS_START;
|
||||
int bank = offset / 8;
|
||||
int slot = (offset % 8) / 2;
|
||||
bool isSave = (offset % 2) == 0;
|
||||
if (isSave) savePatch(bank, slot);
|
||||
else loadPatch(bank, slot);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user