diff --git a/libs/ardour/instrument_info.cc b/libs/ardour/instrument_info.cc index e7538a061f..4a1dc96046 100644 --- a/libs/ardour/instrument_info.cc +++ b/libs/ardour/instrument_info.cc @@ -49,6 +49,9 @@ InstrumentInfo::~InstrumentInfo () void InstrumentInfo::set_external_instrument (const string& model, const string& mode) { + if (external_instrument_model == model && external_instrument_mode == mode && internal_instrument.expired ()) { + return; + } external_instrument_model = model; external_instrument_mode = mode; internal_instrument.reset (); @@ -58,6 +61,7 @@ InstrumentInfo::set_external_instrument (const string& model, const string& mode void InstrumentInfo::set_internal_instrument (boost::shared_ptr p) { + bool changed = !external_instrument_mode.empty (); external_instrument_mode = ""; boost::shared_ptr pi = boost::dynamic_pointer_cast(p); @@ -67,17 +71,24 @@ InstrumentInfo::set_internal_instrument (boost::shared_ptr p) * InstrumentInfo::get_plugin_patch_name() needs to be overhauled, * it limits all PluginInsert to generic-midi or only numbers. */ + changed |= !internal_instrument.expired (); + changed |= external_instrument_model != pi->plugin ()->midnam_model (); + internal_instrument.reset (); external_instrument_model = pi->plugin ()->midnam_model (); const std::list device_modes = MIDI::Name::MidiPatchManager::instance().custom_device_mode_names_by_model (external_instrument_model); if (device_modes.size() > 0) { + changed |= external_instrument_mode != device_modes.front(); external_instrument_mode = device_modes.front(); } } else { + changed |= internal_instrument.lock () != p || external_instrument_model != _("Unknown"); internal_instrument = p; - external_instrument_model = (_("Unknown")); + external_instrument_model = _("Unknown"); + } + if (changed) { + Changed(); /* EMIT SIGNAL */ } - Changed(); /* EMIT SIGNAL */ } string