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 35befc521af6a8ee6430c28f893ea83553b38055
parent 6c655c376d6cd8a96b9154c6afcaaf7a0750135f
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Thu, 27 Feb 2025 22:47:28 +0100

create getTableId and getWaveId helper functions / remove duplicated code

Diffstat:
Msource/xtLib/xtState.cpp | 24+++++++++++++++++-------
Msource/xtLib/xtState.h | 3+++
2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/source/xtLib/xtState.cpp b/source/xtLib/xtState.cpp @@ -400,7 +400,7 @@ namespace xt bool State::parseWaveDump(const SysEx& _data) { - const auto idx = (static_cast<uint32_t>(_data[IdxWaveIndexH]) << 7u) | static_cast<uint32_t>(_data[IdxWaveIndexL]); + const auto idx = getWaveId(_data).rawId(); if(idx >= m_waves.size()) return false; @@ -413,7 +413,7 @@ namespace xt bool State::parseTableDump(const SysEx& _data) { - const auto idx = (static_cast<uint32_t>(_data[IdxWaveIndexH]) << 7u) | static_cast<uint32_t>(_data[IdxWaveIndexL]); + const auto idx = getTableId(_data).rawId(); if(idx >= m_tables.size()) return false; @@ -637,9 +637,9 @@ namespace xt bool State::getWave(Responses& _responses, const SysEx& _data) { - const auto idx = static_cast<uint16_t>((static_cast<uint16_t>(_data[IdxWaveIndexH]) << 7u) | static_cast<uint16_t>(_data[IdxWaveIndexL])); + const auto idx = getWaveId(_data); - auto* w = getWave(WaveId(idx)); + auto* w = getWave(idx); if(!w || !isValid(*w)) return false; _responses.emplace_back(w->begin(), w->end()); @@ -656,9 +656,9 @@ namespace xt bool State::getTable(Responses& _responses, const SysEx& _data) { - const auto idx = static_cast<uint16_t>((static_cast<uint16_t>(_data[IdxWaveIndexH]) << 7u) | static_cast<uint16_t>(_data[IdxWaveIndexL])); + const auto idx = getTableId(_data); - auto* t = getTable(TableId(idx)); + auto* t = getTable(idx); if(!t || !isValid(*t)) return false; _responses.emplace_back(t->begin(), t->end()); @@ -760,6 +760,16 @@ namespace xt return static_cast<SysexCommand>(_data[wLib::IdxCommand]); } + TableId State::getTableId(const SysEx& _data) + { + return TableId(static_cast<uint16_t>((_data[IdxWaveIndexH] << 7) | _data[IdxWaveIndexL])); + } + + WaveId State::getWaveId(const SysEx& _data) + { + return WaveId(static_cast<uint16_t>((_data[IdxWaveIndexH] << 7) | _data[IdxWaveIndexL])); + } + void State::forwardToDevice(const SysEx& _data) { if(m_sender != Origin::External) @@ -774,7 +784,7 @@ namespace xt // A wave that is edited that is part of a table that is used in one of the current singles is not updated // The workaround is to send a table dump with different waves and then the one with the correct waves { - const auto waveId = WaveId(static_cast<uint16_t>((_data[IdxWaveIndexH] << 7) | _data[IdxWaveIndexL])); + const auto waveId = getWaveId(_data); std::set<TableId> dirtyTables; diff --git a/source/xtLib/xtState.h b/source/xtLib/xtState.h @@ -110,6 +110,9 @@ namespace xt static SysexCommand getCommand(const SysEx& _data); + static TableId getTableId(const SysEx& _data); + static WaveId getWaveId(const SysEx& _data); + template<size_t Size> static bool append(SysEx& _dst, const std::array<uint8_t, Size>& _src, uint32_t _checksumStartIndex) { if(!isValid(_src))