From 40c162d6096f9bb338b602fb7845234133285411 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 7 Dec 2010 02:56:11 +0000 Subject: Move RDF-based preset stuff into LadspaPlugin, to make way for a set of evil hacks to make VST chunk-based presets work (for some values of `work'). May fix #3577. git-svn-id: svn://localhost/ardour2/branches/3.0@8202 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/plugin_ui.h | 2 +- gtk2_ardour/vst_pluginui.cc | 58 ++++++++++++++++++++++++--------------------- 2 files changed, 32 insertions(+), 28 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/plugin_ui.h b/gtk2_ardour/plugin_ui.h index edc7c609aa..0caed4ac95 100644 --- a/gtk2_ardour/plugin_ui.h +++ b/gtk2_ardour/plugin_ui.h @@ -324,8 +324,8 @@ class VSTPluginUI : public PlugUIBase, public Gtk::VBox bool configure_handler (GdkEventConfigure*, Gtk::Socket*); void save_plugin_setting (); - void create_preset_store (); void preset_chosen (); + void update_presets (); }; #endif // VST_SUPPORT diff --git a/gtk2_ardour/vst_pluginui.cc b/gtk2_ardour/vst_pluginui.cc index 6c1b359fd4..72c73f7467 100644 --- a/gtk2_ardour/vst_pluginui.cc +++ b/gtk2_ardour/vst_pluginui.cc @@ -35,7 +35,14 @@ VSTPluginUI::VSTPluginUI (boost::shared_ptr pi, boost::shared_ptr< : PlugUIBase (pi), vst (vp) { - create_preset_store (); + preset_model = ListStore::create (preset_columns); + + CellRenderer* renderer = manage (new CellRendererText()); + vst_preset_combo.pack_start (*renderer, true); + vst_preset_combo.add_attribute (*renderer, "text", 0); + vst_preset_combo.set_model (preset_model); + + update_presets (); fst_run_editor (vst->fst()); @@ -63,8 +70,19 @@ VSTPluginUI::~VSTPluginUI () void VSTPluginUI::preset_chosen () { - // we can't dispatch directly here, too many plugins only expects one GUI thread. - vst->fst()->want_program = vst_preset_combo.get_active_row_number (); + int const r = vst_preset_combo.get_active_row_number (); + + if (r < vst->first_user_preset_index()) { + /* This is a plugin-provided preset. + We can't dispatch directly here; too many plugins expects only one GUI thread. + */ + vst->fst()->want_program = r; + } else { + /* This is a user preset. This method knows about the direct dispatch restriction, too */ + TreeModel::iterator i = vst_preset_combo.get_active (); + plugin->load_preset ((*i)[preset_columns.name]); + } + socket.grab_focus (); } @@ -138,37 +156,23 @@ VSTPluginUI::configure_handler (GdkEventConfigure* ev, Gtk::Socket *socket) } void -VSTPluginUI::create_preset_store () +VSTPluginUI::update_presets () { - FST *fst = vst->fst(); - int vst_version = fst->plugin->dispatcher (fst->plugin, effGetVstVersion, 0, 0, NULL, 0.0f); + std::vector presets = plugin->get_presets (); - preset_model = ListStore::create (preset_columns); - - for (int i = 0; i < fst->plugin->numPrograms; ++i) { - char buf[100]; - TreeModel::Row row = *(preset_model->append()); - - snprintf (buf, 90, "preset %d", i); + preset_model->clear (); - if (vst_version >= 2) { - fst->plugin->dispatcher (fst->plugin, 29, i, 0, buf, 0.0); - } - - row[preset_columns.name] = buf; - row[preset_columns.number] = i; + int j = 0; + for (std::vector::const_iterator i = presets.begin(); i != presets.end(); ++i) { + TreeModel::Row row = *(preset_model->append ()); + row[preset_columns.name] = i->label; + row[preset_columns.number] = j++; } - if (fst->plugin->numPrograms > 0) { - fst->plugin->dispatcher( fst->plugin, effSetProgram, 0, 0, NULL, 0.0 ); + if (presets.size() > 0) { + vst->fst()->plugin->dispatcher (vst->fst()->plugin, effSetProgram, 0, 0, NULL, 0); } - vst_preset_combo.set_model (preset_model); - - CellRenderer* renderer = manage (new CellRendererText()); - vst_preset_combo.pack_start (*renderer, true); - vst_preset_combo.add_attribute (*renderer, "text", 0); - if (vst->fst()->current_program != -1) { vst_preset_combo.set_active (vst->fst()->current_program); } else { -- cgit v1.2.3