X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=libs%2Fardour%2Fplugin.cc;h=a0ac97b440b7a5e6cdc313e8bf72c6cd14120235;hb=b90baf217632b203e66c296217eb357637a18430;hp=92fe289e0ca500b0d40b25e1e7c8e7a29088cb41;hpb=d5dbdc9ea5c3d1a34b2b1809e28931a864f55c3e;p=ardour.git diff --git a/libs/ardour/plugin.cc b/libs/ardour/plugin.cc index 92fe289e0c..a0ac97b440 100644 --- a/libs/ardour/plugin.cc +++ b/libs/ardour/plugin.cc @@ -46,6 +46,7 @@ #include "ardour/chan_count.h" #include "ardour/chan_mapping.h" #include "ardour/data_type.h" +#include "ardour/luaproc.h" #include "ardour/midi_buffer.h" #include "ardour/midi_state_tracker.h" #include "ardour/plugin.h" @@ -64,7 +65,7 @@ #include "pbd/stl_delete.h" -#include "i18n.h" +#include "pbd/i18n.h" #include using namespace std; @@ -86,16 +87,6 @@ PluginInfo::is_instrument () const return (n_inputs.n_midi() != 0) && (n_outputs.n_audio() > 0); } -std::vector -PluginInfo::get_presets(Session& session) { - PluginPtr plugin = load (session); - if (plugin) { - return plugin->get_presets(); - } else { - return std::vector (); - } -} - Plugin::Plugin (AudioEngine& e, Session& s) : _engine (e) , _session (s) @@ -130,6 +121,12 @@ Plugin::~Plugin () void Plugin::remove_preset (string name) { + Plugin::PresetRecord const * p = preset_by_label (name); + if (!p->user) { + PBD::error << _("Cannot remove plugin factory preset.") << endmsg; + return; + } + do_remove_preset (name); _presets.erase (preset_by_label (name)->uri); @@ -143,6 +140,11 @@ Plugin::remove_preset (string name) Plugin::PresetRecord Plugin::save_preset (string name) { + if (preset_by_label (name)) { + PBD::error << _("Preset with given name already exists.") << endmsg; + return Plugin::PresetRecord (); + } + string const uri = do_save_preset (name); if (!uri.empty()) { @@ -161,6 +163,10 @@ ARDOUR::find_plugin(Session& session, string identifier, PluginType type) PluginInfoList plugs; switch (type) { + case ARDOUR::Lua: + plugs = mgr.lua_plugin_info(); + break; + case ARDOUR::LADSPA: plugs = mgr.ladspa_plugin_info(); break; @@ -248,9 +254,52 @@ Plugin::input_streams () const return ChanCount::ZERO; } +Plugin::IOPortDescription +Plugin::describe_io_port (ARDOUR::DataType dt, bool input, uint32_t id) const +{ + std::stringstream ss; + switch (dt) { + case DataType::AUDIO: + ss << _("Audio") << " "; + break; + case DataType::MIDI: + ss << _("Midi") << " "; + break; + default: + ss << _("?") << " "; + break; + } + if (input) { + ss << _("In") << " "; + } else { + ss << _("Out") << " "; + } + + ss << (id + 1); + + Plugin::IOPortDescription iod (ss.str()); + return iod; +} + +PluginOutputConfiguration +Plugin::possible_output () const +{ + PluginOutputConfiguration oc; + if (_info) { + oc.insert (_info->n_outputs.n_audio ()); + } + return oc; +} + const Plugin::PresetRecord * Plugin::preset_by_label (const string& label) { +#ifndef NO_PLUGIN_STATE + if (!_have_presets) { + find_presets (); + _have_presets = true; + } +#endif // FIXME: O(n) for (map::const_iterator i = _presets.begin(); i != _presets.end(); ++i) { if (i->second.label == label) { @@ -264,6 +313,12 @@ Plugin::preset_by_label (const string& label) const Plugin::PresetRecord * Plugin::preset_by_uri (const string& uri) { +#ifndef NO_PLUGIN_STATE + if (!_have_presets) { + find_presets (); + _have_presets = true; + } +#endif map::const_iterator pr = _presets.find (uri); if (pr != _presets.end()) { return &pr->second; @@ -274,8 +329,9 @@ Plugin::preset_by_uri (const string& uri) int Plugin::connect_and_run (BufferSet& bufs, - ChanMapping /*in_map*/, ChanMapping /*out_map*/, - pframes_t /* nframes */, framecnt_t /*offset*/) + framepos_t /*start*/, framepos_t /*end*/, double /*speed*/, + ChanMapping /*in_map*/, ChanMapping /*out_map*/, + pframes_t /* nframes */, framecnt_t /*offset*/) { if (bufs.count().n_midi() > 0) { @@ -370,6 +426,7 @@ Plugin::load_preset (PresetRecord r) _last_preset = r; _parameter_changed_since_last_preset = false; + _session.set_dirty (); PresetLoaded (); /* EMIT SIGNAL */ return true; } @@ -381,6 +438,7 @@ Plugin::clear_preset () _last_preset.label = ""; _parameter_changed_since_last_preset = false; + _session.set_dirty (); PresetLoaded (); /* EMIT SIGNAL */ } @@ -426,7 +484,7 @@ XMLNode & Plugin::get_state () { XMLNode* root = new XMLNode (state_node_name ()); - LocaleGuard lg (X_("C")); + LocaleGuard lg; root->add_property (X_("last-preset-uri"), _last_preset.uri); root->add_property (X_("last-preset-label"), _last_preset.label);