Scale type submenu
This commit is contained in:
+11
-132
@@ -12,9 +12,6 @@
|
||||
static Step local_sequence[NUM_TRACKS][NUM_STEPS];
|
||||
|
||||
static void handleInput();
|
||||
static int scaleEditSelection = 0;
|
||||
static int scaleTypeEditIndex = 0;
|
||||
static int scaleEditNoteIndex = 0;
|
||||
static void drawUI();
|
||||
static void updateLeds();
|
||||
|
||||
@@ -35,7 +32,7 @@ void generateRandomScale() {
|
||||
}
|
||||
|
||||
void generateTheme(int themeType) {
|
||||
SequenceGenerator::pickRandomScaleType();
|
||||
SequenceGenerator::pickRandomScaleType(themeType);
|
||||
SequenceGenerator::generateSequenceData(themeType, local_sequence);
|
||||
|
||||
Serial.println(F("Generating theme."));
|
||||
@@ -106,11 +103,6 @@ static void handleInput() {
|
||||
SequenceGenerator::generateSequenceData((queuedTheme != -1) ? queuedTheme : currentThemeIndex, nextSequence);
|
||||
}
|
||||
break;
|
||||
case UI_EDIT_SCALE_TYPE:
|
||||
scaleTypeEditIndex += delta;
|
||||
if (scaleTypeEditIndex < 0) scaleTypeEditIndex = 10;
|
||||
if (scaleTypeEditIndex > 10) scaleTypeEditIndex = 0;
|
||||
break;
|
||||
case UI_EDIT_FLAVOUR:
|
||||
{
|
||||
currentStrategyIndices[randomizeTrack] += (delta > 0 ? 1 : -1);
|
||||
@@ -127,38 +119,6 @@ static void handleInput() {
|
||||
trackIntensity[randomizeTrack] = current;
|
||||
}
|
||||
break;
|
||||
case UI_SCALE_EDIT:
|
||||
scaleEditSelection += (delta > 0 ? 1 : -1);
|
||||
if (scaleEditSelection < 0) scaleEditSelection = numScaleNotes + 4;
|
||||
if (scaleEditSelection > numScaleNotes + 4) scaleEditSelection = 0;
|
||||
break;
|
||||
case UI_SCALE_NOTE_EDIT:
|
||||
scaleNotes[scaleEditNoteIndex] += (delta > 0 ? 1 : -1);
|
||||
if (scaleNotes[scaleEditNoteIndex] < 0) scaleNotes[scaleEditNoteIndex] = 11;
|
||||
if (scaleNotes[scaleEditNoteIndex] > 11) scaleNotes[scaleEditNoteIndex] = 0;
|
||||
midi.lock();
|
||||
midi.sendNoteOn(60 + scaleNotes[scaleEditNoteIndex], 100, midiChannels[randomizeTrack]);
|
||||
midi.unlock();
|
||||
delay(50);
|
||||
midi.lock();
|
||||
midi.sendNoteOff(60 + scaleNotes[scaleEditNoteIndex], midiChannels[randomizeTrack]);
|
||||
midi.unlock();
|
||||
break;
|
||||
case UI_SCALE_TRANSPOSE:
|
||||
if (delta != 0) {
|
||||
int shift = delta % 12;
|
||||
if (shift < 0) shift += 12;
|
||||
for(int i=0; i<numScaleNotes; i++) scaleNotes[i] = (scaleNotes[i] + shift) % 12;
|
||||
sortArray(scaleNotes, numScaleNotes);
|
||||
if (isPlaying) {
|
||||
int theme = (queuedTheme != -1) ? queuedTheme : currentThemeIndex;
|
||||
midi.lock();
|
||||
SequenceGenerator::generateSequenceData(theme, nextSequence);
|
||||
sequenceChangeScheduled = true;
|
||||
midi.unlock();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (currentState == UI_RANDOMIZE_TRACK_EDIT) {
|
||||
randomizeTrack += (delta > 0 ? 1 : -1);
|
||||
@@ -225,16 +185,7 @@ static void handleInput() {
|
||||
saveSequence(true);
|
||||
break;
|
||||
|
||||
case MENU_ID_SCALE:
|
||||
currentState = UI_SCALE_EDIT;
|
||||
scaleEditSelection = 0;
|
||||
break;
|
||||
|
||||
case MENU_ID_ROOT: currentState = UI_EDIT_ROOT; break;
|
||||
case MENU_ID_SCALE_TYPE:
|
||||
currentState = UI_EDIT_SCALE_TYPE;
|
||||
scaleTypeEditIndex = 0;
|
||||
break;
|
||||
case MENU_ID_TEMPO: currentState = UI_EDIT_TEMPO; break;
|
||||
case MENU_ID_STEPS: currentState = UI_EDIT_STEPS; break;
|
||||
|
||||
@@ -256,10 +207,17 @@ static void handleInput() {
|
||||
case MENU_ID_RESET: factoryReset(); break;
|
||||
|
||||
default:
|
||||
if (menuItems[menuSelection].id >= MENU_ID_SCALE_TYPE_CHROMATIC && menuItems[menuSelection].id <= MENU_ID_SCALE_TYPE_CHORD_7) {
|
||||
int typeIndex = menuItems[menuSelection].id - MENU_ID_SCALE_TYPE_CHROMATIC;
|
||||
enabledScaleTypes ^= (1 << typeIndex);
|
||||
if (enabledScaleTypes == 0) enabledScaleTypes = (1 << typeIndex); // Prevent disabling all
|
||||
break;
|
||||
}
|
||||
if (menuItems[menuSelection].id >= MENU_ID_THEME_1 && menuItems[menuSelection].id <= MENU_ID_THEME_7) {
|
||||
const int selectedTheme = menuItems[menuSelection].id - MENU_ID_THEME_1 + 1;
|
||||
if (isPlaying) {
|
||||
queuedTheme = selectedTheme;
|
||||
SequenceGenerator::pickRandomScaleType(queuedTheme);
|
||||
midi.lock();
|
||||
SequenceGenerator::generateSequenceData(queuedTheme, nextSequence);
|
||||
sequenceChangeScheduled = true;
|
||||
@@ -298,15 +256,6 @@ static void handleInput() {
|
||||
currentState = UI_MENU_MAIN;
|
||||
saveSequence(true);
|
||||
break;
|
||||
case UI_EDIT_SCALE_TYPE:
|
||||
if (scaleTypeEditIndex == 10) {
|
||||
currentState = UI_MENU_MAIN;
|
||||
saveSequence(true);
|
||||
} else {
|
||||
enabledScaleTypes ^= (1 << scaleTypeEditIndex);
|
||||
if (enabledScaleTypes == 0) enabledScaleTypes = (1 << scaleTypeEditIndex); // Prevent disabling all
|
||||
}
|
||||
break;
|
||||
case UI_EDIT_FLAVOUR:
|
||||
currentState = UI_MENU_MAIN;
|
||||
if (isPlaying) {
|
||||
@@ -339,71 +288,6 @@ static void handleInput() {
|
||||
currentState = UI_MENU_MAIN;
|
||||
saveSequence(true);
|
||||
break;
|
||||
case UI_SCALE_EDIT:
|
||||
if (scaleEditSelection == 0) {
|
||||
currentState = UI_MENU_MAIN;
|
||||
saveSequence(true);
|
||||
} else if (scaleEditSelection == 1) {
|
||||
generateRandomScale();
|
||||
if (isPlaying) {
|
||||
int theme = (queuedTheme != -1) ? queuedTheme : currentThemeIndex;
|
||||
midi.lock();
|
||||
SequenceGenerator::generateSequenceData(theme, nextSequence);
|
||||
sequenceChangeScheduled = true;
|
||||
midi.unlock();
|
||||
}
|
||||
saveSequence(true);
|
||||
} else if (scaleEditSelection <= numScaleNotes + 1) {
|
||||
scaleEditNoteIndex = scaleEditSelection - 2;
|
||||
currentState = UI_SCALE_NOTE_EDIT;
|
||||
} else if (scaleEditSelection == numScaleNotes + 2) {
|
||||
currentState = UI_SCALE_TRANSPOSE;
|
||||
} else if (scaleEditSelection == numScaleNotes + 3) {
|
||||
if (numScaleNotes < 12) {
|
||||
int next = (numScaleNotes > 0) ? (scaleNotes[numScaleNotes-1] + 1) % 12 : 0;
|
||||
scaleNotes[numScaleNotes] = next;
|
||||
numScaleNotes++;
|
||||
scaleEditSelection--; // Move cursor to the new note
|
||||
if (isPlaying) {
|
||||
int theme = (queuedTheme != -1) ? queuedTheme : currentThemeIndex;
|
||||
midi.lock();
|
||||
SequenceGenerator::generateSequenceData(theme, nextSequence);
|
||||
sequenceChangeScheduled = true;
|
||||
midi.unlock();
|
||||
}
|
||||
saveSequence(true);
|
||||
}
|
||||
} else {
|
||||
if (numScaleNotes > 1) {
|
||||
numScaleNotes--;
|
||||
scaleEditSelection--;
|
||||
if (isPlaying) {
|
||||
int theme = (queuedTheme != -1) ? queuedTheme : currentThemeIndex;
|
||||
midi.lock();
|
||||
SequenceGenerator::generateSequenceData(theme, nextSequence);
|
||||
sequenceChangeScheduled = true;
|
||||
midi.unlock();
|
||||
}
|
||||
saveSequence(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case UI_SCALE_NOTE_EDIT:
|
||||
sortArray(scaleNotes, numScaleNotes);
|
||||
if (isPlaying) {
|
||||
int theme = (queuedTheme != -1) ? queuedTheme : currentThemeIndex;
|
||||
midi.lock();
|
||||
SequenceGenerator::generateSequenceData(theme, nextSequence);
|
||||
sequenceChangeScheduled = true;
|
||||
midi.unlock();
|
||||
}
|
||||
currentState = UI_SCALE_EDIT;
|
||||
saveSequence(true);
|
||||
break;
|
||||
case UI_SCALE_TRANSPOSE:
|
||||
currentState = UI_SCALE_EDIT;
|
||||
saveSequence(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -444,13 +328,7 @@ static void drawUI() {
|
||||
local_randomizeTrack = randomizeTrack;
|
||||
|
||||
local_currentState = currentState;
|
||||
if (local_currentState == UI_SCALE_EDIT || local_currentState == UI_SCALE_NOTE_EDIT || local_currentState == UI_SCALE_TRANSPOSE) {
|
||||
local_menuSelection = scaleEditSelection;
|
||||
} else if (local_currentState == UI_EDIT_SCALE_TYPE) {
|
||||
local_menuSelection = scaleTypeEditIndex;
|
||||
} else {
|
||||
local_menuSelection = menuSelection;
|
||||
}
|
||||
local_menuSelection = menuSelection;
|
||||
local_midiChannel = midiChannels[local_randomizeTrack];
|
||||
local_tempo = tempo;
|
||||
local_currentTrackNumSteps = numSteps[local_randomizeTrack];
|
||||
@@ -517,7 +395,7 @@ static void updateLeds() {
|
||||
// It's a TRACK section item (Track, Mute, Flavour, Mutation, Themes)
|
||||
ledDisplayMode = MODE_MONO;
|
||||
}
|
||||
} else if (local_currentState == UI_EDIT_STEPS || local_currentState == UI_EDIT_FLAVOUR || local_currentState == UI_RANDOMIZE_TRACK_EDIT || local_currentState == UI_SCALE_EDIT || local_currentState == UI_SCALE_NOTE_EDIT || local_currentState == UI_SCALE_TRANSPOSE) {
|
||||
} else if (local_currentState == UI_EDIT_STEPS || local_currentState == UI_EDIT_FLAVOUR || local_currentState == UI_RANDOMIZE_TRACK_EDIT) {
|
||||
// These are entered from TRACK section items
|
||||
ledDisplayMode = MODE_MONO;
|
||||
}
|
||||
@@ -534,6 +412,7 @@ void loopUI() {
|
||||
int nextTheme = random(1, 8); // Themes 1-7
|
||||
int repeats = random(1, 9); // 1-8 repeats
|
||||
|
||||
SequenceGenerator::pickRandomScaleType(nextTheme);
|
||||
SequenceGenerator::generateSequenceData(nextTheme, nextSequence);
|
||||
queuedTheme = nextTheme;
|
||||
nextSongRepeats = repeats;
|
||||
|
||||
Reference in New Issue
Block a user