27class ParamDescriptor {
29 ParamDescriptor() =
default;
30 ParamDescriptor(
const ParamDescriptor&) =
default;
31 ParamDescriptor(ParamDescriptor&&) =
default;
32 ParamDescriptor& operator=(
const ParamDescriptor&) =
default;
33 ParamDescriptor& operator=(ParamDescriptor&&) =
default;
38 constexpr void setToHaveParamOnly(int32_t p) { data = p | 0xFFFFFF00; }
40 constexpr void setToHaveParamAndSource(int32_t p, PatchSource s) {
41 data = p | (util::to_underlying(s) << 8) | 0xFFFF0000;
44 constexpr void setToHaveParamAndTwoSources(int32_t p, PatchSource s, PatchSource sLowestLevel) {
45 data = p | (util::to_underlying(s) << 8) | (util::to_underlying(sLowestLevel) << 16) | 0xFF000000;
48 [[nodiscard]]
constexpr bool isSetToParamWithNoSource(int32_t p)
const {
return (data == (p | 0xFFFFFF00)); }
50 [[nodiscard]]
constexpr inline bool isSetToParamAndSource(int32_t p, PatchSource s)
const {
51 return (data == (p | (util::to_underlying(s) << 8) | 0xFFFF0000));
54 [[nodiscard]]
constexpr bool isJustAParam()
const {
return (data & 0x0000FF00) == 0x0000FF00; }
56 [[nodiscard]]
constexpr int32_t getJustTheParam()
const {
return data & 0xFF; }
58 constexpr void changeParam(int32_t newParam) { data = (data & 0xFFFFFF00) | newParam; }
60 [[nodiscard]]
constexpr PatchSource getBottomLevelSource()
const {
61 if ((data & 0x00FF0000) == 0x00FF0000) {
62 return static_cast<PatchSource
>((data >> 8) & 0xFF);
65 return static_cast<PatchSource
>((data >> 16) & 0xFF);
68 constexpr void addSource(PatchSource newSource) {
69 uint8_t newSourceUnderlying = util::to_underlying(newSource);
70 if ((data & 0x0000FF00) == 0x0000FF00) {
71 data = (data & 0xFFFF00FF) | (newSourceUnderlying << 8);
73 else if ((data & 0x00FF0000) == 0x00FF0000) {
74 data = (data & 0xFF00FFFF) | (newSourceUnderlying << 16);
77 data = (data & 0x00FFFFFF) | (newSourceUnderlying << 24);
81 [[nodiscard]]
constexpr ParamDescriptor getDestination()
const {
82 ParamDescriptor newParamDescriptor{};
83 if ((data & 0x00FF0000) == 0x00FF0000) {
84 newParamDescriptor.data = data | 0x0000FF00;
87 newParamDescriptor.data = data | 0x00FF0000;
89 return newParamDescriptor;
92 [[nodiscard]]
constexpr bool hasJustOneSource()
const {
93 return ((data & 0xFFFF0000) == 0xFFFF0000) && ((data & 0x0000FF00) != 0x0000FF00);
96 [[nodiscard]]
constexpr PatchSource getTopLevelSource()
const {
97 return static_cast<PatchSource
>((data & 0x0000FF00) >> 8);
100 [[nodiscard]]
constexpr PatchSource getSecondSourceFromTop()
const {
101 return static_cast<PatchSource
>((data & 0x00FF0000) >> 16);
104 [[nodiscard]]
constexpr bool hasSecondSource()
const {
return ((data & 0x00FF0000) != 0x00FF0000); }
106 constexpr void setToNull() { data = 0xFFFFFFFF; }
108 [[nodiscard]]
constexpr bool isNull()
const {
return (data == 0xFFFFFFFF); }