Ardour  9.0-pre0-582-g084a23a80d
plug_insert_base.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022 Robin Gareus <robin@gareus.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef _ardour_plugin_insert_base_h_
20 #define _ardour_plugin_insert_base_h_
21 
22 #include "pbd/destructible.h"
23 
24 #include "evoral/ControlSet.h"
25 
26 #include "ardour/ardour.h"
28 #include "ardour/chan_mapping.h"
29 #include "ardour/plugin.h"
30 #include "ardour/plugin_types.h"
31 
32 namespace ARDOUR {
33 
34 class Plugin;
35 class ReadOnlyControl;
36 class Route;
37 class Session;
38 
39 class LIBARDOUR_API PlugInsertBase : virtual public Evoral::ControlSet, virtual public PBD::Destructible
40 {
41 public:
42  virtual ~PlugInsertBase () {}
43 
44  virtual uint32_t get_count () const = 0;
45  virtual std::shared_ptr<Plugin> plugin (uint32_t num = 0) const = 0;
46  virtual PluginType type () const = 0;
47 
48  enum UIElements : std::uint8_t {
49  NoGUIToolbar = 0x00,
50  BypassEnable = 0x01,
51  PluginPreset = 0x02,
52  MIDIKeyboard = 0x04,
53  AllUIElements = 0x0f
54  };
55 
56  virtual UIElements ui_elements () const = 0;
57 
58  virtual bool write_immediate_event (Evoral::EventType event_type, size_t size, const uint8_t* buf) = 0;
59  virtual bool load_preset (Plugin::PresetRecord) = 0;
60 
61  virtual std::shared_ptr<ReadOnlyControl> control_output (uint32_t) const = 0;
62 
63  virtual bool can_reset_all_parameters () = 0;
64  virtual bool reset_parameters_to_default () = 0;
65 
66  virtual std::string describe_parameter (Evoral::Parameter param) = 0;
67 
68  virtual bool provides_stats () const = 0;
69  virtual bool get_stats (PBD::microseconds_t&, PBD::microseconds_t&, double&, double&) const = 0;
70  virtual void clear_stats () = 0;
71 
72  virtual ChanMapping input_map (uint32_t num) const = 0;
73  virtual ChanMapping output_map (uint32_t num) const = 0;
74 
77  public:
79  PlugInsertBase* p,
80  const Evoral::Parameter& param,
81  const ParameterDescriptor& desc,
82  std::shared_ptr<AutomationList> list = std::shared_ptr<AutomationList> ());
83 
84  virtual double get_value (void) const;
85  void catch_up_with_external_value (double val);
86  XMLNode& get_state () const;
87  std::string get_user_string () const;
88 
89  protected:
90  virtual void actually_set_value (double val, PBD::Controllable::GroupControlDisposition group_override);
92  };
93 
97  PlugInsertBase* p,
98  const Evoral::Parameter& param,
99  const ParameterDescriptor& desc,
100  std::shared_ptr<AutomationList> list = std::shared_ptr<AutomationList> ());
101 
102  virtual double get_value (void) const;
103  XMLNode& get_state () const;
104 
105  protected:
109  };
110 
122  };
123 
125  struct Match {
126  Match () : method (Impossible), plugins (0), strict_io (false), custom_cfg (false) {}
127  Match (MatchingMethod m, int32_t p,
128  bool strict = false, bool custom = false, ChanCount h = ChanCount ())
129  : method (m), plugins (p), hide (h), strict_io (strict), custom_cfg (custom) {}
130 
132  int32_t plugins;
134  bool strict_io;
135  bool custom_cfg;
136  };
137 
138 protected:
139  static std::shared_ptr<Plugin> plugin_factory (std::shared_ptr<Plugin>);
140 
141  bool parse_plugin_type (XMLNode const&, PluginType&, std::string&) const;
142  std::shared_ptr<Plugin> find_and_load_plugin (Session&, XMLNode const&, PluginType&, std::string const&, bool& any_vst);
143 
144  void set_control_ids (const XMLNode&, int version, bool by_value = false);
145  void preset_load_set_value (uint32_t, float);
146 };
147 
148 } // namespace ARDOUR
149 
150 std::ostream& operator<<(std::ostream& o, const ARDOUR::PlugInsertBase::Match& m);
151 
152 #endif
virtual void actually_set_value(double val, PBD::Controllable::GroupControlDisposition group_override)
void catch_up_with_external_value(double val)
PluginControl(Session &s, PlugInsertBase *p, const Evoral::Parameter &param, const ParameterDescriptor &desc, std::shared_ptr< AutomationList > list=std::shared_ptr< AutomationList >())
virtual double get_value(void) const
virtual bool can_reset_all_parameters()=0
virtual std::shared_ptr< ReadOnlyControl > control_output(uint32_t) const =0
virtual UIElements ui_elements() const =0
virtual PluginType type() const =0
virtual bool reset_parameters_to_default()=0
virtual ChanMapping output_map(uint32_t num) const =0
virtual std::string describe_parameter(Evoral::Parameter param)=0
void set_control_ids(const XMLNode &, int version, bool by_value=false)
virtual void clear_stats()=0
bool parse_plugin_type(XMLNode const &, PluginType &, std::string &) const
virtual ChanMapping input_map(uint32_t num) const =0
virtual bool get_stats(PBD::microseconds_t &, PBD::microseconds_t &, double &, double &) const =0
virtual uint32_t get_count() const =0
static std::shared_ptr< Plugin > plugin_factory(std::shared_ptr< Plugin >)
virtual bool provides_stats() const =0
virtual bool write_immediate_event(Evoral::EventType event_type, size_t size, const uint8_t *buf)=0
virtual bool load_preset(Plugin::PresetRecord)=0
@ Delegate
we are delegating to the plugin, and it can handle it
@ ExactMatch
our insert's inputs are the same as the plugin's
@ Hide
we ‘hide’ some of the plugin's inputs by feeding them silence
@ Replicate
we have multiple instances of the plugin
@ Split
we copy one of our insert's inputs to multiple plugin inputs
@ NoInputs
plugin has no inputs, so anything goes
void preset_load_set_value(uint32_t, float)
std::shared_ptr< Plugin > find_and_load_plugin(Session &, XMLNode const &, PluginType &, std::string const &, bool &any_vst)
virtual std::shared_ptr< Plugin > plugin(uint32_t num=0) const =0
Definition: xml++.h:114
#define LIBARDOUR_API
int64_t microseconds_t
Definition: microseconds.h:28
std::ostream & operator<<(std::ostream &o, const ARDOUR::PlugInsertBase::Match &m)
Match(MatchingMethod m, int32_t p, bool strict=false, bool custom=false, ChanCount h=ChanCount())
ChanCount hide
number of channels to hide
bool custom_cfg
custom config (if not strict)
int32_t plugins
number of copies of the plugin that we need
MatchingMethod method
method to employ
virtual void actually_set_value(double value, PBD::Controllable::GroupControlDisposition)
PluginPropertyControl(Session &s, PlugInsertBase *p, const Evoral::Parameter &param, const ParameterDescriptor &desc, std::shared_ptr< AutomationList > list=std::shared_ptr< AutomationList >())