commit 9ae074e929802643bcb8f221ccf41c653dc64030
parent 8565ecc6be6641b490065fb17a425f901e65f5fe
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Thu, 30 Dec 2021 22:47:14 +0100
fix bank loading feature only loaded bank to UI but not to synth
Diffstat:
1 file changed, 53 insertions(+), 47 deletions(-)
diff --git a/source/jucePlugin/PluginEditor.cpp b/source/jucePlugin/PluginEditor.cpp
@@ -263,63 +263,70 @@ void AudioPluginAudioProcessorEditor::loadFile() {
m_previousPath.isEmpty() ? juce::File::getSpecialLocation(juce::File::currentApplicationFile).getParentDirectory() : m_previousPath,
"*.syx,*.mid,*.midi",
true);
- const bool result = chooser.browseForFileToOpen();
- if (result)
+
+ if (!chooser.browseForFileToOpen())
+ return;
+ bool sentData = false;
+ const auto result = chooser.getResult();
+ m_previousPath = result.getParentDirectory().getFullPathName();
+ const auto ext = result.getFileExtension().toLowerCase();
+ if (ext == ".syx")
{
- const auto result = chooser.getResult();
- m_previousPath = result.getParentDirectory().getFullPathName();
- const auto ext = result.getFileExtension().toLowerCase();
- if (ext == ".syx")
+ juce::MemoryBlock data;
+ result.loadFileAsData(data);
+ for (auto it = data.begin(); it != data.end(); it += 267)
{
- juce::MemoryBlock data;
- result.loadFileAsData(data);
- for (auto it = data.begin(); it != data.end(); it += 267)
+ if ((it + 267) < data.end())
{
- if ((it + 267) < data.end())
- {
- processorRef.getController().parseMessage(Virus::SysEx(it, it + 267));
- }
+ processorRef.getController().sendSysEx(Virus::SysEx(it, it + 267));
+ sentData = true;
}
- m_btLoadFile.setButtonText("Loaded");
}
- else if (ext == ".mid" || ext == ".midi")
+ m_btLoadFile.setButtonText("Loaded");
+ }
+ else if (ext == ".mid" || ext == ".midi")
+ {
+ juce::MemoryBlock data;
+ if (!result.loadFileAsData(data))
{
- juce::MemoryBlock data;
- if (!result.loadFileAsData(data))
- {
- return;
- }
- const uint8_t *ptr = (uint8_t *)data.getData();
- const auto end = ptr + data.getSize();
+ return;
+ }
+ const uint8_t *ptr = (uint8_t *)data.getData();
+ const auto end = ptr + data.getSize();
- for (auto it = ptr; it < end; it += 1)
+ for (auto it = ptr; it < end; it += 1)
+ {
+ if ((uint8_t)*it == (uint8_t)0xf0 && (it+267) < end)
{
- if ((uint8_t)*it == (uint8_t)0xf0 && (it+267) < end)
+ if ((uint8_t) *(it + 1) == (uint8_t)0x00)
{
- if ((uint8_t) *(it + 1) == (uint8_t)0x00)
- {
- auto syx = Virus::SysEx(it, it + 267);
- syx[7] = 0x01; // force to bank a
- syx[266] = 0xf7;
- processorRef.getController().parseMessage(syx);
-
- it += 266;
- }
- else // some midi files have two bytes after the 0xf0
+ auto syx = Virus::SysEx(it, it + 267);
+ syx[7] = 0x01; // force to bank a
+ syx[266] = 0xf7;
+
+ processorRef.getController().sendSysEx(syx);
+
+ it += 266;
+ }
+ else // some midi files have two bytes after the 0xf0
+ {
+ auto syx = Virus::SysEx();
+ syx.push_back(0xf0);
+ for (auto i = it + 3; i < it + 3 + 266; i++)
{
- auto syx = Virus::SysEx();
- syx.push_back(0xf0);
- for (auto i = it + 3; i < it + 3 + 266; i++)
- {
- syx.push_back((uint8_t)*i);
- }
- syx[7] = 0x01; // force to bank a
- syx[266] = 0xf7;
- processorRef.getController().parseMessage(syx);
- it += 266;
+ syx.push_back((uint8_t)*i);
}
+ syx[7] = 0x01; // force to bank a
+ syx[266] = 0xf7;
+ processorRef.getController().sendSysEx(syx);
+ it += 266;
}
+
+ sentData = true;
}
}
- }
-}
-\ No newline at end of file
+ }
+
+ if (sentData)
+ processorRef.getController().onStateLoaded();
+}