commit 680717a2dae857aab42ed078f0a4b7a53d9c5f09
parent 8b1f95e08b283c7fe7f710f1578c4ccc61938ff4
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Tue, 22 Oct 2024 12:36:33 +0200
add workaround to fix device not picking up edited wave if the wave is part of the table currently used for a part
Diffstat:
2 files changed, 53 insertions(+), 1 deletion(-)
diff --git a/source/xtJucePlugin/weData.cpp b/source/xtJucePlugin/weData.cpp
@@ -239,6 +239,57 @@ namespace xtJucePlugin
return false;
const auto sysex = xt::State::createWaveData(*wave, _id.rawId(), false);
m_controller.sendSysEx(sysex);
+
+ // if a wave is edited that is part of the current wavetable of a patch, that table has to be sent again too because the device doesn't update otherwise
+ std::set<xt::TableId> dirtyTableIds;
+
+ auto checkTableForPart = [this, _id, &dirtyTableIds](uint8_t p)
+ {
+ const auto* param = m_controller.getParameter("Wave", p);
+ const auto tableId = xt::TableId(static_cast<uint16_t>(param->getUnnormalizedValue()));
+ const auto& table = getTable(tableId);
+ if(!table)
+ return;
+ const auto& t = *table;
+ for (auto waveId : t)
+ {
+ if(waveId == _id)
+ {
+ dirtyTableIds.insert(tableId);
+ break;
+ }
+ }
+ };
+
+ if(m_controller.isMultiMode())
+ {
+ for(uint8_t p=0; p<m_controller.getPartCount(); ++p)
+ checkTableForPart(p);
+ }
+ else
+ {
+ checkTableForPart(m_controller.getCurrentPart());
+ }
+
+ juce::Timer::callAfterDelay(1000, [this, dirtyTableIds]
+ {
+ for (const auto& id : dirtyTableIds)
+ {
+ // this is super annyoing. Some kind of dirty mechanism seems to prevent that the wavetable is rebuilt even if we send it again
+ // So far the only way to prevent that is to send the table twice, once with another starting wave and then again with the correct
+ // one
+ const auto waveId = getWaveIndex(id, xt::TableIndex(0));
+ const_cast<WaveEditorData*>(this)->setTableWave(id, xt::TableIndex(0), xt::WaveId(waveId.rawId() > 1000 ? 1000 : 1001));
+ sendTableToDevice(id);
+
+ juce::Timer::callAfterDelay(1000, [this, id, waveId]
+ {
+ const_cast<WaveEditorData*>(this)->setTableWave(id, xt::TableIndex(0), waveId);
+ sendTableToDevice(id);
+ });
+ }
+ });
+
return true;
}
diff --git a/source/xtJucePlugin/xtController.h b/source/xtJucePlugin/xtController.h
@@ -91,11 +91,12 @@ namespace xtJucePlugin
bool requestWave(uint32_t _number) const;
bool requestTable(uint32_t _number) const;
+ uint8_t getPartCount() const override;
+
private:
void selectPreset(int _offset);
void onStateLoaded() override;
- uint8_t getPartCount() const override;
void parseSingle(const pluginLib::SysEx& _msg, const pluginLib::MidiPacket::Data& _data, const pluginLib::MidiPacket::ParamValues& _params);
void parseMulti(const pluginLib::SysEx& _msg, const pluginLib::MidiPacket::Data& _data, const pluginLib::MidiPacket::ParamValues& _params) const;