Skip to content

Commit

Permalink
Lots of UI bugfixes, MidiFX QuickEdit mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Quixotic7 committed Mar 2, 2024
1 parent 104d97d commit b8a8c10
Show file tree
Hide file tree
Showing 11 changed files with 232 additions and 183 deletions.
1 change: 1 addition & 0 deletions OMX-27-firmware/src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const uint32_t secs2micros = 1000000;

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

Expand Down
3 changes: 3 additions & 0 deletions OMX-27-firmware/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ struct ColorConfig
uint32_t octDnColor = ORANGE;
uint32_t octUpColor = RBLUE;

uint32_t mfxQuickEdit = RED;

uint32_t mfxNone = LEDOFF;
uint32_t mfxChance = MEDRED;
uint32_t mfxTranspose = PURPLE;
Expand Down Expand Up @@ -373,6 +375,7 @@ extern const int PPQ;

extern const char *mfxOffMsg;
extern const char *mfxArpEditMsg;
extern const char *mfxPassthroughEditMsg;
extern const char *exitMsg;
extern const char *paramOffMsg;

Expand Down
97 changes: 46 additions & 51 deletions OMX-27-firmware/src/midifx/midifx_arpeggiator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace midifx
{
enum ArpPage
{
ARPPAGE_Chance,
ARPPAGE_1,
ARPPAGE_2,
ARPPAGE_3, // TransposeSteps, TransposeDistance
Expand Down Expand Up @@ -129,6 +130,7 @@ namespace midifx

changeArpMode(arpMode_);

params_.addPage(1);
params_.addPage(4);
params_.addPage(4);
params_.addPage(4);
Expand Down Expand Up @@ -2078,6 +2080,16 @@ namespace midifx
auto page = params_.getSelPage();
auto param = params_.getSelParam();

if (e.down() && page >= ARPPAGE_MODPAT && heldKey16_ < 0 && thisKey == 3)
{
funcKeyModLength_ = true;
}

if (!e.down() && thisKey == 3)
{
funcKeyModLength_ = false;
}

if (funcKeyMode == FUNCKEYMODE_NONE || heldKey16_ >= 0)
{
if (e.down())
Expand All @@ -2103,7 +2115,7 @@ namespace midifx
// Select step
if (thisKey >= 11)
{
if (param == 16)
if (param == 16 || funcKeyModLength_)
{
if (page == ARPPAGE_MODPAT)
{
Expand Down Expand Up @@ -2235,6 +2247,9 @@ namespace midifx

if (heldKey16_ < 0)
{
auto modLengthColor = (funcKeyModLength_ && blinkState) ? LEDOFF : FUNKONE;
strip.setPixelColor(3, modLengthColor);

// Function Keys
if (funcKeyMode == FUNCKEYMODE_F3)
{
Expand Down Expand Up @@ -2385,9 +2400,20 @@ namespace midifx
useLabelHeader = true;
}

if (!useLabelHeader && funcKeyMode == FUNCKEYMODE_NONE && (page == ARPPAGE_MODPAT || page == ARPPAGE_TRANSPPAT))
{
if (funcKeyModLength_)
{
useLabelHeader = true;

tempStrings[0] = "Set Length";
}
}

if (!useLabelHeader && funcKeyMode != FUNCKEYMODE_NONE && (page == ARPPAGE_MODPAT || page == ARPPAGE_TRANSPPAT))
{
useLabelHeader = true;

if (funcKeyMode == FUNCKEYMODE_F1)
{
tempStrings[0] = "Reset";
Expand Down Expand Up @@ -2481,70 +2507,39 @@ namespace midifx
// omxDisp.dispValues16(transpPattern_, transpPatternLength_ + 1, 0, 127, false, params_.getSelParam(), params_.getNumPages(), params_.getSelPage(), encoderSelect_, true, labels, 3);
return;
}
else if(page == ARPPAGE_Chance)
{
omxDisp.dispParamBar(chancePerc_, chancePerc_, 0, 100, !getEncoderSelect(), false, "Arpeggiator", "Chance");
return;
}

omxDisp.clearLegends();

if (page == ARPPAGE_1) // Mode, Pattern, Reset mode, Chance
{
omxDisp.legends[0] = "MODE";
omxDisp.legends[1] = "PAT";
omxDisp.legends[2] = "RSET";
omxDisp.legends[3] = "CHC%";
omxDisp.legendText[0] = kModeDisp_[arpMode_];
omxDisp.legendText[1] = kPatDisp_[arpPattern_];
omxDisp.legendText[2] = kResetDisp_[resetMode_];
omxDisp.useLegendString[3] = true;
omxDisp.legendString[3] = String(chancePerc_) + "%";
omxDisp.setLegend(0, "MODE", kModeDisp_[arpMode_]);
omxDisp.setLegend(1, "PAT", kPatDisp_[arpPattern_]);
omxDisp.setLegend(2, "RSET", kResetDisp_[resetMode_]);
omxDisp.setLegend(3, "CHC%", String(chancePerc_) + "%");
}
else if (page == ARPPAGE_2) // Rate, Octave Range, Gate, BPM
{
omxDisp.legends[0] = "RATE";
omxDisp.useLegendString[0] = true;
omxDisp.legendString[0] = "1/" + String(kArpRates[rateIndex_]);

omxDisp.legends[1] = "RANG";
omxDisp.legendVals[1] = (octaveRange_ + 1);

omxDisp.legends[2] = "GATE";
omxDisp.legendVals[2] = gate;

omxDisp.legends[3] = "BPM";
omxDisp.legendVals[3] = (int)clockConfig.clockbpm;
omxDisp.setLegend(0, "RATE", "1/" + String(kArpRates[rateIndex_]));
omxDisp.setLegend(1, "RANG", octaveRange_ + 1);
omxDisp.setLegend(2, "GATE", gate);
omxDisp.setLegend(3, "BPM", (int)clockConfig.clockbpm);
}
else if (page == ARPPAGE_3) // Transpose Distance
{
omxDisp.legends[0] = "ODIST";
omxDisp.useLegendString[0] = true;
omxDisp.legendString[0] = octDistance_ >= 0 ? ("+" + String(octDistance_)) : (String(octDistance_));

omxDisp.legends[1] = "QUANT";

if (quantizedRateIndex_ <= -2)
{
omxDisp.legendText[1] = "OFF";
}
else if (quantizedRateIndex_ == -1)
{
omxDisp.legendText[1] = "GBL";
}
else
{
omxDisp.useLegendString[1] = true;
omxDisp.legendString[1] = "1/" + String(kArpRates[quantizedRateIndex_]);
}


omxDisp.setLegend(0, "ODIST", octDistance_ >= 0 ? ("+" + String(octDistance_)) : (String(octDistance_)));
omxDisp.setLegend(1, "QUANT", quantizedRateIndex_ <= -2, quantizedRateIndex_ == -1 ? "GBL" : "1/" + String(kArpRates[quantizedRateIndex_]));
}
else if (page == ARPPAGE_4) // Velocity, midiChannel_, sendMidi, sendCV
{
omxDisp.legends[0] = "VEL";
omxDisp.legends[1] = "CHAN";
omxDisp.legends[2] = "MIDI";
omxDisp.legends[3] = "CV";
omxDisp.legendVals[0] = velocity_;
omxDisp.legendVals[1] = midiChannel_ + 1;
omxDisp.legendVals[2] = sendMidi_;
omxDisp.legendVals[3] = sendCV_;
omxDisp.setLegend(0, "VEL", velocity_);
omxDisp.setLegend(1, "CHAN", midiChannel_ + 1);
omxDisp.setLegend(2, "MIDI", sendMidi_);
omxDisp.setLegend(3, "CV", sendCV_);
}

omxDisp.dispGenericMode2(params_.getNumPages(), params_.getSelPage(), params_.getSelParam(), getEncoderSelect());
Expand Down
2 changes: 2 additions & 0 deletions OMX-27-firmware/src/midifx/midifx_arpeggiator.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ namespace midifx
int patPos_;
bool goingUp_;

bool funcKeyModLength_; // Shortcut key to edit length of mod and transpose patterns without needing to use the encoder

int8_t heldKey16_ = -1; // Key that is held

int8_t modCopyBuffer_;
Expand Down
23 changes: 7 additions & 16 deletions OMX-27-firmware/src/midifx/midifx_chance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ namespace midifx

MidiFXChance::MidiFXChance()
{
params_.addPage(4);
params_.addPage(1);
encoderSelect_ = true;
chancePerc_ = random(100);
}

int MidiFXChance::getFXType()
Expand Down Expand Up @@ -55,7 +56,7 @@ namespace midifx
// Serial.println("MidiFXChance::noteInput");
// note.noteNumber += 7;

uint8_t r = random(255);
uint8_t r = random(100);

if (r <= chancePerc_)
{
Expand Down Expand Up @@ -84,7 +85,7 @@ namespace midifx
{
if (param == 0)
{
chancePerc_ = constrain(chancePerc_ + amt, 0, 255);
chancePerc_ = constrain(chancePerc_ + amt, 0, 100);
}
}
omxDisp.setDirty();
Expand All @@ -100,24 +101,14 @@ namespace midifx
{
case CHPAGE_1:
{
omxDisp.legends[0] = "CHC%";
omxDisp.legends[1] = "";
omxDisp.legends[2] = "";
omxDisp.legends[3] = "";
omxDisp.legendVals[0] = -127;
omxDisp.legendVals[1] = -127;
omxDisp.legendVals[2] = -127;
omxDisp.legendVals[3] = -127;
omxDisp.useLegendString[0] = true;
uint8_t perc = ((chancePerc_ / 255.0f) * 100);
omxDisp.legendString[0] = String(perc) + "%";
omxDisp.dispParamBar(chancePerc_, chancePerc_, 0, 100, !getEncoderSelect(), false, "Trigger", "Chance");
}
break;
default:
break;
}

omxDisp.dispGenericMode2(params_.getNumPages(), params_.getSelPage(), params_.getSelParam(), getEncoderSelect());
// omxDisp.dispGenericMode2(params_.getNumPages(), params_.getSelPage(), params_.getSelParam(), getEncoderSelect());
}

int MidiFXChance::saveToDisk(int startingAddress, Storage *storage)
Expand All @@ -132,7 +123,7 @@ namespace midifx
{
// Serial.println((String)"Loading mfx chance: " + startingAddress); // 5969

chancePerc_ = storage->read(startingAddress);
chancePerc_ = constrain(storage->read(startingAddress), 0, 100);
// Serial.println((String)"chancePerc_: " + chancePerc_);

return startingAddress + 1;
Expand Down
2 changes: 1 addition & 1 deletion OMX-27-firmware/src/midifx/midifx_chance.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ namespace midifx
void onEncoderChangedEditParam(Encoder::Update enc) override;

private:
uint8_t chancePerc_ = 255;
uint8_t chancePerc_ = 100;
};
}
Loading

0 comments on commit b8a8c10

Please sign in to comment.