Skip to content

Commit

Permalink
Fix Scale Corruption; disallow Lock and Group changes when scale is off
Browse files Browse the repository at this point in the history
  • Loading branch information
jr0dsgarage committed Mar 16, 2024
1 parent 20eff63 commit ca84fee
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
2 changes: 2 additions & 0 deletions OMX-27-firmware/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ struct ScaleConfig
int scaleRoot = 0;
int scalePattern = -1;
bool lockScale = false; // If Scale is locked you will be unable to play notes out of the scale.
bool lockedState = false; // for holding previous scale lock state
bool group16 = false; // If group16 is active, all notes in scale will be grouped into lower 16 notes.
bool groupedState = false; // for holding previous group16 state
bool scaleSelectHold;
bool showScaleInSeq = false;
};
Expand Down
29 changes: 27 additions & 2 deletions OMX-27-firmware/src/modes/omx_mode_midi_keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,39 @@ void OmxModeMidiKeyboard::onEncoderChanged(Encoder::Update enc)
omxDisp.displayMessage(musicScale->getScaleName(scaleConfig.scalePattern));
musicScale->calculateScale(scaleConfig.scaleRoot, scaleConfig.scalePattern);
}

if (scaleConfig.scalePattern == -1)
{ // record locked and grouped states, then set the current lockScale and group16 to off
if (prevPat != -1)
{
scaleConfig.lockedState = scaleConfig.lockScale;
scaleConfig.groupedState = scaleConfig.group16;
}
scaleConfig.lockScale = 0;
scaleConfig.group16 = 0;
}
else
{ // restore locked and grouped states if the scale was previously set to off
if (prevPat == -1)
{
scaleConfig.lockScale = scaleConfig.lockedState;
scaleConfig.group16 = scaleConfig.groupedState;
}
}
}
if (selParam == 3)
{
scaleConfig.lockScale = constrain(scaleConfig.lockScale + amt, 0, 1);
if (scaleConfig.scalePattern != -1)
{
scaleConfig.lockScale = constrain(scaleConfig.lockScale + amt, 0, 1);
}
}
if (selParam == 4)
{
scaleConfig.group16 = constrain(scaleConfig.group16 + amt, 0, 1);
if (scaleConfig.scalePattern != -1)
{
scaleConfig.group16 = constrain(scaleConfig.group16 + amt, 0, 1);
}
}
}

Expand Down

0 comments on commit ca84fee

Please sign in to comment.