commit 998e884a86903d86a6ec678341c45ecfe04dda19
parent ddce56ac3430fcdcfe9c637805f08910738c6112
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Fri, 2 Aug 2024 17:39:47 +0200
refactor
Diffstat:
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/source/nord/n2x/n2xLib/n2xstate.cpp b/source/nord/n2x/n2xLib/n2xstate.cpp
@@ -317,26 +317,16 @@ namespace n2x
}
}
- bool State::changeSingleParameter(const uint8_t _part, const SingleParam _parameter, uint8_t _value)
+ bool State::changeSingleParameter(const uint8_t _part, const SingleParam _parameter, const uint8_t _value)
{
if(_part >= m_singles.size())
return false;
- const auto off = getOffsetInSingleDump(_parameter);
- const auto current = unpackNibbles(m_singles[_part], off);
- if(current == _value)
- return false;
- packNibbles(m_singles[_part], off, _value);
- return true;
+ return changeDumpParameter(m_singles[_part], getOffsetInSingleDump(_parameter), _value);
}
bool State::changeMultiParameter(const MultiParam _parameter, const uint8_t _value)
{
- const auto off = getOffsetInMultiDump(_parameter);
- const auto current = unpackNibbles(m_multi, off);
- if(current == _value)
- return false;
- packNibbles(m_multi, off, _value);
- return true;
+ return changeDumpParameter(m_multi, getOffsetInMultiDump(_parameter), _value);
}
void State::updateMultiFromSingles()
diff --git a/source/nord/n2x/n2xLib/n2xstate.h b/source/nord/n2x/n2xLib/n2xstate.h
@@ -31,6 +31,16 @@ namespace n2x
bool changeSingleParameter(uint8_t _part, SingleParam _parameter, uint8_t _value);
bool changeMultiParameter(MultiParam _parameter, uint8_t _value);
+ template<typename TDump>
+ bool changeDumpParameter(TDump& _dump, uint32_t _offset, uint8_t _value)
+ {
+ const auto current = unpackNibbles(_dump, _offset);
+ if(current == _value)
+ return false;
+ packNibbles(_dump, _offset, _value);
+ return true;
+ }
+
void updateMultiFromSingles();
const auto& getMulti() const { return m_multi; }