commit 1b587b45ef382dec2916849922abe407d2bc5582
parent 8e71149a128be41bbd7a143970ac227f8dbb868f
Author: Tal Aviram <me@talaviram.com>
Date: Wed, 28 Jul 2021 08:26:32 +0300
controller - saving Multi patches.
Diffstat:
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/source/jucePlugin/VirusController.cpp b/source/jucePlugin/VirusController.cpp
@@ -66,11 +66,21 @@ namespace Virus
void Controller::parseMulti(const SysEx &msg)
{
- uint8_t bankNum, progNum, data256, checksum;
assert(msg.size() - kHeaderWithMsgCodeLen > 0);
constexpr auto startPos = kHeaderWithMsgCodeLen + 4;
auto progName = parseAsciiText(msg, startPos + 1);
- DBG(progName);
+
+ MultiPatch patch;
+ patch.bankNumber = msg[startPos];
+ patch.progNumber = msg[startPos + 1];
+ copyData(msg, startPos + 2, patch.data);
+ m_multis[patch.progNumber] = patch;
+ }
+
+ void Controller::copyData(const SysEx &src, int startPos, uint8_t *dst)
+ {
+ for (auto i = 0; i < kDataSizeInBytes; i++)
+ dst[i] = src[startPos + i];
}
void Controller::parseData(const SysEx &msg, const size_t startPos)
diff --git a/source/jucePlugin/VirusController.h b/source/jucePlugin/VirusController.h
@@ -20,6 +20,20 @@ namespace Virus
void printMessage(const SysEx &) const;
private:
+ static constexpr size_t kDataSizeInBytes = 256; // same for multi and single
+
+ struct MultiPatch
+ {
+ uint8_t bankNumber;
+ uint8_t progNumber;
+ uint8_t data[kDataSizeInBytes];
+ };
+
+ MultiPatch m_multis[128]; // RAM has 128 Multi 'snapshots'
+
+ // unchecked copy for patch data bytes
+ static inline void copyData(const SysEx &src, int startPos, uint8_t *dst);
+
juce::String parseAsciiText(const SysEx &, int startPos);
void parseMessage(const SysEx &);
void parseSingle(const SysEx &);