commit 00c5ff9c6432127875f6eb5e4bb94d87423bcdae
parent fc1e7395b871195656774f7e2fdad1b9dda204b1
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Thu, 3 Oct 2024 17:11:53 +0200
send changes to wave / control table to device
Diffstat:
5 files changed, 41 insertions(+), 4 deletions(-)
diff --git a/source/xtJucePlugin/weControlTreeItem.cpp b/source/xtJucePlugin/weControlTreeItem.cpp
@@ -88,12 +88,16 @@ namespace xtJucePlugin
// if the source is the control list, we swap two entries. if the source is the wave list, we add a new wave
if(waveDesc->source == WaveDescSource::ControlTableList)
{
- data.swapTableEntries(m_table, m_index, waveDesc->tableIndex);
- setSelected(true, true, juce::dontSendNotification);
+ if(data.swapTableEntries(m_table, m_index, waveDesc->tableIndex))
+ {
+ setSelected(true, true, juce::dontSendNotification);
+ data.sendTableToDevice(m_table);
+ }
}
else if(waveDesc->source == WaveDescSource::WaveList)
{
- data.setTableWave(m_table, m_index, waveDesc->waveId);
+ if(data.setTableWave(m_table, m_index, waveDesc->waveId))
+ data.sendTableToDevice(m_table);
}
}
diff --git a/source/xtJucePlugin/weData.cpp b/source/xtJucePlugin/weData.cpp
@@ -215,6 +215,30 @@ namespace xtJucePlugin
return true;
}
+ bool WaveEditorData::sendTableToDevice(const xt::TableId _id) const
+ {
+ const auto index = _id.rawId();
+ if(index >= m_tables.size())
+ return false;
+ auto& table = m_tables[index];
+ if(!table)
+ return false;
+ auto& t = *table;
+ const auto sysex = xt::State::createTableData(t, index, false);
+ m_controller.sendSysEx(sysex);
+ return true;
+ }
+
+ bool WaveEditorData::sendWaveToDevice(const xt::WaveId _id) const
+ {
+ const auto wave = getWave(_id);
+ if(!wave)
+ return false;
+ const auto sysex = xt::State::createWaveData(*wave, _id.rawId(), false);
+ m_controller.sendSysEx(sysex);
+ return true;
+ }
+
bool WaveEditorData::requestWave(const xt::WaveId _index)
{
if(isWaitingForData())
diff --git a/source/xtJucePlugin/weData.h b/source/xtJucePlugin/weData.h
@@ -52,6 +52,9 @@ namespace xtJucePlugin
bool setWave(xt::WaveId _id, const xt::WaveData& _data);
bool setTable(xt::TableId _index, const xt::TableData& _data);
+ bool sendTableToDevice(xt::TableId _id) const;
+ bool sendWaveToDevice(xt::WaveId _id) const;
+
private:
bool requestWave(xt::WaveId _index);
bool requestTable(xt::TableId _index);
diff --git a/source/xtJucePlugin/weTablesTreeItem.cpp b/source/xtJucePlugin/weTablesTreeItem.cpp
@@ -63,6 +63,7 @@ namespace xtJucePlugin
{
setSelected(true, true, juce::dontSendNotification);
m_editor.setSelectedTable(m_index);
+ data.sendTableToDevice(m_index);
}
}
diff --git a/source/xtJucePlugin/weWaveTreeItem.cpp b/source/xtJucePlugin/weWaveTreeItem.cpp
@@ -92,7 +92,12 @@ namespace xtJucePlugin
if(!waveDesc)
return;
auto& data = m_editor.getData();
- data.copyWave(m_waveIndex, waveDesc->waveId);
+
+ if(data.copyWave(m_waveIndex, waveDesc->waveId))
+ {
+ setSelected(true, true, juce::dontSendNotification);
+ data.sendWaveToDevice(m_waveIndex);
+ }
}
void WaveTreeItem::onWaveChanged(const xt::WaveId _index) const