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 83b07d2ad8f4821e38c84cc8cb9d5b827dcd790d
parent ccaca06686ae6a30b7d148907865fa24e23d4d19
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Sun, 29 Sep 2024 01:09:25 +0200

create func to interpolate two wavetables, needed in the future for dsp preview and maybe vor visualization

Diffstat:
Msource/xtLib/xtState.cpp | 21+++++++++++++++++++++
Msource/xtLib/xtState.h | 1+
2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/source/xtLib/xtState.cpp b/source/xtLib/xtState.cpp @@ -760,6 +760,27 @@ namespace xt return sysex; } + WaveData State::createinterpolatedTable(const WaveData& _a, const WaveData& _b, uint16_t _indexA, uint16_t _indexB, uint16_t _indexTarget) + { + assert(_indexB > _indexA); + assert(_indexTarget >= _indexA && _indexTarget <= _indexB); + + xt::WaveData result; + + const auto indexDelta = _indexB - _indexA; + const auto targetDelta = _indexTarget - _indexA; + + for(size_t i=0; i<_a.size(); ++i) + { + auto d = _b[i] - _a[i]; + d *= targetDelta; + d /= indexDelta; + d += _a[i]; + result[i] = static_cast<int8_t>(d); + } + return result; + } + void State::parseTableData(TableData& _table, const SysEx& _sysex) { constexpr uint32_t off = 7; diff --git a/source/xtLib/xtState.h b/source/xtLib/xtState.h @@ -86,6 +86,7 @@ namespace xt static void parseWaveData(WaveData& _wave, const SysEx& _sysex); static SysEx createWaveData(const WaveData& _wave, uint16_t _waveIndex, bool _preview); + static WaveData createinterpolatedTable(const WaveData& _a, const WaveData& _b, uint16_t _indexA, uint16_t _indexB, uint16_t _indexTarget); static void parseTableData(TableData& _table, const SysEx& _sysex); static SysEx createTableData(const TableData& _table, uint32_t _tableIndex, bool _preview);