commit dfa788412700062c111856bb56e8a940e0faac50
parent dda745896a3f0974a7a423ad2908daccea5edac6
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Fri, 16 Jul 2021 01:41:30 +0200
support plugin state saving for current program only, too
Diffstat:
3 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/source/jucePlugin/PluginProcessor.cpp b/source/jucePlugin/PluginProcessor.cpp
@@ -242,14 +242,19 @@ void AudioPluginAudioProcessor::setStateInformation (const void* data, int sizeI
{
// You should use this method to restore your parameters from this memory block,
// whose contents will have been created by the getStateInformation() call.
+ setState(data, sizeInBytes);
+}
- if(sizeInBytes < 1)
- return;
-
+void AudioPluginAudioProcessor::getCurrentProgramStateInformation(juce::MemoryBlock& destData)
+{
std::vector<uint8_t> state;
- state.resize(sizeInBytes);
- memcpy(&state[0], data, sizeInBytes);
- m_plugin.setState(state);
+ m_plugin.getState(state, synthLib::StateTypeCurrentProgram);
+ destData.append(&state[0], state.size());
+}
+
+void AudioPluginAudioProcessor::setCurrentProgramStateInformation(const void* data, int sizeInBytes)
+{
+ setState(data, sizeInBytes);
}
void AudioPluginAudioProcessor::getLastMidiOut(std::vector<synthLib::SMidiEvent>& dst)
@@ -264,6 +269,17 @@ void AudioPluginAudioProcessor::addMidiEvent(const synthLib::SMidiEvent& ev)
m_plugin.addMidiEvent(ev);
}
+void AudioPluginAudioProcessor::setState(const void* _data, size_t _sizeInBytes)
+{
+ if(_sizeInBytes < 1)
+ return;
+
+ std::vector<uint8_t> state;
+ state.resize(_sizeInBytes);
+ memcpy(&state[0], _data, _sizeInBytes);
+ m_plugin.setState(state);
+}
+
//==============================================================================
// This creates new instances of the plugin..
juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter()
diff --git a/source/jucePlugin/PluginProcessor.h b/source/jucePlugin/PluginProcessor.h
@@ -44,6 +44,8 @@ public:
//==============================================================================
void getStateInformation (juce::MemoryBlock& destData) override;
void setStateInformation (const void* data, int sizeInBytes) override;
+ void getCurrentProgramStateInformation (juce::MemoryBlock& destData) override;
+ void setCurrentProgramStateInformation (const void* data, int sizeInBytes) override;
// _____________
//
@@ -55,6 +57,8 @@ public:
// _____________
//
private:
+ void setState(const void* _data, size_t _sizeInBytes);
+
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioPluginAudioProcessor)
diff --git a/source/synthLib/deviceTypes.h b/source/synthLib/deviceTypes.h
@@ -5,6 +5,6 @@ namespace synthLib
enum StateType
{
StateTypeGlobal,
- StateTypeLocal,
+ StateTypeCurrentProgram,
};
}