gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

commit 41648626d13fc3df6342d51e54449b39ae924547
parent 0214b05e0e91852a9bb4e37ffc48d98c586ed8d2
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Thu,  1 Aug 2024 16:24:33 +0200

tool functions to modify dumps

Diffstat:
Msource/nord/n2x/n2xLib/n2xstate.cpp | 10++++++++++
Msource/nord/n2x/n2xLib/n2xstate.h | 43+++++++++++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/source/nord/n2x/n2xLib/n2xstate.cpp b/source/nord/n2x/n2xLib/n2xstate.cpp @@ -297,6 +297,16 @@ namespace n2x assert(i + g_sysexFooterSize == g_multiDumpSize); } + uint32_t State::getOffsetInSingleDump(const SingleParam _param) + { + return g_sysexHeaderSize + (_param<<1); + } + + uint32_t State::getOffsetInMultiDump(const MultiParam _param) + { + return g_sysexHeaderSize + g_singleDataSize * 4 + (_param<<1); + } + void State::send(const synthLib::SMidiEvent& _e) const { if(_e.source == synthLib::MidiEventSource::Plugin) diff --git a/source/nord/n2x/n2xLib/n2xstate.h b/source/nord/n2x/n2xLib/n2xstate.h @@ -35,6 +35,49 @@ namespace n2x template<size_t Size> static void createHeader(std::array<uint8_t, Size>& _buffer, uint8_t _msgType, uint8_t _msgSpec); + static uint32_t getOffsetInSingleDump(SingleParam _param); + static uint32_t getOffsetInMultiDump(MultiParam _param); + + uint8_t getPartMidiChannel(const uint8_t _part) const + { + return getPartMidiChannel(m_multi, _part); + } + + template<typename TDump> static uint8_t getPartMidiChannel(const TDump& _dump, const uint8_t _part) + { + return getMultiParam(_dump, SlotAMidiChannel, _part); + } + + uint8_t getMultiParam(const MultiParam _param, const uint8_t _part) const + { + return getMultiParam(m_multi, _param, _part); + } + + template<typename TDump> static uint8_t getMultiParam(const TDump& _dump, const MultiParam _param, const uint8_t _part) + { + const auto off = getOffsetInMultiDump(_param) + (_part << 2); + + return unpackNibbles<TDump>(_dump, off); + } + + template<typename TDump> static uint8_t getSingleParam(const TDump& _dump, const SingleParam _param, const uint8_t _part) + { + const auto off = getOffsetInSingleDump(_param) + (_part << 2); + + return unpackNibbles<TDump>(_dump, off); + } + + template<typename TDump> static uint8_t unpackNibbles(const TDump& _dump, uint32_t _off) + { + return static_cast<uint8_t>((_dump[_off] & 0xf) | (_dump[_off + 1] << 8)); + } + + template<typename TDump> static void packNibbles(TDump& _dump, uint32_t _off, const uint8_t _value) + { + _dump[_off ] = _value & 0x0f; + _dump[_off+1] = _value >> 8; + } + private: template<size_t Size> bool receive(const std::array<uint8_t, Size>& _data) {