Scale editor
This commit is contained in:
+107
-12
@@ -18,6 +18,8 @@
|
||||
static Step local_sequence[NUM_TRACKS][NUM_STEPS];
|
||||
|
||||
static void handleInput();
|
||||
static int scaleEditSelection = 0;
|
||||
static int scaleEditNoteIndex = 0;
|
||||
static void drawUI();
|
||||
static void updateLeds();
|
||||
static void generateTrackData(int track, int themeType, Step (*target)[NUM_STEPS]);
|
||||
@@ -179,6 +181,38 @@ static void handleInput() {
|
||||
if (currentStrategyIndices[randomizeTrack] >= numStrategies) currentStrategyIndices[randomizeTrack] = 0;
|
||||
}
|
||||
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();
|
||||
generateSequenceData(theme, nextSequence);
|
||||
sequenceChangeScheduled = true;
|
||||
midi.unlock();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (currentState == UI_RANDOMIZE_TRACK_EDIT) {
|
||||
randomizeTrack += (delta > 0 ? 1 : -1);
|
||||
@@ -242,16 +276,8 @@ static void handleInput() {
|
||||
break;
|
||||
|
||||
case MENU_ID_SCALE:
|
||||
generateRandomScale();
|
||||
if (isPlaying) {
|
||||
int theme = (queuedTheme != -1) ? queuedTheme : currentThemeIndex;
|
||||
midi.lock();
|
||||
// Regenerate all tracks with new scale
|
||||
generateSequenceData(theme, nextSequence);
|
||||
sequenceChangeScheduled = true;
|
||||
midi.unlock();
|
||||
}
|
||||
saveSequence(true);
|
||||
currentState = UI_SCALE_EDIT;
|
||||
scaleEditSelection = 0;
|
||||
break;
|
||||
|
||||
case MENU_ID_TEMPO: currentState = UI_EDIT_TEMPO; break;
|
||||
@@ -319,6 +345,71 @@ 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();
|
||||
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();
|
||||
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();
|
||||
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();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -358,7 +449,11 @@ static void drawUI() {
|
||||
local_randomizeTrack = randomizeTrack;
|
||||
|
||||
local_currentState = currentState;
|
||||
local_menuSelection = menuSelection;
|
||||
if (local_currentState == UI_SCALE_EDIT || local_currentState == UI_SCALE_NOTE_EDIT || local_currentState == UI_SCALE_TRANSPOSE) {
|
||||
local_menuSelection = scaleEditSelection;
|
||||
} else {
|
||||
local_menuSelection = menuSelection;
|
||||
}
|
||||
local_midiChannel = midiChannels[local_randomizeTrack];
|
||||
local_tempo = tempo;
|
||||
local_numSteps = numSteps;
|
||||
@@ -424,7 +519,7 @@ static void updateLeds() {
|
||||
// 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) {
|
||||
} else if (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) {
|
||||
// These are entered from TRACK section items
|
||||
ledDisplayMode = MODE_MONO;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user