70 lines
2.5 KiB
C++
70 lines
2.5 KiB
C++
#include "SharedState.h"
|
|
#include "LuckyStrategy.h"
|
|
#include "ArpStrategy.h"
|
|
#include "EuclideanStrategy.h"
|
|
#include "MarkovStrategy.h"
|
|
#include "CellularAutomataStrategy.h"
|
|
#include "LSystemStrategy.h"
|
|
|
|
// Global state variables
|
|
Step sequence[NUM_TRACKS][NUM_STEPS];
|
|
Step nextSequence[NUM_TRACKS][NUM_STEPS];
|
|
volatile bool sequenceChangeScheduled = false;
|
|
volatile bool needsPanic = false;
|
|
|
|
UIState currentState = UI_MENU_RANDOMIZE;
|
|
|
|
// Menus
|
|
const char* mainMenu[] = { "Randomize", "Setup" };
|
|
extern const int mainMenuCount = sizeof(mainMenu) / sizeof(char*);
|
|
|
|
const char* randomizeMenuMono[] = { "Setup", "Melody", "Flavour", "Scale", "Tempo", "Mutation", "Song Mode", "Theme 1", "Theme 2", "Theme 3", "Theme 4", "Theme 5", "Theme 6", "Theme 7" };
|
|
extern const int randomizeMenuMonoCount = sizeof(randomizeMenuMono) / sizeof(char*);
|
|
extern const int THEME_1_INDEX_MONO = 7;
|
|
|
|
const char* randomizeMenuPoly[] = { "Setup", "Track", "Mute", "Melody", "Flavour", "Scale", "Tempo", "Mutation", "Song Mode", "Theme 1", "Theme 2", "Theme 3", "Theme 4", "Theme 5", "Theme 6", "Theme 7" };
|
|
extern const int randomizeMenuPolyCount = sizeof(randomizeMenuPoly) / sizeof(char*);
|
|
extern const int THEME_1_INDEX_POLY = 9;
|
|
|
|
const char* setupMenu[] = { "Back", "Play Mode", "Channel", "Factory Reset" };
|
|
extern const int setupMenuCount = sizeof(setupMenu) / sizeof(char*);
|
|
|
|
int menuSelection = 0;
|
|
volatile bool trackMute[NUM_TRACKS];
|
|
int randomizeTrack = 0;
|
|
volatile int playbackStep = 0;
|
|
volatile int midiChannels[NUM_TRACKS];
|
|
int scaleNotes[12];
|
|
int numScaleNotes = 0;
|
|
int melodySeeds[NUM_TRACKS];
|
|
volatile int queuedTheme = -1;
|
|
volatile int currentThemeIndex = 1;
|
|
extern const uint32_t EEPROM_MAGIC = 0x4242424B;
|
|
|
|
MelodyStrategy* strategies[] = {
|
|
new LuckyStrategy(), new ArpStrategy(), new EuclideanStrategy(),
|
|
new MarkovStrategy(), new CellularAutomataStrategy(), new LSystemStrategy()};
|
|
extern const int numStrategies = 6;
|
|
int currentStrategyIndices[NUM_TRACKS];
|
|
|
|
volatile PlayMode playMode = MODE_MONO;
|
|
volatile bool mutationEnabled = false;
|
|
volatile bool songModeEnabled = false;
|
|
volatile int songRepeatsRemaining = 0;
|
|
volatile int nextSongRepeats = 0;
|
|
volatile bool songModeNeedsNext = false;
|
|
volatile bool isPlaying = false;
|
|
volatile int tempo = 120; // BPM
|
|
volatile unsigned long lastClockTime = 0;
|
|
volatile int clockCount = 0;
|
|
|
|
// Encoder State
|
|
volatile int encoderDelta = 0;
|
|
|
|
// Button State
|
|
bool lastButtonState = HIGH;
|
|
unsigned long lastDebounceTime = 0;
|
|
bool buttonActive = false;
|
|
bool buttonConsumed = false;
|
|
unsigned long buttonPressTime = 0;
|