commit 45ca552e613edb8b018d753fe277ae9ae73dc90d
parent cff75be1cb6232f1b4a6b900f5c846d63416e7f4
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Sun, 29 Sep 2024 12:25:29 +0200
cache rom waves & wave tables on disk
Diffstat:
5 files changed, 46 insertions(+), 8 deletions(-)
diff --git a/source/xtJucePlugin/weData.cpp b/source/xtJucePlugin/weData.cpp
@@ -1,12 +1,14 @@
#include "weData.h"
#include "xtController.h"
-#include "dsp56kEmu/logging.h"
+
+#include "synthLib/os.h"
+
#include "xtLib/xtState.h"
namespace xtJucePlugin
{
- WaveEditorData::WaveEditorData(Controller& _controller) : m_controller(_controller)
+ WaveEditorData::WaveEditorData(Controller& _controller, std::string _cacheDir) : m_controller(_controller), m_cacheDir(std::move(_cacheDir))
{
}
@@ -20,7 +22,6 @@ namespace xtJucePlugin
const auto id = xt::TableId(i);
if(!m_tables[i] && !isAlgorithmicTable(id))
{
- LOG("Request table " << i);
requestTable(id);
return;
}
@@ -44,6 +45,8 @@ namespace xtJucePlugin
return;
}
}
+
+ onAllDataReceived();
}
void WaveEditorData::onReceiveWave(const pluginLib::MidiPacket::Data& _data, const std::vector<uint8_t>& _msg)
@@ -253,6 +256,36 @@ namespace xtJucePlugin
return true;
}
+ void WaveEditorData::onAllDataReceived() const
+ {
+ const auto romWaves = synthLib::validatePath(m_cacheDir) + "romWaves.syx";
+
+ std::vector<uint8_t> data;
+
+ for(uint16_t i=0; i<static_cast<uint16_t>(m_romWaves.size()); ++i)
+ {
+ auto& romWave = m_romWaves[i];
+ assert(romWave);
+ if(!romWave)
+ continue;
+ auto sysex = xt::State::createWaveData(*romWave, i, false);
+ data.insert(data.end(), sysex.begin(), sysex.end());
+ }
+
+ assert(xt::Wave::g_firstRamTableIndex < m_tables.size());
+
+ for(uint16_t i=0; i<xt::Wave::g_firstRamTableIndex; ++i)
+ {
+ auto& table = m_tables[i];
+ assert(table || isAlgorithmicTable(xt::TableId(i)));
+ if(!table)
+ continue;
+ auto sysex = xt::State::createTableData(*table, i, false);
+ data.insert(data.end(), sysex.begin(), sysex.end());
+ }
+ synthLib::writeFile(romWaves, data);
+ }
+
bool WaveEditorData::isAlgorithmicTable(const xt::TableId _index)
{
for (const uint32_t i : xt::Wave::g_algorithmicWavetables)
diff --git a/source/xtJucePlugin/weData.h b/source/xtJucePlugin/weData.h
@@ -2,7 +2,6 @@
#include <cstdint>
#include <optional>
-#include <limits>
#include <vector>
#include "weTypes.h"
@@ -22,7 +21,7 @@ namespace xtJucePlugin
pluginLib::Event<xt::WaveId> onWaveChanged;
pluginLib::Event<xt::TableId> onTableChanged;
- WaveEditorData(Controller& _controller);
+ WaveEditorData(Controller& _controller, std::string _cacheDir);
void requestData();
@@ -59,7 +58,10 @@ namespace xtJucePlugin
bool requestWave(xt::WaveId _index);
bool requestTable(xt::TableId _index);
+ void onAllDataReceived() const;
+
Controller& m_controller;
+ const std::string m_cacheDir;
xt::WaveId m_currentWaveRequestIndex = g_invalidWaveIndex;
xt::TableId m_currentTableRequestIndex = g_invalidTableIndex;
diff --git a/source/xtJucePlugin/xtEditor.cpp b/source/xtJucePlugin/xtEditor.cpp
@@ -182,7 +182,10 @@ namespace xtJucePlugin
{
if(_object.getName() == "waveEditorContainer")
{
- m_waveEditor = new WaveEditor(*this);
+ const auto configOptions = getProcessor().getConfigOptions();
+ const auto dir = configOptions.getDefaultFile().getParentDirectory();
+
+ m_waveEditor = new WaveEditor(*this, dir);
getXtController().setWaveEditor(m_waveEditor);
return m_waveEditor;
}
diff --git a/source/xtJucePlugin/xtWaveEditor.cpp b/source/xtJucePlugin/xtWaveEditor.cpp
@@ -14,7 +14,7 @@
namespace xtJucePlugin
{
- WaveEditor::WaveEditor(Editor& _editor) : ComponentMovementWatcher(this), m_editor(_editor), m_data(_editor.getXtController())
+ WaveEditor::WaveEditor(Editor& _editor, const juce::File& _cacheDir) : ComponentMovementWatcher(this), m_editor(_editor), m_data(_editor.getXtController(), _cacheDir.getFullPathName().toStdString())
{
addComponentListener(this);
diff --git a/source/xtJucePlugin/xtWaveEditor.h b/source/xtJucePlugin/xtWaveEditor.h
@@ -23,7 +23,7 @@ namespace xtJucePlugin
class WaveEditor : public juce::Component, juce::ComponentMovementWatcher
{
public:
- explicit WaveEditor(Editor& _editor);
+ explicit WaveEditor(Editor& _editor, const juce::File& _cacheDir);
WaveEditor() = delete;
WaveEditor(const WaveEditor&) = delete;
WaveEditor(WaveEditor&&) = delete;