summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-12-25 22:38:48 +0100
committerRobin Gareus <robin@gareus.org>2015-12-25 22:38:48 +0100
commit81a3ae985d3059e26d5af2e933a7eca0ecdd29fd (patch)
tree87413e20aa42b61197930cad513badb79975d144 /libs/ardour
parente6cb65a171e9455a94fb9e43409c9d178759d431 (diff)
Keep plugin presets in sync across plugin-instances.
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/ardour/plugin.h7
-rw-r--r--libs/ardour/plugin.cc17
2 files changed, 24 insertions, 0 deletions
diff --git a/libs/ardour/ardour/plugin.h b/libs/ardour/ardour/plugin.h
index 72eda4c2fd..0351f5d751 100644
--- a/libs/ardour/ardour/plugin.h
+++ b/libs/ardour/ardour/plugin.h
@@ -207,6 +207,9 @@ class LIBARDOUR_API Plugin : public PBD::StatefulDestructible, public Latent
PBD::Signal0<void> PresetAdded;
PBD::Signal0<void> PresetRemoved;
+ /** Emitted when any preset has been changed */
+ static PBD::Signal2<void, std::string, Plugin*> PresetsChanged;
+
/** Emitted when a preset has been loaded */
PBD::Signal0<void> PresetLoaded;
@@ -312,6 +315,8 @@ private:
/** Fill _presets with our presets */
virtual void find_presets () = 0;
+ void update_presets (std::string src_unique_id, Plugin* src );
+
/** Add state to an existing XMLNode */
virtual void add_state (XMLNode *) const = 0;
@@ -322,6 +327,8 @@ private:
PresetRecord _last_preset;
bool _parameter_changed_since_last_preset;
+ PBD::ScopedConnection _preset_connection;
+
void resolve_midi ();
};
diff --git a/libs/ardour/plugin.cc b/libs/ardour/plugin.cc
index d03024b64b..d6c9a48805 100644
--- a/libs/ardour/plugin.cc
+++ b/libs/ardour/plugin.cc
@@ -78,6 +78,8 @@ static bool seen_get_state_message = false;
static bool seen_set_state_message = false;
#endif
+PBD::Signal2<void, std::string, Plugin*> Plugin::PresetsChanged;
+
bool
PluginInfo::is_instrument () const
{
@@ -93,6 +95,7 @@ Plugin::Plugin (AudioEngine& e, Session& s)
, _parameter_changed_since_last_preset (false)
{
_pending_stop_events.ensure_buffers (DataType::MIDI, 1, 4096);
+ PresetsChanged.connect_same_thread (_preset_connection, boost::bind (&Plugin::update_presets, this, _1 ,_2));
}
Plugin::Plugin (const Plugin& other)
@@ -107,6 +110,7 @@ Plugin::Plugin (const Plugin& other)
, _parameter_changed_since_last_preset (false)
{
_pending_stop_events.ensure_buffers (DataType::MIDI, 1, 4096);
+ PresetsChanged.connect_same_thread (_preset_connection, boost::bind (&Plugin::update_presets, this, _1 ,_2));
}
Plugin::~Plugin ()
@@ -122,6 +126,7 @@ Plugin::remove_preset (string name)
_last_preset.uri = "";
_parameter_changed_since_last_preset = false;
PresetRemoved (); /* EMIT SIGNAL */
+ PresetsChanged (unique_id(), this); /* EMIT SIGNAL */
}
/** @return PresetRecord with empty URI on failure */
@@ -133,6 +138,7 @@ Plugin::save_preset (string name)
if (!uri.empty()) {
_presets.insert (make_pair (uri, PresetRecord (uri, name)));
PresetAdded (); /* EMIT SIGNAL */
+ PresetsChanged (unique_id(), this); /* EMIT SIGNAL */
}
return PresetRecord (uri, name);
@@ -309,6 +315,17 @@ Plugin::resolve_midi ()
_have_pending_stop_events = true;
}
+void
+Plugin::update_presets (std::string src_unique_id, Plugin* src )
+{
+ if (src == this || unique_id() != src_unique_id) {
+ return;
+ }
+ _have_presets = false;
+ // TODO check if a preset was added/removed and emit the proper signal
+ // so far no subscriber distinguishes between PresetAdded and PresetRemoved
+ PresetAdded();
+}
vector<Plugin::PresetRecord>
Plugin::get_presets ()