Ardour  8.12
region_fx_plugin.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2024 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_region_fx_plugin_h__
20 #define __ardour_region_fx_plugin_h__
21 
22 #include <atomic>
23 
25 
26 #include "ardour/ardour.h"
28 #include "ardour/chan_mapping.h"
32 #include "ardour/plugin.h"
33 #include "ardour/types.h"
34 
35 namespace Gtkmm2ext
36 {
37 class WindowProxy;
38 }
39 
40 class XMLNode;
41 
42 namespace ARDOUR
43 {
44 class ReadOnlyControl;
45 
47 {
48 public:
49  RegionFxPlugin (Session&, Temporal::TimeDomain const, std::shared_ptr<Plugin> = std::shared_ptr<Plugin> ());
51 
52  /* UI Proxy */
54  {
55  return _window_proxy;
56  }
58  {
59  _window_proxy = wp;
60  }
61 
62  /* Latent */
64  /* TailTime */
66 
67  /* PlugInsertBase */
68  uint32_t get_count () const
69  {
70  return _plugins.size ();
71  }
72  PluginType type () const;
73 
74  std::shared_ptr<Plugin> plugin (uint32_t num = 0) const
75  {
76  if (num < _plugins.size ()) {
77  return _plugins[num];
78  } else {
79  return std::shared_ptr<Plugin>();
80  }
81  }
82 
84  std::shared_ptr<Evoral::Control> control_factory(const Evoral::Parameter& id);
85 
86  bool write_immediate_event (Evoral::EventType event_type, size_t size, const uint8_t* buf);
88 
89  std::shared_ptr<ReadOnlyControl> control_output (uint32_t) const;
90 
93 
95 
97 
98  bool provides_stats () const
99  {
100  return false;
101  }
102  bool get_stats (PBD::microseconds_t&, PBD::microseconds_t&, double&, double&) const
103  {
104  return false;
105  }
106  void clear_stats () {}
107 
108  ChanMapping input_map (uint32_t num) const {
109  if (num < _in_map.size()) {
110  return _in_map.find (num)->second;
111  } else {
112  return ChanMapping ();
113  }
114  }
115 
116  ChanMapping output_map (uint32_t num) const {
117  if (num < _out_map.size()) {
118  return _out_map.find (num)->second;
119  } else {
120  return ChanMapping ();
121  }
122  }
123 
124  /* Stateful */
125  XMLNode& get_state (void) const;
126  int set_state (const XMLNode&, int version);
127 
130 
131  /* Fx */
133 
134  void flush ();
135  int set_block_size (pframes_t nframes);
138 
141 
144 
146  {
147  return _configured_in;
148  }
150  {
151  return _configured_out;
152  }
154  {
155  return _required_buffers;
156  }
157 
158 private:
159  /* disallow copy construction */
161 
162  void add_plugin (std::shared_ptr<Plugin>);
163  void plugin_removed (std::weak_ptr<Plugin>);
164  bool set_count (uint32_t num);
165  bool check_inplace ();
167  void parameter_changed_externally (uint32_t, float);
169  bool find_next_event (timepos_t const& start, timepos_t const& end, Evoral::ControlEvent& next_event) const;
170  void start_touch (uint32_t param_id);
171  void end_touch (uint32_t param_id);
173 
175 
178 
181 
182  typedef std::vector<std::shared_ptr<Plugin>> Plugins;
184 
188 
189  std::map <uint32_t, ARDOUR::ChanMapping> _in_map;
190  std::map <uint32_t, ARDOUR::ChanMapping> _out_map;
191 
194 
196 
197  typedef std::map<uint32_t, std::shared_ptr<ReadOnlyControl>> CtrlOutMap;
199 
201  std::atomic<int> _flush;
202 
204 
205  mutable Glib::Threads::Mutex _process_lock;
206 };
207 
208 } // namespace ARDOUR
209 
210 #endif
Glib::Threads::Mutex _process_lock
void start_touch(uint32_t param_id)
std::map< uint32_t, ARDOUR::ChanMapping > _out_map
ChanCount input_streams() const
int set_block_size(pframes_t nframes)
std::shared_ptr< ReadOnlyControl > control_output(uint32_t) const
bool load_preset(Plugin::PresetRecord)
int set_state(const XMLNode &, int version)
void set_window_proxy(Gtkmm2ext::WindowProxy *wp)
void plugin_removed(std::weak_ptr< Plugin >)
samplecnt_t _plugin_signal_tailtime
void truncate_automation_start(timecnt_t)
void automatables(PBD::ControllableSet &) const
ChanCount required_buffers() const
ChanCount output_streams() const
PluginType type() const
bool configure_io(ChanCount in, ChanCount out)
RegionFxPlugin(Session &, Temporal::TimeDomain const, std::shared_ptr< Plugin >=std::shared_ptr< Plugin >())
Gtkmm2ext::WindowProxy * window_proxy() const
void automation_run(samplepos_t start, pframes_t nframes)
bool get_stats(PBD::microseconds_t &, PBD::microseconds_t &, double &, double &) const
void truncate_automation_end(timepos_t)
std::map< uint32_t, ARDOUR::ChanMapping > _in_map
void set_default_automation(timepos_t)
std::atomic< int > _flush
void update_id(PBD::ID)
void parameter_changed_externally(uint32_t, float)
ChanMapping input_map(uint32_t num) const
bool write_immediate_event(Evoral::EventType event_type, size_t size, const uint8_t *buf)
uint32_t get_count() const
std::string describe_parameter(Evoral::Parameter param)
Gtkmm2ext::WindowProxy * _window_proxy
XMLNode & get_state(void) const
bool set_count(uint32_t num)
Match private_can_support_io_configuration(ChanCount const &, ChanCount &) const
bool find_next_event(timepos_t const &start, timepos_t const &end, Evoral::ControlEvent &next_event) const
bool can_support_io_configuration(const ChanCount &in, ChanCount &out)
samplecnt_t signal_tailtime() const
bool connect_and_run(BufferSet &, samplepos_t start, samplepos_t end, samplepos_t region_pos, pframes_t nframes, sampleoffset_t buf_off, sampleoffset_t cycle_off)
UIElements ui_elements() const
ChanMapping output_map(uint32_t num) const
void maybe_emit_changed_signals() const
RegionFxPlugin(RegionFxPlugin const &)
samplecnt_t _plugin_signal_latency
samplecnt_t signal_latency() const
std::shared_ptr< Evoral::Control > control_factory(const Evoral::Parameter &id)
bool reset_parameters_to_default()
std::vector< std::shared_ptr< Plugin > > Plugins
std::shared_ptr< Plugin > plugin(uint32_t num=0) const
void end_touch(uint32_t param_id)
std::map< uint32_t, std::shared_ptr< ReadOnlyControl > > CtrlOutMap
void add_plugin(std::shared_ptr< Plugin >)
bool run(BufferSet &, samplepos_t start, samplepos_t end, samplepos_t region_pos, pframes_t nframes, sampleoffset_t off)
Definition: id.h:35
Definition: xml++.h:114
#define LIBARDOUR_API
PBD::PropertyDescriptor< timepos_t > start
uint32_t pframes_t
Temporal::samplecnt_t samplecnt_t
Temporal::sampleoffset_t sampleoffset_t
Temporal::samplepos_t samplepos_t
DebugBits ChanMapping
std::set< std::shared_ptr< Controllable > > ControllableSet
Definition: controllable.h:41
int64_t microseconds_t
Definition: microseconds.h:29