commit 5957419201b85a704b8336d720874c1e036d7cba
parent 830390980ec6f060a009d9efd73e995e7775724c
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Mon, 10 Mar 2025 21:10:35 +0100
do not access table wave ids directly, add & use tool function instead as it is not a 1:1 relation for speech tables
Diffstat:
5 files changed, 58 insertions(+), 10 deletions(-)
diff --git a/source/xtJucePlugin/weData.cpp b/source/xtJucePlugin/weData.cpp
@@ -264,7 +264,9 @@ namespace xtJucePlugin
auto& t = *table;
- for (const auto waveId : t)
+ auto waves = xt::State::getWavesForTable(t);
+
+ for (const auto waveId : waves)
{
if(!xt::wave::isValidWaveIndex(waveId.rawId()))
continue;
diff --git a/source/xtJucePlugin/xtController.cpp b/source/xtJucePlugin/xtController.cpp
@@ -420,7 +420,8 @@ namespace xtJucePlugin
if (xt::State::parseTableData(table, _msg))
{
- for (const auto& wave : table)
+ auto waves = xt::State::getWavesForTable(table);
+ for (const auto& wave : waves)
{
if (!xt::wave::isReadOnly(wave))
requestWave(wave.rawId());
diff --git a/source/xtJucePlugin/xtPatchManager.cpp b/source/xtJucePlugin/xtPatchManager.cpp
@@ -377,7 +377,9 @@ namespace xtJucePlugin
if (!xt::State::parseTableData(table, itTable->second))
return;
- for (const auto waveId : table)
+ const auto waves = xt::State::getWavesForTable(table);
+
+ for (const auto waveId : waves)
{
if(!xt::wave::isValidWaveIndex(waveId.rawId()))
continue;
diff --git a/source/xtLib/xtState.cpp b/source/xtLib/xtState.cpp
@@ -89,7 +89,9 @@ namespace xt
TableData table;
parseTableData(table, {t.begin(), t.end()});
- for (const auto& waveId : table)
+ auto tableWaves = getWavesForTable(table);
+
+ for (const auto& waveId : tableWaves)
{
if(wave::isReadOnly(waveId))
continue;
@@ -789,6 +791,16 @@ namespace xt
return WaveId(static_cast<uint16_t>((_data[IdxWaveIndexH] << 7) | _data[IdxWaveIndexL]));
}
+ bool State::isSpeech(const TableData& _table)
+ {
+ return _table[0].rawId() == 0xdead && _table[1].rawId() == 0xbeef;
+ }
+
+ bool State::isUpaw(const TableData& _table)
+ {
+ return _table[0].rawId() == 0x12de && _table[1].rawId() == 0xc0de;
+ }
+
void State::forwardToDevice(const SysEx& _data)
{
if(m_sender != Origin::External)
@@ -822,8 +834,9 @@ namespace xt
TableData table;
if (!parseTableData(table, { t.begin(), t.end() }))
return false;
- auto it = std::find(table.begin(), table.end(), waveId);
- if (it == table.end())
+ auto waves = getWavesForTable(table);
+ const auto it = std::find(waves.begin(), waves.end(), waveId);
+ if (it == waves.end())
return false;
dirtyTables.insert(_id);
return true;
@@ -850,9 +863,10 @@ namespace xt
TableData table;
parseTableData(table, originalTableSysex);
+ auto waves = getWavesForTable(table);
// modify table to use a different wave
- for (auto& idx : table)
+ for (auto& idx : waves)
{
if (idx == waveId)
idx = WaveId(waveId.rawId() > 1000 ? 1000 : 1001);
@@ -1163,20 +1177,44 @@ namespace xt
extractTableDataFromSysEx(_table, _sysex, 6);
- if (_table[0].rawId() == 0xdead && _table[1].rawId() == 0xbeef)
+ if (isSpeech(_table))
{
_table[2] = WaveId(_table[2].rawId() + wave::g_firstRamWaveIndex - Mw1::g_firstRamWaveIndex);
}
else
{
for(auto & t : _table)
- {
t = WaveId(t.rawId() + wave::g_firstRamWaveIndex - Mw1::g_firstRamWaveIndex);
- }
}
return true;
}
+ std::vector<WaveId> State::getWavesForTable(const TableData& _table)
+ {
+ std::vector<WaveId> waves;
+
+ if (isSpeech(_table))
+ {
+ const auto startWaveId = _table[2];
+
+ waves.reserve(8);
+ for (uint16_t i=0; i<8; ++i)
+ waves.emplace_back(startWaveId.rawId() + i);
+ }
+ else if (isUpaw(_table))
+ {
+ assert(false && "add support");
+ }
+ else
+ {
+ waves.reserve(_table.size());
+ for (const auto& w : _table)
+ waves.push_back(w);
+ }
+
+ return waves;
+ }
+
SysEx State::createTableData(const TableData& _table, const uint32_t _tableIndex, const bool _preview)
{
const auto hh = static_cast<uint8_t>(_tableIndex >> 7);
diff --git a/source/xtLib/xtState.h b/source/xtLib/xtState.h
@@ -107,6 +107,8 @@ namespace xt
static bool parseTableData(TableData& _table, const SysEx& _sysex);
static bool parseMw1TableData(TableData& _table, const SysEx& _sysex);
+ static std::vector<WaveId> getWavesForTable(const TableData& _table);
+
static SysEx createTableData(const TableData& _table, uint32_t _tableIndex, bool _preview);
static SysEx createCombinedPatch(const std::vector<SysEx>& _dumps);
@@ -117,6 +119,9 @@ namespace xt
static TableId getTableId(const SysEx& _data);
static WaveId getWaveId(const SysEx& _data);
+ static bool isSpeech(const TableData& _table);
+ static bool isUpaw(const TableData& _table);
+
template<size_t Size> static bool append(SysEx& _dst, const std::array<uint8_t, Size>& _src, uint32_t _checksumStartIndex)
{
if(!isValid(_src))