Skip to content

Commit

Permalink
Merge branch 'MFXRepeat' of https://github.com/Quixotic7/OMX-27 into …
Browse files Browse the repository at this point in the history
…startupScreenVersionNumber
  • Loading branch information
jr0dsgarage committed Mar 9, 2024
2 parents 5eb16f7 + e409725 commit ac28426
Show file tree
Hide file tree
Showing 70 changed files with 11,573 additions and 1,823 deletions.
Binary file modified .DS_Store
Binary file not shown.
983 changes: 736 additions & 247 deletions Docs.md

Large diffs are not rendered by default.

110 changes: 91 additions & 19 deletions OMX-27-firmware/OMX-27-firmware.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// OMX-27 MIDI KEYBOARD / SEQUENCER

// v1.12.17
// Last update: August 2023
// v1.13.3
// Last update: Feb 2024
//
// Original concept and initial code by Steven Noreyko
// Additional code contributions:
Expand All @@ -28,8 +28,10 @@
#include "src/midi/sysex.h"
#include "src/hardware/omx_keypad.h"
#include "src/utils/omx_util.h"
#include "src/utils/cvNote_util.h"
#include "src/hardware/omx_disp.h"
#include "src/modes/omx_mode_midi_keyboard.h"
#include "src/modes/omx_mode_drum.h"
#include "src/modes/omx_mode_sequencer.h"
#include "src/modes/omx_mode_grids.h"
#include "src/modes/omx_mode_euclidean.h"
Expand All @@ -52,8 +54,11 @@ extern "C"
// #endif

OmxModeMidiKeyboard omxModeMidi;
OmxModeDrum omxModeDrum;
OmxModeSequencer omxModeSeq;
#ifdef OMXMODEGRIDS
OmxModeGrids omxModeGrids;
#endif
OmxModeEuclidean omxModeEuclid;
OmxModeChords omxModeChords;

Expand Down Expand Up @@ -162,6 +167,9 @@ void changeOmxMode(OMXMode newOmxmode)
omxModeMidi.setMidiMode();
activeOmxMode = &omxModeMidi;
break;
case MODE_DRUM:
activeOmxMode = &omxModeDrum;
break;
case MODE_CHORDS:
activeOmxMode = &omxModeChords;
break;
Expand All @@ -178,7 +186,9 @@ void changeOmxMode(OMXMode newOmxmode)
activeOmxMode = &omxModeMidi;
break;
case MODE_GRIDS:
#ifdef OMXMODEGRIDS
activeOmxMode = &omxModeGrids;
#endif
break;
case MODE_EUCLID:
activeOmxMode = &omxModeEuclid;
Expand All @@ -190,6 +200,9 @@ void changeOmxMode(OMXMode newOmxmode)
}

activeOmxMode->onModeActivated();

omxLeds.setDirty();
omxDisp.setDirty();
}

// ####### END LEDS
Expand Down Expand Up @@ -255,9 +268,11 @@ void handleNoteOn(byte channel, byte note, byte velocity)
}
if (midiSettings.midiInToCV)
{
omxUtil.cvNoteOn(note);
cvNoteUtil.cvNoteOn(note);
}

omxScreensaver.resetCounter();

activeOmxMode->inMidiNoteOn(channel, note, velocity);
}

Expand All @@ -270,7 +285,7 @@ void handleNoteOff(byte channel, byte note, byte velocity)

if (midiSettings.midiInToCV)
{
omxUtil.cvNoteOff();
cvNoteUtil.cvNoteOff(note);
}

activeOmxMode->inMidiNoteOff(channel, note, velocity);
Expand Down Expand Up @@ -347,7 +362,13 @@ void saveHeader()
uint8_t scaleGrp16 = (uint8_t)scaleConfig.group16;
storage->write(EEPROM_HEADER_ADDRESS + 34, scaleGrp16);

// 35 bytes
storage->write(EEPROM_HEADER_ADDRESS + 35, midiSettings.defaultVelocity);

storage->write(EEPROM_HEADER_ADDRESS + 36, clockConfig.globalQuantizeStepIndex);

storage->write(EEPROM_HEADER_ADDRESS + 37, cvNoteUtil.triggerMode);

// 38 bytes
}

// returns true if the header contained initialized data
Expand Down Expand Up @@ -413,6 +434,12 @@ bool loadHeader(void)

globalScale.calculateScale(scaleConfig.scaleRoot, scaleConfig.scalePattern);

midiSettings.defaultVelocity = storage->read(EEPROM_HEADER_ADDRESS + 35);

clockConfig.globalQuantizeStepIndex = constrain(storage->read(EEPROM_HEADER_ADDRESS + 36), 0, kNumArpRates - 1);

cvNoteUtil.triggerMode = constrain(storage->read(EEPROM_HEADER_ADDRESS + 37), 0, 1);

return true;
}

Expand Down Expand Up @@ -441,10 +468,13 @@ void savePatterns(void)
{
return;
}
Serial.println((String) "nLocalAddress: " + nLocalAddress);
Serial.println((String)"nLocalAddress: " + nLocalAddress); // 5784

#ifdef OMXMODEGRIDS
Serial.println("Saving Grids");

// Grids patterns
patternSize = OmxModeGrids::serializedPatternSize(storage->isEeprom());
patternSize = OmxModeGrids::serializedPatternSize(isEeprom);
int numPatterns = OmxModeGrids::getNumPatterns();

// Serial.println((String)"OmxModeGrids patternSize: " + patternSize);
Expand All @@ -460,15 +490,20 @@ void savePatterns(void)

nLocalAddress += patternSize;
}
Serial.println((String) "nLocalAddress: " + nLocalAddress); // 5968
Serial.println((String)"nLocalAddress: " + nLocalAddress); // 6008
#endif

Serial.println("Saving Euclidean");
nLocalAddress = omxModeEuclid.saveToDisk(nLocalAddress, storage);
Serial.println((String) "nLocalAddress: " + nLocalAddress); // 6321
Serial.println((String)"nLocalAddress: " + nLocalAddress); // 7433

Serial.println("Saving Chords");
nLocalAddress = omxModeChords.saveToDisk(nLocalAddress, storage);
Serial.println((String) "nLocalAddress: " + nLocalAddress); // 6321
Serial.println((String)"nLocalAddress: " + nLocalAddress); // 10505

Serial.println("Saving Drums");
nLocalAddress = omxModeDrum.saveToDisk(nLocalAddress, storage);
Serial.println((String)"nLocalAddress: " + nLocalAddress); // 11545

Serial.println("Saving MidiFX");
for (uint8_t i = 0; i < NUM_MIDIFX_GROUPS; i++)
Expand All @@ -477,7 +512,15 @@ void savePatterns(void)
// Serial.println((String)"Saved: " + i);
// Serial.println((String)"nLocalAddress: " + nLocalAddress);
}
Serial.println((String) "nLocalAddress: " + nLocalAddress); // 6321
Serial.println((String)"nLocalAddress: " + nLocalAddress); // 11585

// Starting 11545
// MidiFX with nothing 11585
// 1 MidiFX full ARPS 11913
//
// OMX Frooze/Ran out of memory after creating 4 x 8 - 3 = 29 ARPs
// Maybe build in a limit of 2 or one arps per MidiFX, or just recommend users not to
// create 29 ARPs.

// Seq patternSize: 715
// nLocalAddress: 5752
Expand Down Expand Up @@ -525,7 +568,8 @@ void loadPatterns(void)
// 332 * 8 = 2656

// Grids patterns
patternSize = OmxModeGrids::serializedPatternSize(storage->isEeprom());
#ifdef OMXMODEGRIDS
patternSize = OmxModeGrids::serializedPatternSize(isEeprom);
int numPatterns = OmxModeGrids::getNumPatterns();

for (int i = 0; i < numPatterns; i++)
Expand All @@ -540,6 +584,7 @@ void loadPatterns(void)
omxModeGrids.setPattern(i, pattern);
nLocalAddress += patternSize;
}
#endif

Serial.print("Pattern size: ");
Serial.print(patternSize);
Expand All @@ -553,7 +598,11 @@ void loadPatterns(void)

Serial.print("Loading Chords - ");
nLocalAddress = omxModeChords.loadFromDisk(nLocalAddress, storage);
Serial.println((String) "nLocalAddress: " + nLocalAddress); // 5988
Serial.println((String)"nLocalAddress: " + nLocalAddress); // 5988

Serial.print("Loading Drums - ");
nLocalAddress = omxModeDrum.loadFromDisk(nLocalAddress, storage);
Serial.println((String)"nLocalAddress: " + nLocalAddress); // 5988

// Serial.println((String)"nLocalAddress: " + nLocalAddress); // 5968

Expand Down Expand Up @@ -637,8 +686,9 @@ void loop()
seqConfig.currentFrameMicros = micros();
// Micros timeStart = micros();
activeOmxMode->loopUpdate(passed);
cvNoteUtil.loopUpdate(passed);

if (passed > 0)
if (passed > 0) // This should always be true
{
if (sequencer.playing || omxUtil.areClocksRunning())
{
Expand Down Expand Up @@ -693,9 +743,10 @@ void loop()
// set mode
// int modesize = NUM_OMX_MODES;
sysSettings.newmode = (OMXMode)constrain(sysSettings.newmode + amt, 0, NUM_OMX_MODES - 1);
omxDisp.dispMode();
omxDisp.bumpDisplayTimer();
// omxDisp.dispMode();
// omxDisp.bumpDisplayTimer();
omxDisp.setDirty();
omxLeds.setDirty();
}
else
{
Expand All @@ -721,7 +772,8 @@ void loop()
seqStop();
omxLeds.setAllLEDS(0, 0, 0);
encoderConfig.enc_edit = false;
omxDisp.dispMode();
// omxDisp.dispMode();
omxDisp.setDirty();
}
else if (encoderConfig.enc_edit)
{
Expand All @@ -745,9 +797,12 @@ void loop()
}
else
{
// Enter mode change
encoderConfig.enc_edit = true;
sysSettings.newmode = sysSettings.omxMode;
omxDisp.dispMode();
omxLeds.setAllLEDS(0, 0, 0);
omxDisp.setDirty();
// omxDisp.dispMode();
}

omxDisp.setDirty();
Expand Down Expand Up @@ -782,6 +837,9 @@ void loop()
if (e.down() && thisKey == 0 && encoderConfig.enc_edit)
{
// temp - save whenever the 0 key is pressed in encoder edit mode
omxDisp.displayMessage("Saving...");
omxDisp.isDirty();
omxDisp.showDisplay();
saveToStorage();
// Serial.println("EEPROM saved");
omxDisp.displayMessage("Saved State");
Expand Down Expand Up @@ -818,7 +876,15 @@ void loop()
{
omxLeds.updateBlinkStates();
omxDisp.UpdateMessageTextTimer();
activeOmxMode->onDisplayUpdate();

if (encoderConfig.enc_edit)
{
omxDisp.dispMode();
}
else
{
activeOmxMode->onDisplayUpdate();
}
}
else
{ // if screenSaverMode
Expand Down Expand Up @@ -900,6 +966,7 @@ void setup()

lastProcessTime = micros();
omxUtil.resetClocks();
omxUtil.subModeClearStorage.setStoragePtr(storage);

// HW MIDI
MM::begin();
Expand Down Expand Up @@ -953,15 +1020,20 @@ void setup()

globalScale.calculateScale(scaleConfig.scaleRoot, scaleConfig.scalePattern);
omxModeMidi.SetScale(&globalScale);
omxModeDrum.SetScale(&globalScale);
omxModeSeq.SetScale(&globalScale);
#ifdef OMXMODEGRIDS
omxModeGrids.SetScale(&globalScale);
#endif
omxModeEuclid.SetScale(&globalScale);
omxModeChords.SetScale(&globalScale);

// Load from EEPROM
bool bLoaded = loadFromStorage();
if (!bLoaded)
{
Serial.println( "Init load fail. Reinitializing" );

// Failed to load due to initialized EEPROM or version mismatch
// defaults
// sysSettings.omxMode = DEFAULT_MODE;
Expand Down
28 changes: 22 additions & 6 deletions OMX-27-firmware/src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
#include "consts/consts.h"

const OMXMode DEFAULT_MODE = MODE_MIDI;
const uint8_t EEPROM_VERSION = 29;
const uint8_t EEPROM_VERSION = 36;

// v30 - adds storage to header for velocity
// v31 - adds storage for drums
// v32 - adds mfx chord saves
// v33 - adds mfx selector saves
// v34 - adds mfx repeat saves
// v35 - adds quantize rate to arps, added global quant rate to header
// v36 - adds stuff to randomizer

// DEFINE CC NUMBERS FOR POTS // CCS mapped to Organelle Defaults
const int CC1 = 21;
Expand Down Expand Up @@ -54,13 +62,21 @@ int potMaxVal = 8190; // T4 = 1019 // T3.2 = 8190;

const int gridh = 32;
const int gridw = 128;
const int PPQ = 96;
const int PPQ = 96; // Pulses Per Quarter note

const char *mfxOffMsg = "MidiFX are Off";
const uint32_t secs2micros = 1000000;

const char *modes[] = {"MI", "CH", "S1", "S2", "GR", "EL", "OM"};
const char *macromodes[] = {"Off", "M8", "NRN"};
const int nummacromodes = 2;

const char *mfxOffMsg = "MidiFX are Off";
const char *mfxArpEditMsg = "Arp Edit";
const char *mfxPassthroughEditMsg = "MFX Quickedit";
const char *exitMsg = "Exit";
const char *paramOffMsg = "OFF";
const char *paramOnMsg = "ON";

const char *modes[] = {"MI", "DRUM", "CH", "S1", "S2", "GR", "EL", "OM"};
const char *macromodes[] = {"Off", "M8", "NRN", "DEL"};
const int nummacromodes = 3;

float multValues[] = {.25, .5, 1, 2, 4, 8, 16};
const char *mdivs[] = {"1/64", "1/32", "1/16", "1/8", "1/4", "1/2", "W"};
Expand Down
Loading

0 comments on commit ac28426

Please sign in to comment.