Drop mono mode
This commit is contained in:
+48
-71
@@ -36,7 +36,6 @@ void saveSequence(bool quiet) {
|
||||
for(int i=0; i<NUM_TRACKS; i++) mutes[i] = trackMute[i];
|
||||
EEPROM.put(addr, mutes); addr += sizeof(mutes);
|
||||
EEPROM.put(addr, (int)tempo); addr += sizeof(int);
|
||||
EEPROM.put(addr, (int)playMode); addr += sizeof(int);
|
||||
|
||||
EEPROM.put(addr, numScaleNotes); addr += sizeof(numScaleNotes);
|
||||
for (int i = 0; i<12; i++) {
|
||||
@@ -67,8 +66,6 @@ bool loadSequence() {
|
||||
int t;
|
||||
EEPROM.get(addr, t); addr += sizeof(int);
|
||||
tempo = t;
|
||||
EEPROM.get(addr, t); addr += sizeof(int);
|
||||
playMode = (PlayMode)t;
|
||||
|
||||
EEPROM.get(addr, numScaleNotes); addr += sizeof(numScaleNotes);
|
||||
for (int i = 0; i<12; i++) {
|
||||
@@ -121,11 +118,7 @@ void generateTheme(int themeType) {
|
||||
}
|
||||
|
||||
void mutateSequence(Step (*target)[NUM_STEPS]) {
|
||||
if (playMode == MODE_POLY) {
|
||||
for(int i=0; i<NUM_TRACKS; i++) strategies[currentStrategyIndices[i]]->mutate(target, i, NUM_STEPS, scaleNotes, numScaleNotes);
|
||||
} else {
|
||||
strategies[currentStrategyIndices[0]]->mutate(target, 0, NUM_STEPS, scaleNotes, numScaleNotes);
|
||||
}
|
||||
for(int i=0; i<NUM_TRACKS; i++) strategies[currentStrategyIndices[i]]->mutate(target, i, NUM_STEPS, scaleNotes, numScaleNotes);
|
||||
}
|
||||
|
||||
static void handleInput() {
|
||||
@@ -146,9 +139,8 @@ static void handleInput() {
|
||||
case UI_MENU_RANDOMIZE:
|
||||
{
|
||||
menuSelection += (delta > 0 ? 1 : -1);
|
||||
int count = (playMode == MODE_POLY) ? randomizeMenuPolyCount : randomizeMenuMonoCount;
|
||||
if (menuSelection < 0) menuSelection = count - 1;
|
||||
if (menuSelection >= count) menuSelection = 0;
|
||||
if (menuSelection < 0) menuSelection = randomizeMenuPolyCount - 1;
|
||||
if (menuSelection >= randomizeMenuPolyCount) menuSelection = 0;
|
||||
}
|
||||
break;
|
||||
case UI_MENU_SETUP:
|
||||
@@ -158,10 +150,9 @@ static void handleInput() {
|
||||
break;
|
||||
case UI_SETUP_CHANNEL_EDIT:
|
||||
{
|
||||
int trackToEdit = (playMode == MODE_POLY) ? randomizeTrack : 0;
|
||||
midiChannels[trackToEdit] += (delta > 0 ? 1 : -1);
|
||||
if (midiChannels[trackToEdit] < 1) midiChannels[trackToEdit] = 16;
|
||||
if (midiChannels[trackToEdit] > 16) midiChannels[trackToEdit] = 1;
|
||||
midiChannels[randomizeTrack] += (delta > 0 ? 1 : -1);
|
||||
if (midiChannels[randomizeTrack] < 1) midiChannels[randomizeTrack] = 16;
|
||||
if (midiChannels[randomizeTrack] > 16) midiChannels[randomizeTrack] = 1;
|
||||
}
|
||||
break;
|
||||
case UI_EDIT_TEMPO:
|
||||
@@ -171,15 +162,11 @@ static void handleInput() {
|
||||
break;
|
||||
case UI_EDIT_FLAVOUR:
|
||||
{
|
||||
int trackToEdit = playMode == MODE_POLY ? randomizeTrack : 0;
|
||||
currentStrategyIndices[trackToEdit] += (delta > 0 ? 1 : -1);
|
||||
if (currentStrategyIndices[trackToEdit] < 0) currentStrategyIndices[trackToEdit] = numStrategies - 1;
|
||||
if (currentStrategyIndices[trackToEdit] >= numStrategies) currentStrategyIndices[trackToEdit] = 0;
|
||||
currentStrategyIndices[randomizeTrack] += (delta > 0 ? 1 : -1);
|
||||
if (currentStrategyIndices[randomizeTrack] < 0) currentStrategyIndices[randomizeTrack] = numStrategies - 1;
|
||||
if (currentStrategyIndices[randomizeTrack] >= numStrategies) currentStrategyIndices[randomizeTrack] = 0;
|
||||
}
|
||||
break;
|
||||
case UI_SETUP_PLAYMODE_EDIT:
|
||||
playMode = (playMode == MODE_MONO) ? MODE_POLY : MODE_MONO;
|
||||
break;
|
||||
}
|
||||
if (currentState == UI_RANDOMIZE_TRACK_EDIT) {
|
||||
randomizeTrack += (delta > 0 ? 1 : -1);
|
||||
@@ -216,32 +203,24 @@ static void handleInput() {
|
||||
break;
|
||||
case UI_MENU_RANDOMIZE:
|
||||
{
|
||||
int track_offset = (playMode == MODE_POLY) ? 2 : 0;
|
||||
int theme_1_index = (playMode == MODE_POLY) ? THEME_1_INDEX_POLY : THEME_1_INDEX_MONO;
|
||||
if (menuSelection == 0) { currentState = UI_MENU_SETUP; menuSelection = 0; break; }
|
||||
if (playMode == MODE_POLY) {
|
||||
if (menuSelection == 1) { currentState = UI_RANDOMIZE_TRACK_EDIT; break; }
|
||||
if (menuSelection == 2) { trackMute[randomizeTrack] = !trackMute[randomizeTrack]; break; }
|
||||
}
|
||||
|
||||
if (menuSelection == 1 + track_offset) { // Melody
|
||||
int track = playMode == MODE_POLY ? randomizeTrack : 0;
|
||||
if (menuSelection == 1) { // Melody
|
||||
midi.lock();
|
||||
melodySeeds[track] = random(10000);
|
||||
melodySeeds[randomizeTrack] = random(10000);
|
||||
if (isPlaying) {
|
||||
int theme = (queuedTheme != -1) ? queuedTheme : currentThemeIndex;
|
||||
if (!sequenceChangeScheduled) {
|
||||
memcpy(nextSequence, sequence, sizeof(sequence));
|
||||
}
|
||||
generateTrackData(track, theme, nextSequence);
|
||||
generateTrackData(randomizeTrack, theme, nextSequence);
|
||||
sequenceChangeScheduled = true;
|
||||
}
|
||||
midi.unlock();
|
||||
saveSequence(true);
|
||||
break;
|
||||
}
|
||||
if (menuSelection == 2 + track_offset) { currentState = UI_EDIT_FLAVOUR; break; } // Flavour
|
||||
if (menuSelection == 3 + track_offset) { // Scale
|
||||
if (menuSelection == 2) { // Scale
|
||||
generateRandomScale();
|
||||
if (isPlaying) {
|
||||
int theme = (queuedTheme != -1) ? queuedTheme : currentThemeIndex;
|
||||
@@ -254,17 +233,22 @@ static void handleInput() {
|
||||
saveSequence(true);
|
||||
break;
|
||||
}
|
||||
if (menuSelection == 4 + track_offset) { currentState = UI_EDIT_TEMPO; break; }
|
||||
if (menuSelection == 5 + track_offset) { mutationEnabled = !mutationEnabled; break; }
|
||||
if (menuSelection == 6 + track_offset) {
|
||||
if (menuSelection == 3) { currentState = UI_EDIT_TEMPO; break; } // Tempo
|
||||
if (menuSelection == 4) { // Song Mode
|
||||
songModeEnabled = !songModeEnabled;
|
||||
if (songModeEnabled) {
|
||||
songModeNeedsNext = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (menuSelection >= theme_1_index) { // Themes
|
||||
const int selectedTheme = menuSelection - theme_1_index + 1;
|
||||
|
||||
if (menuSelection == 5) { currentState = UI_RANDOMIZE_TRACK_EDIT; break; } // Track
|
||||
if (menuSelection == 6) { trackMute[randomizeTrack] = !trackMute[randomizeTrack]; break; } // Mute
|
||||
if (menuSelection == 7) { currentState = UI_EDIT_FLAVOUR; break; } // Flavour
|
||||
if (menuSelection == 8) { mutationEnabled = !mutationEnabled; break; } // Mutation
|
||||
|
||||
if (menuSelection >= THEME_1_INDEX_POLY) { // Themes
|
||||
const int selectedTheme = menuSelection - THEME_1_INDEX_POLY + 1;
|
||||
if (isPlaying) {
|
||||
queuedTheme = selectedTheme;
|
||||
midi.lock();
|
||||
@@ -280,9 +264,8 @@ static void handleInput() {
|
||||
break;
|
||||
case UI_MENU_SETUP:
|
||||
if (menuSelection == 0) { currentState = UI_MENU_RANDOMIZE; menuSelection = 0; break; }
|
||||
if (menuSelection == 1) { currentState = UI_SETUP_PLAYMODE_EDIT; break; }
|
||||
if (menuSelection == 2) { currentState = UI_SETUP_CHANNEL_EDIT; break; }
|
||||
if (menuSelection == 3) { factoryReset(); break; }
|
||||
if (menuSelection == 1) { currentState = UI_SETUP_CHANNEL_EDIT; break; }
|
||||
if (menuSelection == 2) { factoryReset(); break; }
|
||||
break;
|
||||
case UI_SETUP_CHANNEL_EDIT:
|
||||
currentState = UI_MENU_SETUP;
|
||||
@@ -296,21 +279,16 @@ static void handleInput() {
|
||||
currentState = UI_MENU_RANDOMIZE;
|
||||
if (isPlaying) {
|
||||
int theme = (queuedTheme != -1) ? queuedTheme : currentThemeIndex;
|
||||
int track = playMode == MODE_POLY ? randomizeTrack : 0;
|
||||
midi.lock();
|
||||
if (!sequenceChangeScheduled) {
|
||||
memcpy(nextSequence, sequence, sizeof(sequence));
|
||||
}
|
||||
generateTrackData(track, theme, nextSequence);
|
||||
generateTrackData(randomizeTrack, theme, nextSequence);
|
||||
sequenceChangeScheduled = true;
|
||||
midi.unlock();
|
||||
}
|
||||
saveSequence(true);
|
||||
break;
|
||||
case UI_SETUP_PLAYMODE_EDIT:
|
||||
currentState = UI_MENU_SETUP;
|
||||
saveSequence(true);
|
||||
break;
|
||||
case UI_RANDOMIZE_TRACK_EDIT:
|
||||
currentState = UI_MENU_RANDOMIZE;
|
||||
saveSequence(true);
|
||||
@@ -338,14 +316,9 @@ static void handleInput() {
|
||||
}
|
||||
|
||||
static void drawUI() {
|
||||
const char **randMenu;
|
||||
int randMenuCount;
|
||||
int themeIndex;
|
||||
|
||||
// Make local copies of shared data inside a critical section
|
||||
// to avoid holding the lock during slow display operations.
|
||||
UIState local_currentState;
|
||||
PlayMode local_playMode;
|
||||
int local_menuSelection, local_randomizeTrack, local_tempo, local_currentThemeIndex, local_queuedTheme, local_numScaleNotes;
|
||||
int local_melodySeed;
|
||||
bool local_mutationEnabled, local_songModeEnabled, local_isPlaying;
|
||||
@@ -356,30 +329,18 @@ static void drawUI() {
|
||||
int local_scaleNotes[12];
|
||||
|
||||
midi.lock();
|
||||
local_playMode = playMode;
|
||||
local_randomizeTrack = randomizeTrack;
|
||||
int ui_track = (local_playMode == MODE_POLY) ? local_randomizeTrack : 0;
|
||||
|
||||
if (local_playMode == MODE_POLY) {
|
||||
randMenu = randomizeMenuPoly;
|
||||
randMenuCount = randomizeMenuPolyCount;
|
||||
themeIndex = THEME_1_INDEX_POLY;
|
||||
} else {
|
||||
randMenu = randomizeMenuMono;
|
||||
randMenuCount = randomizeMenuMonoCount;
|
||||
themeIndex = THEME_1_INDEX_MONO;
|
||||
}
|
||||
|
||||
local_currentState = currentState;
|
||||
local_menuSelection = menuSelection;
|
||||
local_midiChannel = midiChannels[ui_track];
|
||||
local_midiChannel = midiChannels[local_randomizeTrack];
|
||||
local_tempo = tempo;
|
||||
local_strategy = strategies[currentStrategyIndices[ui_track]];
|
||||
local_strategy = strategies[currentStrategyIndices[local_randomizeTrack]];
|
||||
local_queuedTheme = queuedTheme;
|
||||
local_currentThemeIndex = currentThemeIndex;
|
||||
local_numScaleNotes = numScaleNotes;
|
||||
memcpy(local_scaleNotes, scaleNotes, sizeof(local_scaleNotes));
|
||||
local_melodySeed = melodySeeds[ui_track];
|
||||
local_melodySeed = melodySeeds[local_randomizeTrack];
|
||||
local_mutationEnabled = mutationEnabled;
|
||||
local_songModeEnabled = songModeEnabled;
|
||||
memcpy(local_sequence, sequence, sizeof(local_sequence));
|
||||
@@ -392,8 +353,8 @@ static void drawUI() {
|
||||
local_midiChannel, local_tempo, local_strategy,
|
||||
local_queuedTheme, local_currentThemeIndex, local_numScaleNotes, local_scaleNotes, local_melodySeed,
|
||||
local_mutationEnabled, local_songModeEnabled, (const Step (*)[NUM_STEPS])local_sequence, local_playbackStep, local_isPlaying,
|
||||
mainMenu, mainMenuCount, randMenu, randMenuCount, setupMenu, setupMenuCount,
|
||||
themeIndex, local_playMode, local_randomizeTrack, (const bool*)local_trackMute);
|
||||
mainMenu, mainMenuCount, randomizeMenuPoly, randomizeMenuPolyCount, setupMenu, setupMenuCount,
|
||||
THEME_1_INDEX_POLY, MODE_POLY, local_randomizeTrack, (const bool*)local_trackMute);
|
||||
}
|
||||
|
||||
static void updateLeds() {
|
||||
@@ -402,6 +363,7 @@ static void updateLeds() {
|
||||
int local_playbackStep;
|
||||
bool local_isPlaying;
|
||||
UIState local_currentState;
|
||||
int local_menuSelection;
|
||||
bool local_songModeEnabled;
|
||||
int local_songRepeatsRemaining;
|
||||
bool local_sequenceChangeScheduled;
|
||||
@@ -415,6 +377,7 @@ static void updateLeds() {
|
||||
local_playbackStep = playbackStep;
|
||||
local_isPlaying = isPlaying;
|
||||
local_currentState = currentState;
|
||||
local_menuSelection = menuSelection;
|
||||
local_songModeEnabled = songModeEnabled;
|
||||
local_songRepeatsRemaining = songRepeatsRemaining;
|
||||
local_sequenceChangeScheduled = sequenceChangeScheduled;
|
||||
@@ -424,9 +387,23 @@ static void updateLeds() {
|
||||
memcpy(local_trackMute, (const void*)trackMute, sizeof(local_trackMute));
|
||||
midi.unlock();
|
||||
|
||||
PlayMode ledDisplayMode = MODE_POLY; // Default to POLY (MAIN section view)
|
||||
|
||||
if (local_currentState == UI_MENU_RANDOMIZE) {
|
||||
// Main section items: Setup(0), Melody(1), Scale(2), Tempo(3), Song Mode(4)
|
||||
bool isMainSection = (local_menuSelection <= 4);
|
||||
if (!isMainSection) {
|
||||
// It's a TRACK section item (Track, Mute, Flavour, Mutation, Themes)
|
||||
ledDisplayMode = MODE_MONO;
|
||||
}
|
||||
} else if (local_currentState == UI_EDIT_FLAVOUR || local_currentState == UI_RANDOMIZE_TRACK_EDIT) {
|
||||
// These are entered from TRACK section items
|
||||
ledDisplayMode = MODE_MONO;
|
||||
}
|
||||
|
||||
ui.updateLeds((const Step (*)[NUM_STEPS])local_sequence, local_playbackStep, local_isPlaying,
|
||||
local_currentState, local_songModeEnabled, local_songRepeatsRemaining,
|
||||
local_sequenceChangeScheduled, local_playMode, local_numScaleNotes,
|
||||
local_sequenceChangeScheduled, ledDisplayMode, local_numScaleNotes,
|
||||
local_scaleNotes, (const bool*)local_trackMute);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user