diff --git a/gtk2_ardour/au_pluginui.h b/gtk2_ardour/au_pluginui.h index 5644331662..b0af3b6a40 100644 --- a/gtk2_ardour/au_pluginui.h +++ b/gtk2_ardour/au_pluginui.h @@ -54,7 +54,7 @@ namespace ARDOUR { class AUPlugin; - class PluginInsert; + class PlugInsertBase; class IOProcessor; } @@ -77,7 +77,7 @@ class AUPluginUI; class AUPluginUI : public PlugUIBase, public Gtk::VBox { public: - AUPluginUI (boost::shared_ptr); + AUPluginUI (boost::shared_ptr); ~AUPluginUI (); gint get_preferred_width () { return req_width; } diff --git a/gtk2_ardour/au_pluginui.mm b/gtk2_ardour/au_pluginui.mm index 8ce8f9a6a8..e06483099c 100644 --- a/gtk2_ardour/au_pluginui.mm +++ b/gtk2_ardour/au_pluginui.mm @@ -393,8 +393,8 @@ static void interposed_drawIfNeeded (id receiver, SEL selector, NSRect rect) } @end -AUPluginUI::AUPluginUI (boost::shared_ptr insert) - : PlugUIBase (insert) +AUPluginUI::AUPluginUI (boost::shared_ptr pib) + : PlugUIBase (pib) , automation_mode_label (_("Automation")) , preset_label (_("Presets")) , resizable (false) @@ -415,7 +415,7 @@ AUPluginUI::AUPluginUI (boost::shared_ptr insert) set_popdown_strings (automation_mode_selector, automation_mode_strings); automation_mode_selector.set_active_text (automation_mode_strings.front()); - if ((au = boost::dynamic_pointer_cast (insert->plugin())) == 0) { + if ((au = boost::dynamic_pointer_cast (pib->plugin())) == 0) { error << _("unknown type of editor-supplying plugin (note: no AudioUnit support in this version of ardour)") << endmsg; throw failed_constructor (); } @@ -427,13 +427,7 @@ AUPluginUI::AUPluginUI (boost::shared_ptr insert) top_box.set_spacing (6); top_box.set_border_width (6); - bool for_auditioner = false; - if (insert->session().the_auditioner()) { - for_auditioner = insert->session().the_auditioner()->the_instrument() == insert; - } - if (!for_auditioner) { - add_common_widgets (&top_box); - } + add_common_widgets (&top_box); set_spacing (0); pack_start (top_box, false, false); @@ -819,7 +813,7 @@ AUPluginUI::cocoa_view_resized () plugin_requested_resize = 1; - ProcessorWindowProxy* wp = insert->window_proxy(); + ProcessorWindowProxy* wp = _pi ? _pi->window_proxy() : NULL; if (wp) { /* Once a plugin has requested a resize of its own window, do * NOT save the window. The user may save state with the plugin @@ -1289,9 +1283,9 @@ AUPluginUI::stop_updating (GdkEventAny*) } PlugUIBase* -create_au_gui (boost::shared_ptr plugin_insert, VBox** box) +create_au_gui (boost::shared_ptr pib, VBox** box) { - AUPluginUI* aup = new AUPluginUI (plugin_insert); + AUPluginUI* aup = new AUPluginUI (pib); (*box) = aup; return aup; } diff --git a/gtk2_ardour/generic_pluginui.cc b/gtk2_ardour/generic_pluginui.cc index 359937369b..254795e953 100644 --- a/gtk2_ardour/generic_pluginui.cc +++ b/gtk2_ardour/generic_pluginui.cc @@ -47,7 +47,6 @@ #include "midi++/midnam_patch.h" -#include "ardour/auditioner.h" #include "ardour/midi_patch_manager.h" #include "ardour/midi_track.h" #include "ardour/plugin.h" @@ -85,8 +84,8 @@ using namespace ArdourWidgets; using namespace Gtk; using namespace ARDOUR_UI_UTILS; -GenericPluginUI::GenericPluginUI (boost::shared_ptr pi, bool scrollable) - : PlugUIBase (pi) +GenericPluginUI::GenericPluginUI (boost::shared_ptr pib, bool scrollable) + : PlugUIBase (pib) , automation_menu (0) , is_scrollable(scrollable) , _plugin_pianokeyboard_expander (_("MIDI Keyboard (audition only)")) @@ -94,11 +93,6 @@ GenericPluginUI::GenericPluginUI (boost::shared_ptr pi, bool scrol , _piano_velocity (*manage (new Adjustment (100, 1, 127, 1, 16))) , _piano_channel (*manage (new Adjustment (0, 1, 16, 1, 1))) { - bool for_auditioner = false; - if (insert->session().the_auditioner()) { - for_auditioner = insert->session().the_auditioner()->the_instrument() == insert; - } - set_name ("PluginEditor"); set_border_width (6); //set_homogeneous (false); @@ -109,7 +103,7 @@ GenericPluginUI::GenericPluginUI (boost::shared_ptr pi, bool scrol smaller_hbox->set_spacing (6); smaller_hbox->set_border_width (0); - if (for_auditioner) { + if (_pib->ui_elements () == PlugInsertBase::NoGUIToolbar) { Gtk::Label* spacer = manage (new Gtk::Label()); smaller_hbox->pack_start(*spacer); } else { @@ -127,42 +121,40 @@ GenericPluginUI::GenericPluginUI (boost::shared_ptr pi, bool scrol automation_latch_all_button.set_text (GainMeterBase::astate_string (ARDOUR::Latch)); automation_latch_all_button.set_name (X_("generic button")); - if (!for_auditioner) { /*auditioner is not run when it isn't auditioning; so the piano keyboard, cpu usage, and other features are not applicable */ - if (pi->is_instrument ()) { - _piano = new APianoKeyboard (); - _piano->set_can_focus (); + if (_pib->ui_elements () & PlugInsertBase::MIDIKeyboard) { + _piano = new APianoKeyboard (); + _piano->set_can_focus (); - _piano->NoteOn.connect (sigc::mem_fun (*this, &GenericPluginUI::note_on_event_handler)); - _piano->NoteOff.connect (sigc::mem_fun (*this, &GenericPluginUI::note_off_event_handler)); + _piano->NoteOn.connect (sigc::mem_fun (*this, &GenericPluginUI::note_on_event_handler)); + _piano->NoteOff.connect (sigc::mem_fun (*this, &GenericPluginUI::note_off_event_handler)); - HBox* box = manage (new HBox); - box->pack_start (*manage (new Label (_("Channel:"))), false, false); - box->pack_start (_piano_channel, false, false); - box->pack_start (*manage (new Label (_("Velocity:"))), false, false); - box->pack_start (_piano_velocity, false, false); + HBox* box = manage (new HBox); + box->pack_start (*manage (new Label (_("Channel:"))), false, false); + box->pack_start (_piano_channel, false, false); + box->pack_start (*manage (new Label (_("Velocity:"))), false, false); + box->pack_start (_piano_velocity, false, false); - Box* box2 = manage (new HBox ()); - box2->pack_start (*box, true, false); + Box* box2 = manage (new HBox ()); + box2->pack_start (*box, true, false); - _pianobox.set_spacing (4); - _pianobox.pack_start (*box2, true, true); - _pianobox.pack_start (*_piano, true, true); + _pianobox.set_spacing (4); + _pianobox.pack_start (*box2, true, true); + _pianobox.pack_start (*_piano, true, true); - _plugin_pianokeyboard_expander.set_expanded(false); - _plugin_pianokeyboard_expander.property_expanded().signal_changed().connect( sigc::mem_fun(*this, &GenericPluginUI::toggle_pianokeyboard)); + _plugin_pianokeyboard_expander.set_expanded(false); + _plugin_pianokeyboard_expander.property_expanded().signal_changed().connect( sigc::mem_fun(*this, &GenericPluginUI::toggle_pianokeyboard)); - pack_end (_plugin_pianokeyboard_expander, false, false); - } else { - pack_end (plugin_analysis_expander, false, false); - } + pack_end (_plugin_pianokeyboard_expander, false, false); + } else if (_pi && _pi->ui_elements () != PlugInsertBase::NoGUIToolbar) { + pack_end (plugin_analysis_expander, false, false); + } - if (insert->provides_stats ()) { - pack_end (cpuload_expander, false, false); - } + if (_pib->provides_stats ()) { + pack_end (cpuload_expander, false, false); + } - if (!plugin->get_docs().empty()) { - pack_end (description_expander, false, false); - } + if (!plugin->get_docs().empty()) { + pack_end (description_expander, false, false); } settings_box.set_homogeneous (false); @@ -170,7 +162,31 @@ GenericPluginUI::GenericPluginUI (boost::shared_ptr pi, bool scrol settings_box.set_border_width (0); settings_box.pack_start (*smaller_hbox, false, false); - if (pi->controls().size() > 0) { + bool has_automatables = false; + + for (size_t i = 0; i < plugin->parameter_count(); ++i) { + if (!plugin->parameter_is_control (i)) { + continue; + } + if (!plugin->parameter_is_input (i)) { + continue; + } + const Evoral::Parameter param(PluginAutomation, 0, i); + boost::shared_ptr c (boost::dynamic_pointer_cast(_pib->control (param))); + if (!c) { + continue; + } + if (c->flags () & Controllable::HiddenControl) { + continue; + } + if (c->flags () & Controllable::NotAutomatable) { + continue; + } + has_automatables = true; + break; + } + + if (_pi && has_automatables) { HBox* automation_hbox = manage (new HBox); automation_hbox->set_spacing (6); Label* l = manage (new Label (_("All Automation"))); @@ -185,8 +201,12 @@ GenericPluginUI::GenericPluginUI (boost::shared_ptr pi, bool scrol main_contents.pack_start (settings_box, false, false); - pi->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&GenericPluginUI::processor_active_changed, this, boost::weak_ptr(pi)), gui_context()); - _bypass_button.set_active (!pi->enabled()); + if (_pi) { + _pi->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&GenericPluginUI::processor_active_changed, this, boost::weak_ptr(_pi)), gui_context()); + _bypass_button.set_active (!_pi->enabled()); + } else { + _bypass_button.set_sensitive (false); + } /* ScrolledWindow will wrap hpacker in a Viewport */ scroller.add (hpacker); @@ -198,7 +218,7 @@ GenericPluginUI::GenericPluginUI (boost::shared_ptr pi, bool scrol prefheight = -1; build (); - if (insert->plugin()->has_midnam() && insert->plugin()->knows_bank_patch()) { + if (_pib->plugin()->has_midnam() && _pib->plugin()->knows_bank_patch()) { build_midi_table (); } @@ -336,9 +356,7 @@ GenericPluginUI::build () ControlUI* cui; - boost::shared_ptr c - = boost::dynamic_pointer_cast( - insert->control(param)); + boost::shared_ptr c (boost::dynamic_pointer_cast(_pib->control (param))); if (c && c->flags () & Controllable::HiddenControl) { continue; @@ -366,9 +384,7 @@ GenericPluginUI::build () const ParameterDescriptor& desc = d->second; const Evoral::Parameter param(PluginPropertyAutomation, 0, desc.key); - boost::shared_ptr c - = boost::dynamic_pointer_cast( - insert->control(param)); + boost::shared_ptr c (boost::dynamic_pointer_cast(_pib->control (param))); if (!c) { error << string_compose(_("Plugin Editor: no control for property %1"), desc.key) << endmsg; @@ -396,9 +412,9 @@ GenericPluginUI::build () plugin->announce_property_values(); } - if (control_uis.empty ()) { + if (control_uis.empty () && _pi) { if (has_descriptive_presets ()) { - preset_gui = new PluginPresetsUI (insert); + preset_gui = new PluginPresetsUI (_pi); // XXX hpacker.pack_start (*preset_gui, true, true); } } else { @@ -644,7 +660,7 @@ GenericPluginUI::build_midi_table () ArdourWidgets::Frame* frame = manage (new ArdourWidgets::Frame); frame->set_name ("BaseFrame"); - if (dynamic_cast (insert->owner())) { + if (_pi && dynamic_cast (_pi->owner())) { frame->set_label (_("MIDI Programs (sent to track)")); } else { frame->set_label (_("MIDI Programs (volatile)")); @@ -664,16 +680,16 @@ GenericPluginUI::build_midi_table () pgm_table->attach (*cui, col + 1, col + 2, row, row+1, SHRINK, SHRINK); } - insert->plugin ()->read_midnam(); + _pib->plugin ()->read_midnam(); midi_refill_patches (); - insert->plugin()->BankPatchChange.connect ( + _pib->plugin()->BankPatchChange.connect ( midi_connections, invalidator (*this), boost::bind (&GenericPluginUI::midi_bank_patch_change, this, _1), gui_context()); - insert->plugin()->UpdatedMidnam.connect ( + _pib->plugin()->UpdatedMidnam.connect ( midi_connections, invalidator (*this), boost::bind (&GenericPluginUI::midi_refill_patches, this), gui_context()); @@ -686,7 +702,7 @@ GenericPluginUI::midi_refill_patches () pgm_names.clear (); - const std::string model = insert->plugin ()->midnam_model (); + const std::string model = _pib->plugin ()->midnam_model (); std::string mode; const std::list device_modes = MIDI::Name::MidiPatchManager::instance().custom_device_mode_names_by_model (model); if (device_modes.size() > 0) { @@ -722,7 +738,7 @@ void GenericPluginUI::midi_bank_patch_change (uint8_t chn) { assert (chn < 16 && midi_pgmsel.size() == 16); - uint32_t bankpgm = insert->plugin()->bank_patch (chn); + uint32_t bankpgm = _pib->plugin()->bank_patch (chn); if (bankpgm == UINT32_MAX) { midi_pgmsel[chn]->set_text (_("--Unset--")); } else { @@ -742,7 +758,7 @@ GenericPluginUI::midi_bank_patch_select (uint8_t chn, uint32_t bankpgm) { int bank = bankpgm >> 7; int pgm = bankpgm & 127; - MidiTrack* mt = dynamic_cast (insert->owner()); + MidiTrack* mt = _pi ? dynamic_cast (_pi->owner()) : NULL; if (mt) { /* send to track */ boost::shared_ptr bank_msb = mt->automation_control(Evoral::Parameter (MidiCCAutomation, chn, MIDI_CTL_MSB_BANK), true); @@ -757,15 +773,15 @@ GenericPluginUI::midi_bank_patch_select (uint8_t chn, uint32_t bankpgm) event[0] = (MIDI_CMD_CONTROL | chn); event[1] = 0x00; event[2] = bank >> 7; - insert->write_immediate_event (Evoral::MIDI_EVENT, 3, event); + _pib->write_immediate_event (Evoral::MIDI_EVENT, 3, event); event[1] = 0x20; event[2] = bank & 127; - insert->write_immediate_event (Evoral::MIDI_EVENT, 3, event); + _pib->write_immediate_event (Evoral::MIDI_EVENT, 3, event); event[0] = (MIDI_CMD_PGM_CHANGE | chn); event[1] = pgm; - insert->write_immediate_event (Evoral::MIDI_EVENT, 2, event); + _pib->write_immediate_event (Evoral::MIDI_EVENT, 2, event); } } @@ -817,13 +833,18 @@ GenericPluginUI::set_short_autostate (ControlUI* cui, bool value) void GenericPluginUI::automation_state_changed (ControlUI* cui) { + AutoState state; + if (_pi) { + /* don't lock to avoid deadlock because we're triggered by + * AutomationControl::Changed() while the automation lock is taken + */ + state = _pi->get_parameter_automation_state (cui->parameter()); + } else { + state = ARDOUR::Off; + } + /* update button label */ - // don't lock to avoid deadlock because we're triggered by - // AutomationControl::Changed() while the automation lock is taken - - AutoState state = insert->get_parameter_automation_state (cui->parameter()); - cui->automate_button.set_active((state != ARDOUR::Off)); if (cui->short_autostate) { @@ -1014,7 +1035,7 @@ GenericPluginUI::build_control_ui (const Evoral::Parameter& param, } - if (mcontrol->flags () & Controllable::NotAutomatable) { + if (!_pi || mcontrol->flags () & Controllable::NotAutomatable) { control_ui->automate_button.set_sensitive (false); set_tooltip(control_ui->automate_button, _("This control cannot be automated")); } else { @@ -1130,6 +1151,7 @@ GenericPluginUI::knob_size_request(Gtk::Requisition* req, ControlUI* cui) { bool GenericPluginUI::astate_button_event (GdkEventButton* ev, ControlUI* cui) { + assert (_pi); if (ev->button != 1) { return true; } @@ -1157,7 +1179,7 @@ GenericPluginUI::astate_button_event (GdkEventButton* ev, ControlUI* cui) sigc::bind (sigc::mem_fun(*this, &GenericPluginUI::set_automation_state), (AutoState) Latch, cui))); anchored_menu_popup (automation_menu, &cui->automate_button, - GainMeterBase::astate_string (insert->get_parameter_automation_state (cui->parameter())), + GainMeterBase::astate_string (_pi->get_parameter_automation_state (cui->parameter())), 1, ev->time); return true; @@ -1174,7 +1196,9 @@ GenericPluginUI::set_all_automation (AutoState as) void GenericPluginUI::set_automation_state (AutoState state, ControlUI* cui) { - insert->set_parameter_automation_state (cui->parameter(), state); + if (_pi) { + _pi->set_parameter_automation_state (cui->parameter(), state); + } } void @@ -1239,7 +1263,7 @@ void GenericPluginUI::control_combo_changed (ControlUI* cui, float value) { if (!cui->ignore_change) { - insert->automation_control (cui->parameter())->set_value (value, Controllable::NoGroup); + cui->combo->get_controllable ()->set_value (value, Controllable::NoGroup); } } @@ -1268,7 +1292,7 @@ GenericPluginUI::output_update () for (vector::iterator i = output_controls.begin(); i != output_controls.end(); ++i) { float val = plugin->get_parameter ((*i)->parameter().id()); char buf[32]; - boost::shared_ptr c = insert->control_output ((*i)->parameter().id()); + boost::shared_ptr c = _pib->control_output ((*i)->parameter().id()); const std::string& str = ARDOUR::value_as_string(c->desc(), Variant(val)); size_t len = str.copy(buf, 31); buf[len] = '\0'; @@ -1322,7 +1346,7 @@ GenericPluginUI::toggle_pianokeyboard () void GenericPluginUI::note_on_event_handler (int note, int) { - MidiTrack* mt = dynamic_cast (insert->owner()); + MidiTrack* mt = _pi ? dynamic_cast (_pi->owner()) : NULL; _piano->grab_focus (); uint8_t channel = _piano_channel.get_value_as_int () - 1; uint8_t event[3]; @@ -1332,14 +1356,14 @@ GenericPluginUI::note_on_event_handler (int note, int) if (mt) { mt->write_immediate_event (Evoral::MIDI_EVENT, 3, event); } else { - insert->write_immediate_event (Evoral::MIDI_EVENT, 3, event); + _pib->write_immediate_event (Evoral::MIDI_EVENT, 3, event); } } void GenericPluginUI::note_off_event_handler (int note) { - MidiTrack* mt = dynamic_cast (insert->owner()); + MidiTrack* mt = _pi ? dynamic_cast (_pi->owner()) : NULL; uint8_t channel = _piano_channel.get_value_as_int () - 1; uint8_t event[3]; event[0] = (MIDI_CMD_NOTE_OFF | channel); @@ -1348,6 +1372,6 @@ GenericPluginUI::note_off_event_handler (int note) if (mt) { mt->write_immediate_event (Evoral::MIDI_EVENT, 3, event); } else { - insert->write_immediate_event (Evoral::MIDI_EVENT, 3, event); + _pib->write_immediate_event (Evoral::MIDI_EVENT, 3, event); } } diff --git a/gtk2_ardour/lv2_plugin_ui.cc b/gtk2_ardour/lv2_plugin_ui.cc index d5535c8129..a8c41ad614 100644 --- a/gtk2_ardour/lv2_plugin_ui.cc +++ b/gtk2_ardour/lv2_plugin_ui.cc @@ -25,8 +25,8 @@ #include -#include "ardour/auditioner.h" #include "ardour/lv2_plugin.h" +#include "ardour/plugin_insert.h" #include "ardour/session.h" #include "pbd/error.h" @@ -73,9 +73,9 @@ LV2PluginUI::write_from_ui(void* controller, } } else if (format == URIMap::instance().urids.atom_eventTransfer) { - const int cnt = me->_pi->get_count(); + const int cnt = me->_pib->get_count(); for (int i=0; i < cnt; i++ ) { - boost::shared_ptr lv2i = boost::dynamic_pointer_cast (me->_pi->plugin(i)); + boost::shared_ptr lv2i = boost::dynamic_pointer_cast (me->_pib->plugin(i)); lv2i->write_from_ui(port_index, format, buffer_size, (const uint8_t*)buffer); } } @@ -296,10 +296,10 @@ LV2PluginUI::output_update() _updates.clear (); } -LV2PluginUI::LV2PluginUI(boost::shared_ptr pi, +LV2PluginUI::LV2PluginUI(boost::shared_ptr pib, boost::shared_ptr lv2p) - : PlugUIBase(pi) - , _pi(pi) + : PlugUIBase(pib) + , _pib(pib) , _lv2(lv2p) , _gui_widget(NULL) , _values_last_sent_to_ui(NULL) @@ -309,13 +309,7 @@ LV2PluginUI::LV2PluginUI(boost::shared_ptr pi, _ardour_buttons_box.set_spacing (6); _ardour_buttons_box.set_border_width (6); - bool for_auditioner = false; - if (insert->session().the_auditioner()) { - for_auditioner = insert->session().the_auditioner()->the_instrument() == insert; - } - if (!for_auditioner) { - add_common_widgets (&_ardour_buttons_box); - } + add_common_widgets (&_ardour_buttons_box); plugin->PresetLoaded.connect (*this, invalidator (*this), boost::bind (&LV2PluginUI::queue_port_update, this), gui_context ()); } @@ -479,7 +473,7 @@ LV2PluginUI::lv2ui_instantiate(const std::string& title) _values_last_sent_to_ui[port] = _lv2->get_parameter(port); _controllables[port] = boost::dynamic_pointer_cast ( - insert->control(Evoral::Parameter(PluginAutomation, 0, port))); + _pib->control(Evoral::Parameter(PluginAutomation, 0, port))); if (_lv2->parameter_is_control(port) && _lv2->parameter_is_input(port)) { if (_controllables[port]) { diff --git a/gtk2_ardour/lv2_plugin_ui.h b/gtk2_ardour/lv2_plugin_ui.h index 74d30148b3..857e8058fc 100644 --- a/gtk2_ardour/lv2_plugin_ui.h +++ b/gtk2_ardour/lv2_plugin_ui.h @@ -38,21 +38,20 @@ #include "ardour/types.h" #include "plugin_ui.h" -#include "ardour/plugin_insert.h" +#include "ardour/plug_insert_base.h" #include "lv2_external_ui.h" #include "lv2/lv2plug.in/ns/extensions/ui/ui.h" namespace ARDOUR { - class PluginInsert; class LV2Plugin; } class LV2PluginUI : public PlugUIBase, public Gtk::VBox { public: - LV2PluginUI (boost::shared_ptr, + LV2PluginUI (boost::shared_ptr, boost::shared_ptr); ~LV2PluginUI (); @@ -72,28 +71,29 @@ private: typedef boost::shared_ptr ControllableRef; - boost::shared_ptr _pi; - boost::shared_ptr _lv2; - std::vector _output_ports; - sigc::connection _screen_update_connection; - sigc::connection _message_update_connection; - Gtk::Widget* _gui_widget; - /** a box containing the focus, bypass, delete, save / add preset buttons etc. */ - Gtk::HBox _ardour_buttons_box; - float* _values_last_sent_to_ui; - std::vector _controllables; - struct lv2_external_ui_host _external_ui_host; - LV2_Feature _external_ui_feature; - LV2_Feature _external_kxui_feature; + boost::shared_ptr _pib; + boost::shared_ptr _lv2; + std::vector _output_ports; + sigc::connection _screen_update_connection; + sigc::connection _message_update_connection; + Gtk::Widget* _gui_widget; + /** a box containing the focus, bypa s, delete, save / add preset buttons etc. */ + Gtk::HBox _ardour_buttons_box; + float* _values_last_sent_to_ui; + std::vector _controllables; + struct lv2_external_ui_host _external_ui_host; + LV2_Feature _external_ui_feature; + LV2_Feature _external_kxui_feature; #ifdef HAVE_LV2_1_17_2 - LV2UI_Request_Value _lv2ui_request_value; - LV2_Feature _lv2ui_request_feature; + LV2UI_Request_Value _lv2ui_request_value; + LV2_Feature _lv2ui_request_feature; #endif - struct lv2_external_ui* _external_ui_ptr; - LV2_Feature _parent_feature; - void* _inst; + struct lv2_external_ui* _external_ui_ptr; + LV2_Feature _parent_feature; + void* _inst; + typedef std::set Updates; - Updates _updates; + Updates _updates; static void on_external_ui_closed(void* controller); diff --git a/gtk2_ardour/lxvst_plugin_ui.cc b/gtk2_ardour/lxvst_plugin_ui.cc index 8ee765210e..485ebd2fbe 100644 --- a/gtk2_ardour/lxvst_plugin_ui.cc +++ b/gtk2_ardour/lxvst_plugin_ui.cc @@ -33,8 +33,8 @@ using namespace Gtk; using namespace ARDOUR; using namespace PBD; -LXVSTPluginUI::LXVSTPluginUI (boost::shared_ptr pi, boost::shared_ptr lxvp) - : VSTPluginUI (pi, lxvp) +LXVSTPluginUI::LXVSTPluginUI (boost::shared_ptr pib, boost::shared_ptr lxvp) + : VSTPluginUI (pib, lxvp) { vstfx_run_editor (_vst->state ()); } diff --git a/gtk2_ardour/lxvst_plugin_ui.h b/gtk2_ardour/lxvst_plugin_ui.h index 2cc775322e..98a4561622 100644 --- a/gtk2_ardour/lxvst_plugin_ui.h +++ b/gtk2_ardour/lxvst_plugin_ui.h @@ -26,14 +26,14 @@ #ifdef LXVST_SUPPORT namespace ARDOUR { - class PluginInsert; + class PlugInsertBase; class LXVSTPlugin; } class LXVSTPluginUI : public VSTPluginUI { public: - LXVSTPluginUI (boost::shared_ptr, boost::shared_ptr); + LXVSTPluginUI (boost::shared_ptr, boost::shared_ptr); ~LXVSTPluginUI (); int get_preferred_height (); diff --git a/gtk2_ardour/plugin_dspload_ui.cc b/gtk2_ardour/plugin_dspload_ui.cc index 48598d421e..c9b8bf2c4e 100644 --- a/gtk2_ardour/plugin_dspload_ui.cc +++ b/gtk2_ardour/plugin_dspload_ui.cc @@ -18,7 +18,7 @@ #include "gtkmm2ext/utils.h" -#include "ardour/session.h" +#include "ardour/audioengine.h" #include "plugin_dspload_ui.h" #include "timers.h" @@ -28,8 +28,8 @@ using namespace Gtkmm2ext; using namespace Gtk; -PluginLoadStatsGui::PluginLoadStatsGui (boost::shared_ptr insert) - : _insert (insert) +PluginLoadStatsGui::PluginLoadStatsGui (boost::shared_ptr pib) + : _pib (pib) , _lbl_min ("", ALIGN_END, ALIGN_CENTER) , _lbl_max ("", ALIGN_END, ALIGN_CENTER) , _lbl_avg ("", ALIGN_END, ALIGN_CENTER) @@ -81,7 +81,7 @@ PluginLoadStatsGui::stop_updating () { void PluginLoadStatsGui::update_cpu_label() { - if (_insert->get_stats (_min, _max, _avg, _dev)) { + if (_pib->get_stats (_min, _max, _avg, _dev)) { _valid = true; _lbl_min.set_text (string_compose (_("%1 [ms]"), rint (_min / 10.) / 100.)); _lbl_max.set_text (string_compose (_("%1 [ms]"), rint (_max / 10.) / 100.)); @@ -124,7 +124,7 @@ PluginLoadStatsGui::draw_bar (GdkEventExpose* ev) const int w = x1 - x0; const int h = y1 - y0; - const double cycle_ms = 1000. * _insert->session().get_block_size() / (double)_insert->session().nominal_sample_rate(); + const double cycle_ms = ARDOUR::AudioEngine::instance()->usecs_per_cycle () / 1000.0; const double base_mult = std::max (1.0, cycle_ms / 2.0); const double log_base = log1p (base_mult); diff --git a/gtk2_ardour/plugin_dspload_ui.h b/gtk2_ardour/plugin_dspload_ui.h index 59aa3f6cd5..4d8183a6f7 100644 --- a/gtk2_ardour/plugin_dspload_ui.h +++ b/gtk2_ardour/plugin_dspload_ui.h @@ -27,12 +27,12 @@ #include "widgets/ardour_button.h" -#include "ardour/plugin_insert.h" +#include "ardour/plug_insert_base.h" class PluginLoadStatsGui : public Gtk::Table { public: - PluginLoadStatsGui (boost::shared_ptr); + PluginLoadStatsGui (boost::shared_ptr); void start_updating (); void stop_updating (); @@ -44,10 +44,10 @@ private: void update_cpu_label (); bool draw_bar (GdkEventExpose*); void clear_stats () { - _insert->clear_stats (); + _pib->clear_stats (); } - boost::shared_ptr _insert; + boost::shared_ptr _pib; sigc::connection update_cpu_label_connection; Gtk::Label _lbl_min; diff --git a/gtk2_ardour/plugin_dspload_window.cc b/gtk2_ardour/plugin_dspload_window.cc index 7dbdf7bde2..a35bdf0a19 100644 --- a/gtk2_ardour/plugin_dspload_window.cc +++ b/gtk2_ardour/plugin_dspload_window.cc @@ -21,6 +21,8 @@ #include #include "ardour/session.h" +#include "ardour/plugin_insert.h" + #include "gtkmm2ext/gui_thread.h" #include "plugin_dspload_ui.h" diff --git a/gtk2_ardour/plugin_ui.cc b/gtk2_ardour/plugin_ui.cc index 22204646f8..61ea26ee39 100644 --- a/gtk2_ardour/plugin_ui.cc +++ b/gtk2_ardour/plugin_ui.cc @@ -71,7 +71,7 @@ # include "vst3_hwnd_plugin_ui.h" # elif defined (__APPLE__) # include "vst3_plugin_ui.h" -extern VST3PluginUI* create_mac_vst3_gui (boost::shared_ptr, Gtk::VBox**); +extern VST3PluginUI* create_mac_vst3_gui (boost::shared_ptr, Gtk::VBox**); # else # include "vst3_x11_plugin_ui.h" # endif @@ -106,9 +106,9 @@ using namespace Gtk; PluginUIWindow* PluginUIWindow::the_plugin_window = 0; PluginUIWindow::PluginUIWindow ( - boost::shared_ptr insert, - bool scrollable, - bool editor) + boost::shared_ptr pib, + bool scrollable, + bool editor) : ArdourWindow (string()) , was_visible (false) , _keyboard_focused (false) @@ -122,22 +122,22 @@ PluginUIWindow::PluginUIWindow ( Label* label = manage (new Label()); label->set_markup ("THIS IS THE PLUGIN UI"); - if (editor && insert->plugin()->has_editor()) { - switch (insert->type()) { + if (editor && pib->plugin()->has_editor()) { + switch (pib->type()) { case ARDOUR::Windows_VST: - have_gui = create_windows_vst_editor (insert); + have_gui = create_windows_vst_editor (pib); break; case ARDOUR::LXVST: - have_gui = create_lxvst_editor (insert); + have_gui = create_lxvst_editor (pib); break; case ARDOUR::MacVST: - have_gui = create_mac_vst_editor (insert); + have_gui = create_mac_vst_editor (pib); break; case ARDOUR::AudioUnit: - have_gui = create_audiounit_editor (insert); + have_gui = create_audiounit_editor (pib); break; case ARDOUR::LADSPA: @@ -145,11 +145,11 @@ PluginUIWindow::PluginUIWindow ( break; case ARDOUR::LV2: - have_gui = create_lv2_editor (insert); + have_gui = create_lv2_editor (pib); break; case ARDOUR::VST3: - have_gui = create_vst3_editor (insert); + have_gui = create_vst3_editor (pib); break; default: @@ -166,7 +166,7 @@ PluginUIWindow::PluginUIWindow ( } if (!have_gui) { - GenericPluginUI* pu = new GenericPluginUI (insert, scrollable); + GenericPluginUI* pu = new GenericPluginUI (pib, scrollable); _pluginui = pu; _pluginui->KeyboardFocused.connect (sigc::mem_fun (*this, &PluginUIWindow::keyboard_focused)); @@ -180,7 +180,7 @@ PluginUIWindow::PluginUIWindow ( set_name ("PluginEditor"); add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK|Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK); - insert->DropReferences.connect (death_connection, invalidator (*this), boost::bind (&PluginUIWindow::plugin_going_away, this), gui_context()); + pib->DropReferences.connect (death_connection, invalidator (*this), boost::bind (&PluginUIWindow::plugin_going_away, this), gui_context()); gint h = _pluginui->get_preferred_height (); gint w = _pluginui->get_preferred_width (); @@ -260,9 +260,9 @@ PluginUIWindow::set_title(const std::string& title) bool #ifdef WINDOWS_VST_SUPPORT -PluginUIWindow::create_windows_vst_editor(boost::shared_ptr insert) +PluginUIWindow::create_windows_vst_editor(boost::shared_ptr pib) #else -PluginUIWindow::create_windows_vst_editor(boost::shared_ptr) +PluginUIWindow::create_windows_vst_editor(boost::shared_ptr) #endif { #ifndef WINDOWS_VST_SUPPORT @@ -271,12 +271,12 @@ PluginUIWindow::create_windows_vst_editor(boost::shared_ptr) boost::shared_ptr vp; - if ((vp = boost::dynamic_pointer_cast (insert->plugin())) == 0) { + if ((vp = boost::dynamic_pointer_cast (pib->plugin())) == 0) { error << string_compose (_("unknown type of editor-supplying plugin (note: no VST support in this version of %1)"), PROGRAM_NAME) << endmsg; throw failed_constructor (); } else { - WindowsVSTPluginUI* vpu = new WindowsVSTPluginUI (insert, vp, GTK_WIDGET(this->gobj())); + WindowsVSTPluginUI* vpu = new WindowsVSTPluginUI (pib, vp, GTK_WIDGET(this->gobj())); _pluginui = vpu; _pluginui->KeyboardFocused.connect (sigc::mem_fun (*this, &PluginUIWindow::keyboard_focused)); @@ -290,9 +290,9 @@ PluginUIWindow::create_windows_vst_editor(boost::shared_ptr) bool #ifdef LXVST_SUPPORT -PluginUIWindow::create_lxvst_editor(boost::shared_ptr insert) +PluginUIWindow::create_lxvst_editor(boost::shared_ptr pib) #else -PluginUIWindow::create_lxvst_editor(boost::shared_ptr) +PluginUIWindow::create_lxvst_editor(boost::shared_ptr) #endif { #ifndef LXVST_SUPPORT @@ -301,12 +301,12 @@ PluginUIWindow::create_lxvst_editor(boost::shared_ptr) boost::shared_ptr lxvp; - if ((lxvp = boost::dynamic_pointer_cast (insert->plugin())) == 0) { + if ((lxvp = boost::dynamic_pointer_cast (pib->plugin())) == 0) { error << string_compose (_("unknown type of editor-supplying plugin (note: no linuxVST support in this version of %1)"), PROGRAM_NAME) << endmsg; throw failed_constructor (); } else { - LXVSTPluginUI* lxvpu = new LXVSTPluginUI (insert, lxvp); + LXVSTPluginUI* lxvpu = new LXVSTPluginUI (pib, lxvp); _pluginui = lxvpu; _pluginui->KeyboardFocused.connect (sigc::mem_fun (*this, &PluginUIWindow::keyboard_focused)); @@ -320,21 +320,21 @@ PluginUIWindow::create_lxvst_editor(boost::shared_ptr) bool #ifdef MACVST_SUPPORT -PluginUIWindow::create_mac_vst_editor (boost::shared_ptr insert) +PluginUIWindow::create_mac_vst_editor (boost::shared_ptr pib) #else -PluginUIWindow::create_mac_vst_editor (boost::shared_ptr) +PluginUIWindow::create_mac_vst_editor (boost::shared_ptr) #endif { #ifndef MACVST_SUPPORT return false; #else boost::shared_ptr mvst; - if ((mvst = boost::dynamic_pointer_cast (insert->plugin())) == 0) { + if ((mvst = boost::dynamic_pointer_cast (pib->plugin())) == 0) { error << string_compose (_("unknown type of editor-supplying plugin (note: no MacVST support in this version of %1)"), PROGRAM_NAME) << endmsg; throw failed_constructor (); } - VSTPluginUI* vpu = create_mac_vst_gui (insert); + VSTPluginUI* vpu = create_mac_vst_gui (pib); _pluginui = vpu; _pluginui->KeyboardFocused.connect (sigc::mem_fun (*this, &PluginUIWindow::keyboard_focused)); add (*vpu); @@ -348,29 +348,29 @@ PluginUIWindow::create_mac_vst_editor (boost::shared_ptr) bool #ifdef VST3_SUPPORT -PluginUIWindow::create_vst3_editor (boost::shared_ptr insert) +PluginUIWindow::create_vst3_editor (boost::shared_ptr pib) #else -PluginUIWindow::create_vst3_editor (boost::shared_ptr) +PluginUIWindow::create_vst3_editor (boost::shared_ptr) #endif { #ifndef VST3_SUPPORT return false; #else boost::shared_ptr vst3; - if ((vst3 = boost::dynamic_pointer_cast (insert->plugin())) == 0) { + if ((vst3 = boost::dynamic_pointer_cast (pib->plugin())) == 0) { error << _("create_vst3_editor called on non-VST3 plugin") << endmsg; throw failed_constructor (); } else { #ifdef PLATFORM_WINDOWS - VST3HWNDPluginUI* pui = new VST3HWNDPluginUI (insert, vst3); + VST3HWNDPluginUI* pui = new VST3HWNDPluginUI (pib, vst3); add (*pui); #elif defined (__APPLE__) VBox* box; - VST3PluginUI* pui = create_mac_vst3_gui (insert, &box); + VST3PluginUI* pui = create_mac_vst3_gui (pib, &box); add (*box); Application::instance()->ActivationChanged.connect (mem_fun (*this, &PluginUIWindow::app_activated)); #else - VST3X11PluginUI* pui = new VST3X11PluginUI (insert, vst3); + VST3X11PluginUI* pui = new VST3X11PluginUI (pib, vst3); add (*pui); #endif _pluginui = pui; @@ -384,16 +384,16 @@ PluginUIWindow::create_vst3_editor (boost::shared_ptr) bool #ifdef AUDIOUNIT_SUPPORT -PluginUIWindow::create_audiounit_editor (boost::shared_ptr insert) +PluginUIWindow::create_audiounit_editor (boost::shared_ptr pib) #else -PluginUIWindow::create_audiounit_editor (boost::shared_ptr) +PluginUIWindow::create_audiounit_editor (boost::shared_ptr) #endif { #ifndef AUDIOUNIT_SUPPORT return false; #else VBox* box; - _pluginui = create_au_gui (insert, &box); + _pluginui = create_au_gui (pib, &box); _pluginui->KeyboardFocused.connect (sigc::mem_fun (*this, &PluginUIWindow::keyboard_focused)); add (*box); @@ -432,16 +432,16 @@ PluginUIWindow::app_activated (bool) } bool -PluginUIWindow::create_lv2_editor(boost::shared_ptr insert) +PluginUIWindow::create_lv2_editor(boost::shared_ptr pib) { #ifdef HAVE_SUIL boost::shared_ptr vp; - if ((vp = boost::dynamic_pointer_cast (insert->plugin())) == 0) { + if ((vp = boost::dynamic_pointer_cast (pib->plugin())) == 0) { error << _("create_lv2_editor called on non-LV2 plugin") << endmsg; throw failed_constructor (); } else { - LV2PluginUI* lpu = new LV2PluginUI (insert, vp); + LV2PluginUI* lpu = new LV2PluginUI (pib, vp); _pluginui = lpu; add (*lpu); lpu->package (*this); @@ -523,9 +523,9 @@ PluginUIWindow::plugin_going_away () death_connection.disconnect (); } -PlugUIBase::PlugUIBase (boost::shared_ptr pi) - : insert (pi) - , plugin (insert->plugin()) +PlugUIBase::PlugUIBase (boost::shared_ptr pib) + : _pib (pib) + , plugin (pib->plugin()) , _add_button (_("Add")) , _save_button (_("Save")) , _delete_button (_("Delete")) @@ -543,10 +543,7 @@ PlugUIBase::PlugUIBase (boost::shared_ptr pi) , preset_gui (0) , preset_dialog (0) { - bool for_auditioner = false; - if (insert->session().the_auditioner()) { - for_auditioner = insert->session().the_auditioner()->the_instrument() == insert; - } + _pi = boost::dynamic_pointer_cast (_pib); /* may be NULL */ _preset_modified.set_size_request (16, -1); _preset_combo.set_text("(default)"); @@ -593,15 +590,18 @@ PlugUIBase::PlugUIBase (boost::shared_ptr pi) _pin_management_button.set_icon (ArdourIcon::PluginPinout); _pin_management_button.signal_clicked.connect (sigc::mem_fun (*this, &PlugUIBase::manage_pins)); - - insert->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&PlugUIBase::processor_active_changed, this, boost::weak_ptr(insert)), gui_context()); - _bypass_button.set_name ("plugin bypass button"); _bypass_button.set_text (_("Bypass")); _bypass_button.set_icon (ArdourIcon::PluginBypass); - _bypass_button.set_active (!pi->enabled ()); _bypass_button.signal_button_release_event().connect (sigc::mem_fun(*this, &PlugUIBase::bypass_button_release), false); + if (_pi) { + _pi->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&PlugUIBase::processor_active_changed, this, boost::weak_ptr(_pi)), gui_context()); + _bypass_button.set_active (!_pi->enabled ()); + } else { + _bypass_button.set_sensitive (false); + } + _focus_button.signal_button_release_event().connect (sigc::mem_fun(*this, &PlugUIBase::focus_toggled)); _focus_button.add_events (Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK); @@ -624,18 +624,17 @@ PlugUIBase::PlugUIBase (boost::shared_ptr pi) cpuload_expander.property_expanded().signal_changed().connect( sigc::mem_fun(*this, &PlugUIBase::toggle_cpuload_display)); cpuload_expander.set_expanded(false); - insert->DropReferences.connect (death_connection, invalidator (*this), boost::bind (&PlugUIBase::plugin_going_away, this), gui_context()); + _pib->DropReferences.connect (death_connection, invalidator (*this), boost::bind (&PlugUIBase::plugin_going_away, this), gui_context()); - if (!for_auditioner) { /*auditioner can skip these signal-callbacks because these widgets are not shown anyway */ + if (_pib->ui_elements () & PlugInsertBase::PluginPreset) { plugin->PresetAdded.connect (*this, invalidator (*this), boost::bind (&PlugUIBase::preset_added_or_removed, this), gui_context ()); plugin->PresetRemoved.connect (*this, invalidator (*this), boost::bind (&PlugUIBase::preset_added_or_removed, this), gui_context ()); plugin->PresetLoaded.connect (*this, invalidator (*this), boost::bind (&PlugUIBase::update_preset, this), gui_context ()); plugin->PresetDirty.connect (*this, invalidator (*this), boost::bind (&PlugUIBase::update_preset_modified, this), gui_context ()); - - insert->AutomationStateChanged.connect (*this, invalidator (*this), boost::bind (&PlugUIBase::automation_state_changed, this), gui_context()); - - insert->LatencyChanged.connect (*this, invalidator (*this), boost::bind (&PlugUIBase::set_latency_label, this), gui_context()); - + } + if (_pi && _pi->ui_elements () != PlugInsertBase::NoGUIToolbar) { + _pi->AutomationStateChanged.connect (*this, invalidator (*this), boost::bind (&PlugUIBase::automation_state_changed, this), gui_context()); + _pi->LatencyChanged.connect (*this, invalidator (*this), boost::bind (&PlugUIBase::set_latency_label, this), gui_context()); automation_state_changed(); } } @@ -658,40 +657,56 @@ PlugUIBase::plugin_going_away () { drop_connections (); /* drop references to the plugin/insert */ - insert.reset (); + _pib.reset (); + _pi.reset (); plugin.reset (); } void PlugUIBase::add_common_widgets (Gtk::HBox* b, bool with_focus) { + PlugInsertBase::UIElements const ui_elements = _pib->ui_elements (); + + if (ui_elements == PlugInsertBase::NoGUIToolbar) { + return; + } if (with_focus) { b->pack_end (_focus_button, false, false); } - b->pack_end (_bypass_button, false, false, with_focus ? 4 : 0); + if (ui_elements & PlugInsertBase::BypassEnable) { + b->pack_end (_bypass_button, false, false, with_focus ? 4 : 0); + } - if (insert->controls().size() > 0) { + if (_pib->controls().size() > 0) { b->pack_end (_reset_button, false, false, 4); } if (has_descriptive_presets ()) { b->pack_end (_preset_browser_button, false, false); } - b->pack_end (_delete_button, false, false); - b->pack_end (_save_button, false, false); - b->pack_end (_add_button, false, false); - b->pack_end (_preset_combo, false, false); - b->pack_end (_preset_modified, false, false); - b->pack_end (_pin_management_button, false, false); - b->pack_start (_latency_button, false, false, 4); + if (ui_elements & PlugInsertBase::PluginPreset) { + b->pack_end (_delete_button, false, false); + b->pack_end (_save_button, false, false); + b->pack_end (_add_button, false, false); + b->pack_end (_preset_combo, false, false); + b->pack_end (_preset_modified, false, false); + } + + if (_pi) { + b->pack_end (_pin_management_button, false, false); + b->pack_start (_latency_button, false, false, 4); + } } void PlugUIBase::set_latency_label () { - samplecnt_t const l = insert->effective_latency (); - float const sr = insert->session().sample_rate (); + if (!_pi) { + return; + } + samplecnt_t const l = _pi->effective_latency (); + float const sr = _pi->session().sample_rate (); _latency_button.set_text (samples_as_time_string (l, sr, true)); } @@ -699,8 +714,9 @@ PlugUIBase::set_latency_label () void PlugUIBase::latency_button_clicked () { + assert (_pi); if (!latency_gui) { - latency_gui = new LatencyGUI (*(insert.get()), insert->session().sample_rate(), insert->session().get_block_size()); + latency_gui = new LatencyGUI (*(_pi.get()), _pi->session().sample_rate(), _pi->session().get_block_size()); latency_dialog = new ArdourWindow (_("Edit Latency")); /* use both keep-above and transient for to try cover as many different WM's as possible. @@ -735,7 +751,7 @@ PlugUIBase::preset_selected (Plugin::PresetRecord preset) return; } if (!preset.label.empty()) { - insert->load_preset (preset); + _pib->load_preset (preset); } else { // blank selected = no preset plugin->clear_preset(); @@ -786,19 +802,19 @@ PlugUIBase::delete_plugin_setting () void PlugUIBase::automation_state_changed () { - _reset_button.set_sensitive (insert->can_reset_all_parameters()); + _reset_button.set_sensitive (_pib->can_reset_all_parameters()); } void PlugUIBase::reset_plugin_parameters () { - insert->reset_parameters_to_default (); + _pib->reset_parameters_to_default (); } bool PlugUIBase::has_descriptive_presets () const { - std::vector presets = insert->plugin()->get_presets(); + std::vector presets = _pib->plugin()->get_presets(); for (std::vector::const_iterator i = presets.begin(); i != presets.end(); ++i) { if (i->valid && !i->description.empty()) { return true; @@ -810,6 +826,9 @@ PlugUIBase::has_descriptive_presets () const void PlugUIBase::browse_presets () { + if (!_pi) { + return; + } if (!preset_dialog) { if (preset_gui) { /* Do not allow custom window, if preset_gui is used. @@ -823,7 +842,7 @@ PlugUIBase::browse_presets () if (win) { preset_dialog->set_transient_for (*win); } - preset_gui = new PluginPresetsUI (insert); + preset_gui = new PluginPresetsUI (_pi); preset_dialog->add (*preset_gui); } preset_dialog->show_all (); @@ -832,7 +851,8 @@ PlugUIBase::browse_presets () void PlugUIBase::manage_pins () { - PluginPinWindowProxy* proxy = insert->pinmgr_proxy (); + assert (_pi); + PluginPinWindowProxy* proxy = _pi->pinmgr_proxy (); if (proxy) { proxy->get (true); proxy->present (); @@ -843,10 +863,11 @@ PlugUIBase::manage_pins () bool PlugUIBase::bypass_button_release (GdkEventButton*) { + assert (_pi); bool view_says_bypassed = (_bypass_button.active_state() != 0); - if (view_says_bypassed != insert->enabled ()) { - insert->enable (view_says_bypassed); + if (view_says_bypassed != _pi->enabled ()) { + _pi->enable (view_says_bypassed); } return false; @@ -910,11 +931,12 @@ PlugUIBase::toggle_description() void PlugUIBase::toggle_plugin_analysis() { + assert (_pi); if (plugin_analysis_expander.get_expanded() && !plugin_analysis_expander.get_child()) { // Create the GUI if (eqgui == 0) { - eqgui = new PluginEqGui (insert); + eqgui = new PluginEqGui (_pi); } plugin_analysis_expander.add (*eqgui); @@ -944,7 +966,7 @@ PlugUIBase::toggle_cpuload_display() { if (cpuload_expander.get_expanded() && !cpuload_expander.get_child()) { if (stats_gui == 0) { - stats_gui = new PluginLoadStatsGui (insert); + stats_gui = new PluginLoadStatsGui (_pib); } cpuload_expander.add (*stats_gui); cpuload_expander.show_all(); @@ -967,7 +989,6 @@ PlugUIBase::toggle_cpuload_display() toplevel->resize (wr.width, wr.height); } } - } void diff --git a/gtk2_ardour/plugin_ui.h b/gtk2_ardour/plugin_ui.h index 2b3424aa85..490b2e8217 100644 --- a/gtk2_ardour/plugin_ui.h +++ b/gtk2_ardour/plugin_ui.h @@ -64,6 +64,7 @@ namespace ARDOUR { class PluginInsert; + class PlugInsertBase; class Plugin; class WindowsVSTPlugin; class LXVSTPlugin; @@ -90,7 +91,7 @@ class VSTPluginUI; class PlugUIBase : public virtual sigc::trackable, public PBD::ScopedConnectionList { public: - PlugUIBase (boost::shared_ptr); + PlugUIBase (boost::shared_ptr); virtual ~PlugUIBase(); virtual gint get_preferred_height () = 0; @@ -117,7 +118,8 @@ public: sigc::signal KeyboardFocused; protected: - boost::shared_ptr insert; + boost::shared_ptr _pib; + boost::shared_ptr _pi; boost::shared_ptr plugin; void add_common_widgets (Gtk::HBox*, bool with_focus = true); @@ -208,7 +210,7 @@ private: class GenericPluginUI : public PlugUIBase, public Gtk::VBox { public: - GenericPluginUI (boost::shared_ptr plug, bool scrollable=false); + GenericPluginUI (boost::shared_ptr plug, bool scrollable=false); ~GenericPluginUI (); gint get_preferred_height () { return prefheight; } @@ -342,9 +344,9 @@ private: class PluginUIWindow : public ArdourWindow { public: - PluginUIWindow (boost::shared_ptr insert, - bool scrollable=false, - bool editor=true); + PluginUIWindow (boost::shared_ptr, + bool scrollable = false, + bool editor = true); ~PluginUIWindow (); PlugUIBase& pluginui() { return *_pluginui; } @@ -377,12 +379,12 @@ private: void app_activated (bool); void plugin_going_away (); - bool create_windows_vst_editor (boost::shared_ptr); - bool create_lxvst_editor(boost::shared_ptr); - bool create_mac_vst_editor(boost::shared_ptr); - bool create_audiounit_editor (boost::shared_ptr); - bool create_lv2_editor (boost::shared_ptr); - bool create_vst3_editor (boost::shared_ptr); + bool create_windows_vst_editor (boost::shared_ptr); + bool create_lxvst_editor(boost::shared_ptr); + bool create_mac_vst_editor(boost::shared_ptr); + bool create_audiounit_editor (boost::shared_ptr); + bool create_lv2_editor (boost::shared_ptr); + bool create_vst3_editor (boost::shared_ptr); static PluginUIWindow* the_plugin_window; }; @@ -391,12 +393,12 @@ private: /* this function has to be in a .mm file * because MacVSTPluginUI has Cocoa members */ -extern VSTPluginUI* create_mac_vst_gui (boost::shared_ptr); +extern VSTPluginUI* create_mac_vst_gui (boost::shared_ptr); #endif #ifdef AUDIOUNIT_SUPPORT /* this function has to be in a .mm file */ -extern PlugUIBase* create_au_gui (boost::shared_ptr, Gtk::VBox**); +extern PlugUIBase* create_au_gui (boost::shared_ptr, Gtk::VBox**); #endif #endif /* __ardour_plugin_ui_h__ */ diff --git a/gtk2_ardour/vst3_hwnd_plugin_ui.cc b/gtk2_ardour/vst3_hwnd_plugin_ui.cc index ab7868e8f7..63ae897d69 100644 --- a/gtk2_ardour/vst3_hwnd_plugin_ui.cc +++ b/gtk2_ardour/vst3_hwnd_plugin_ui.cc @@ -24,7 +24,6 @@ #include "pbd/unwind.h" -#include "ardour/plugin_insert.h" #include "ardour/vst3_plugin.h" #include "gtkmm2ext/gui_thread.h" @@ -37,8 +36,8 @@ using namespace ARDOUR; using namespace Steinberg; -VST3HWNDPluginUI::VST3HWNDPluginUI (boost::shared_ptr pi, boost::shared_ptr vst3) - : VST3PluginUI (pi, vst3) +VST3HWNDPluginUI::VST3HWNDPluginUI (boost::shared_ptr pib, boost::shared_ptr vst3) + : VST3PluginUI (pib, vst3) { /* TODO register window class, implement wndproc etc */ diff --git a/gtk2_ardour/vst3_hwnd_plugin_ui.h b/gtk2_ardour/vst3_hwnd_plugin_ui.h index e13ff5d9d0..de05c11f09 100644 --- a/gtk2_ardour/vst3_hwnd_plugin_ui.h +++ b/gtk2_ardour/vst3_hwnd_plugin_ui.h @@ -29,7 +29,7 @@ class VST3HWNDPluginUI : public VST3PluginUI { public: - VST3HWNDPluginUI (boost::shared_ptr, boost::shared_ptr); + VST3HWNDPluginUI (boost::shared_ptr, boost::shared_ptr); ~VST3HWNDPluginUI (); bool on_window_show(const std::string&); diff --git a/gtk2_ardour/vst3_nsview_plugin_ui.h b/gtk2_ardour/vst3_nsview_plugin_ui.h index 514496fac7..1252b402e5 100644 --- a/gtk2_ardour/vst3_nsview_plugin_ui.h +++ b/gtk2_ardour/vst3_nsview_plugin_ui.h @@ -43,7 +43,7 @@ class VST3NSViewPluginUI : public VST3PluginUI { public: - VST3NSViewPluginUI (boost::shared_ptr, boost::shared_ptr); + VST3NSViewPluginUI (boost::shared_ptr, boost::shared_ptr); ~VST3NSViewPluginUI (); bool on_window_show(const std::string&); diff --git a/gtk2_ardour/vst3_nsview_plugin_ui.mm b/gtk2_ardour/vst3_nsview_plugin_ui.mm index 50e32de071..c63d469b71 100644 --- a/gtk2_ardour/vst3_nsview_plugin_ui.mm +++ b/gtk2_ardour/vst3_nsview_plugin_ui.mm @@ -28,7 +28,7 @@ #include "pbd/error.h" #include "pbd/unwind.h" -#include "ardour/plugin_insert.h" +#include "ardour/plug_insert_base.h" #include "ardour/vst3_plugin.h" #include "gtkmm2ext/gui_thread.h" @@ -43,16 +43,16 @@ using namespace ARDOUR; using namespace Steinberg; VST3PluginUI* -create_mac_vst3_gui (boost::shared_ptr plugin_insert, Gtk::VBox** box) +create_mac_vst3_gui (boost::shared_ptr pib, Gtk::VBox** box) { - VST3NSViewPluginUI* v = new VST3NSViewPluginUI (plugin_insert, boost::dynamic_pointer_cast (plugin_insert->plugin())); + VST3NSViewPluginUI* v = new VST3NSViewPluginUI (pib, boost::dynamic_pointer_cast (pib->plugin())); *box = v; return v; } -VST3NSViewPluginUI::VST3NSViewPluginUI (boost::shared_ptr pi, boost::shared_ptr vst3) - : VST3PluginUI (pi, vst3) +VST3NSViewPluginUI::VST3NSViewPluginUI (boost::shared_ptr pib, boost::shared_ptr vst3) + : VST3PluginUI (pib, vst3) { pack_start (_gui_widget, true, true); diff --git a/gtk2_ardour/vst3_plugin_ui.cc b/gtk2_ardour/vst3_plugin_ui.cc index 08f91c2993..fb825cacc6 100644 --- a/gtk2_ardour/vst3_plugin_ui.cc +++ b/gtk2_ardour/vst3_plugin_ui.cc @@ -18,9 +18,8 @@ #include -#include "ardour/auditioner.h" +#include "ardour/plug_insert_base.h" #include "ardour/session.h" -#include "ardour/plugin_insert.h" #include "ardour/vst3_plugin.h" #include "gtkmm2ext/gui_thread.h" @@ -36,9 +35,8 @@ using namespace Steinberg; DEF_CLASS_IID (Presonus::IPlugInViewScaling) #endif -VST3PluginUI::VST3PluginUI (boost::shared_ptr pi, boost::shared_ptr vst3) - : PlugUIBase (pi) - , _pi (pi) +VST3PluginUI::VST3PluginUI (boost::shared_ptr pib, boost::shared_ptr vst3) + : PlugUIBase (pib) , _vst3 (vst3) , _req_width (0) , _req_height (0) @@ -48,16 +46,10 @@ VST3PluginUI::VST3PluginUI (boost::shared_ptr pi, boost::shared_pt _ardour_buttons_box.set_spacing (6); _ardour_buttons_box.set_border_width (6); - bool for_auditioner =false; - if (insert->session().the_auditioner()) { - for_auditioner = insert->session().the_auditioner()->the_instrument() == insert; - } - if (!for_auditioner) { - add_common_widgets (&_ardour_buttons_box); - } + add_common_widgets (&_ardour_buttons_box); _vst3->OnResizeView.connect (_resize_connection, invalidator (*this), boost::bind (&VST3PluginUI::resize_callback, this, _1, _2), gui_context()); - //pi->plugin()->PresetLoaded.connect (*this, invalidator (*this), boost::bind (&VST3PluginUI::queue_port_update, this), gui_context ()); + //pib->plugin()->PresetLoaded.connect (*this, invalidator (*this), boost::bind (&VST3PluginUI::queue_port_update, this), gui_context ()); pack_start (_ardour_buttons_box, false, false); _ardour_buttons_box.show_all (); diff --git a/gtk2_ardour/vst3_plugin_ui.h b/gtk2_ardour/vst3_plugin_ui.h index fbe45e639f..57ffbefeea 100644 --- a/gtk2_ardour/vst3_plugin_ui.h +++ b/gtk2_ardour/vst3_plugin_ui.h @@ -24,14 +24,14 @@ #include "plugin_ui.h" namespace ARDOUR { - class PluginInsert; + class PlugInsertBase; class VST3Plugin; } class VST3PluginUI : public PlugUIBase, public Gtk::VBox { public: - VST3PluginUI (boost::shared_ptr, boost::shared_ptr); + VST3PluginUI (boost::shared_ptr, boost::shared_ptr); virtual ~VST3PluginUI (); gint get_preferred_height (); @@ -49,7 +49,6 @@ protected: bool forward_scroll_event (GdkEventScroll*); - boost::shared_ptr _pi; boost::shared_ptr _vst3; Gtk::HBox _ardour_buttons_box; diff --git a/gtk2_ardour/vst3_x11_plugin_ui.cc b/gtk2_ardour/vst3_x11_plugin_ui.cc index 3dbc611100..285b1b538c 100644 --- a/gtk2_ardour/vst3_x11_plugin_ui.cc +++ b/gtk2_ardour/vst3_x11_plugin_ui.cc @@ -178,8 +178,8 @@ private: VST3X11Runloop static_runloop; -VST3X11PluginUI::VST3X11PluginUI (boost::shared_ptr pi, boost::shared_ptr vst3) - : VST3PluginUI (pi, vst3) +VST3X11PluginUI::VST3X11PluginUI (boost::shared_ptr pib, boost::shared_ptr vst3) + : VST3PluginUI (pib, vst3) //, _runloop (new VST3X11Runloop) { _vst3->set_runloop (&static_runloop); diff --git a/gtk2_ardour/vst3_x11_plugin_ui.h b/gtk2_ardour/vst3_x11_plugin_ui.h index 883cea18bf..d16f5a47fe 100644 --- a/gtk2_ardour/vst3_x11_plugin_ui.h +++ b/gtk2_ardour/vst3_x11_plugin_ui.h @@ -29,7 +29,7 @@ class VST3X11PluginUI : public VST3PluginUI { public: - VST3X11PluginUI (boost::shared_ptr, boost::shared_ptr); + VST3X11PluginUI (boost::shared_ptr, boost::shared_ptr); ~VST3X11PluginUI (); bool on_window_show(const std::string&); diff --git a/gtk2_ardour/vst_plugin_ui.cc b/gtk2_ardour/vst_plugin_ui.cc index 474cb67137..cf479624f6 100644 --- a/gtk2_ardour/vst_plugin_ui.cc +++ b/gtk2_ardour/vst_plugin_ui.cc @@ -35,21 +35,15 @@ #include #endif -VSTPluginUI::VSTPluginUI (boost::shared_ptr insert, boost::shared_ptr plugin) - : PlugUIBase (insert) +VSTPluginUI::VSTPluginUI (boost::shared_ptr pib, boost::shared_ptr plugin) + : PlugUIBase (pib) , _vst (plugin) { Gtk::HBox* box = manage (new Gtk::HBox); box->set_spacing (6); box->set_border_width (6); - bool for_auditioner =false; - if (insert->session().the_auditioner()) { - for_auditioner = insert->session().the_auditioner()->the_instrument() == insert; - } - if (!for_auditioner) { - add_common_widgets (box); - } + add_common_widgets (box); pack_start (*box, false, false); box->signal_size_allocate().connect (sigc::mem_fun (*this, &VSTPluginUI::top_box_allocated)); diff --git a/gtk2_ardour/vst_plugin_ui.h b/gtk2_ardour/vst_plugin_ui.h index 9be5419b80..4fca6cd51f 100644 --- a/gtk2_ardour/vst_plugin_ui.h +++ b/gtk2_ardour/vst_plugin_ui.h @@ -28,7 +28,7 @@ namespace ARDOUR { class VSTPluginUI : public PlugUIBase, public Gtk::VBox { public: - VSTPluginUI (boost::shared_ptr, boost::shared_ptr); + VSTPluginUI (boost::shared_ptr, boost::shared_ptr); virtual ~VSTPluginUI (); virtual int get_preferred_height (); diff --git a/gtk2_ardour/windows_vst_plugin_ui.cc b/gtk2_ardour/windows_vst_plugin_ui.cc index 98d79c5b6f..66f1496f5e 100644 --- a/gtk2_ardour/windows_vst_plugin_ui.cc +++ b/gtk2_ardour/windows_vst_plugin_ui.cc @@ -22,7 +22,7 @@ #include #include "gtkmm2ext/gui_thread.h" #include "fst.h" -#include "ardour/plugin_insert.h" +#include "ardour/plug_insert_base.h" #include "ardour/windows_vst_plugin.h" #include "windows_vst_plugin_ui.h" @@ -39,8 +39,8 @@ using namespace Gtk; using namespace ARDOUR; using namespace PBD; -WindowsVSTPluginUI::WindowsVSTPluginUI (boost::shared_ptr pi, boost::shared_ptr vp, GtkWidget *parent) - : VSTPluginUI (pi, vp) +WindowsVSTPluginUI::WindowsVSTPluginUI (boost::shared_ptr pib, boost::shared_ptr vp, GtkWidget *parent) + : VSTPluginUI (pib, vp) { #ifdef GDK_WINDOWING_WIN32 diff --git a/gtk2_ardour/windows_vst_plugin_ui.h b/gtk2_ardour/windows_vst_plugin_ui.h index d9cb33767c..b16d08e0e4 100644 --- a/gtk2_ardour/windows_vst_plugin_ui.h +++ b/gtk2_ardour/windows_vst_plugin_ui.h @@ -26,7 +26,7 @@ class WindowsVSTPluginUI : public VSTPluginUI { public: - WindowsVSTPluginUI (boost::shared_ptr, boost::shared_ptr, GtkWidget *parent); + WindowsVSTPluginUI (boost::shared_ptr, boost::shared_ptr, GtkWidget *parent); ~WindowsVSTPluginUI (); bool start_updating (GdkEventAny*) { return false; }