Skip to content

Commit

Permalink
fix copying lumatone state and setting lumatone version
Browse files Browse the repository at this point in the history
  • Loading branch information
vsicurella committed Aug 11, 2024
1 parent aaf0c4f commit ba8264d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
21 changes: 10 additions & 11 deletions Source/lumatone_editor_library/data/lumatone_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ LumatoneState::LumatoneState(juce::String nameIn, const LumatoneState &stateIn)
, mappingData(stateIn.mappingData)
, midiKeyMap(stateIn.midiKeyMap)
{
state = loadStateProperties(stateIn.state);
if (stateIn.state.isValid())
state = stateIn.state;
else
state = juce::ValueTree(LumatoneStateProperty::DefaultState);

loadStateProperties(state);
state.addListener(this);
}

Expand Down Expand Up @@ -101,10 +106,9 @@ void LumatoneState::handleStatePropertyChange(juce::ValueTree stateIn, const juc
}
else if (property == LumatoneStateProperty::LastConnectedFirmwareVersion)
{
setLumatoneVersion(
LumatoneFirmware::ReleaseVersion((int)stateIn.getProperty(property, (int)LumatoneFirmware::ReleaseVersion::FUTURE_VERSION))
);
firmwareVersion = LumatoneFirmware::Version::fromReleaseVersion(determinedVersion);
int value = (int)stateIn.getProperty(property, (int)LumatoneFirmware::ReleaseVersion::FUTURE_VERSION);
LumatoneFirmware::ReleaseVersion version = LumatoneFirmware::ReleaseVersion(value);
setLumatoneVersion(version);
}
else if (property == LumatoneStateProperty::InactiveMacroButtonColour)
{
Expand Down Expand Up @@ -139,15 +143,10 @@ void LumatoneState::setConnectedSerialNumber(juce::String serialNumberIn)
}
}

void LumatoneState::setFirmwareVersion(LumatoneFirmware::Version& versionIn, bool writeToState)
{
firmwareVersion = LumatoneFirmware::Version(versionIn);
setLumatoneVersion(firmwareSupport.getReleaseVersion(firmwareVersion), writeToState);
}

void LumatoneState::setLumatoneVersion(LumatoneFirmware::ReleaseVersion versionIn, bool writeToState)
{
determinedVersion = versionIn;
firmwareVersion = LumatoneFirmware::Version::fromReleaseVersion(determinedVersion);

if (writeToState)
{
Expand Down
2 changes: 0 additions & 2 deletions Source/lumatone_editor_library/data/lumatone_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ class LumatoneState : public LumatoneStateBase

protected:
void setConnectedSerialNumber(juce::String serialNumberIn);
void setFirmwareVersion(LumatoneFirmware::Version& versionIn, bool writeToState=false);

void setLumatoneVersion(LumatoneFirmware::ReleaseVersion versionIn, bool writeToState=false);

protected:
Expand Down

0 comments on commit ba8264d

Please sign in to comment.