Skip to content

Commit

Permalink
Add enum value setter and test
Browse files Browse the repository at this point in the history
  • Loading branch information
jatinchowdhury18 committed Nov 5, 2024
1 parent 53df542 commit 3541e96
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ class EnumChoiceParameter : public ChoiceParameter
return magic_enum::enum_value<EnumType> ((size_t) getIndex());
}

/**
* Sets the parameter value.
* This will result in a call @c setValueNotifyingHost, so make sure that's what you want.
* Especially if calling this from the audio thread!
*/
void setParameterValue (EnumType newValue) { AudioParameterChoice::operator= (static_cast<int> (*magic_enum::enum_index (newValue))); }

using Ptr = OptionalPointer<EnumChoiceParameter>;

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ TEST_CASE ("Param Helpers Test", "[plugin][parameters]")
REQUIRE_MESSAGE (modeParam.get() == Mode_1, "Default value is incorrect!");
modeParam.setValueNotifyingHost (1.0f);
REQUIRE_MESSAGE (modeParam.get() == Mode_3, "Set value is incorrect!");
modeParam.setParameterValue (Mode_2);
REQUIRE_MESSAGE (modeParam.get() == Mode_2, "Set value is incorrect!");
}

SECTION ("Create Semitones Param Test")
Expand Down

0 comments on commit 3541e96

Please sign in to comment.