commit 8b6050411b0eb323885e7f53e3b29967a0b7e056
parent 3da1b7f60012b036e4e49e4b92c71c0354b2ee09
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Thu, 24 Feb 2022 00:03:13 +0100
fix presets not always loaded correctly
Diffstat:
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/source/virusLib/microcontroller.cpp b/source/virusLib/microcontroller.cpp
@@ -125,7 +125,7 @@ bool Microcontroller::sendPreset(const uint8_t program, const std::vector<TWord>
{
std::lock_guard lock(m_mutex);
- if(m_hdi08.hasDataToSend() || needsToWaitForHostBits(0,1))
+ if(m_loadingState || m_hdi08.hasDataToSend() || needsToWaitForHostBits(0,1))
{
// if we write a multi or a multi mode single, remove a pending single for single mode
// If we write a single-mode single, remove all multi-related pending writes
@@ -368,7 +368,7 @@ bool Microcontroller::sendSysex(const std::vector<uint8_t>& _data, bool _cancelI
auto buildGlobalResponses = [&]()
{
- for (auto globalParam : g_pageC_global)
+ for (const auto globalParam : g_pageC_global)
buildGlobalResponse(globalParam);
};
@@ -851,6 +851,9 @@ bool Microcontroller::setState(const std::vector<unsigned char>& _state, const S
if(events.empty())
return false;
+ // delay all preset loads until everything is loaded
+ m_loadingState = true;
+
std::vector<SMidiEvent> unusedResponses;
for (const auto& event : events)
@@ -859,6 +862,8 @@ bool Microcontroller::setState(const std::vector<unsigned char>& _state, const S
unusedResponses.clear();
}
+ m_loadingState = false;
+
return true;
}
diff --git a/source/virusLib/microcontroller.h b/source/virusLib/microcontroller.h
@@ -92,6 +92,7 @@ private:
dsp56k::RingBuffer<synthLib::SMidiEvent, 1024, false> m_pendingMidiEvents;
mutable std::recursive_mutex m_mutex;
+ bool m_loadingState = false;
};
}