Ardour  9.0-pre0-384-ga76afae0e9
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 #pragma once
20 
21 #include <atomic>
22 
24 
25 #include "ardour/ardour.h"
27 #include "ardour/chan_mapping.h"
31 #include "ardour/plugin.h"
32 #include "ardour/types.h"
33 
34 namespace Gtkmm2ext
35 {
36 class WindowProxy;
37 }
38 
39 class XMLNode;
40 
41 namespace ARDOUR
42 {
43 class ReadOnlyControl;
44 
46 {
47 public:
48  RegionFxPlugin (Session&, Temporal::TimeDomain const, std::shared_ptr<Plugin> = std::shared_ptr<Plugin> ());
50 
51  /* UI Proxy */
53  {
54  return _window_proxy;
55  }
57  {
58  _window_proxy = wp;
59  }
60 
61  /* Latent */
63  /* TailTime */
65 
66  /* PlugInsertBase */
67  uint32_t get_count () const
68  {
69  return _plugins.size ();
70  }
71  PluginType type () const;
72 
73  std::shared_ptr<Plugin> plugin (uint32_t num = 0) const
74  {
75  if (num < _plugins.size ()) {
76  return _plugins[num];
77  } else {
78  return std::shared_ptr<Plugin>();
79  }
80  }
81 
83  std::shared_ptr<Evoral::Control> control_factory(const Evoral::Parameter& id);
84 
85  bool write_immediate_event (Evoral::EventType event_type, size_t size, const uint8_t* buf);
87 
88  std::shared_ptr<ReadOnlyControl> control_output (uint32_t) const;
89 
92 
94 
96 
97  bool provides_stats () const
98  {
99  return false;
100  }
101  bool get_stats (PBD::microseconds_t&, PBD::microseconds_t&, double&, double&) const
102  {
103  return false;
104  }
105  void clear_stats () {}
106 
107  ChanMapping input_map (uint32_t num) const {
108  if (num < _in_map.size()) {
109  return _in_map.find (num)->second;
110  } else {
111  return ChanMapping ();
112  }
113  }
114 
115  ChanMapping output_map (uint32_t num) const {
116  if (num < _out_map.size()) {
117  return _out_map.find (num)->second;
118  } else {
119  return ChanMapping ();
120  }
121  }
122 
123  /* Stateful */
124  XMLNode& get_state (void) const;
125  int set_state (const XMLNode&, int version);
126 
129 
130  /* Fx */
132 
133  void flush ();
134  int set_block_size (pframes_t nframes);
137 
140 
143 
145  {
146  return _configured_in;
147  }
149  {
150  return _configured_out;
151  }
153  {
154  return _required_buffers;
155  }
156 
157 private:
158  /* disallow copy construction */
160 
161  void add_plugin (std::shared_ptr<Plugin>);
162  void plugin_removed (std::weak_ptr<Plugin>);
163  bool set_count (uint32_t num);
164  bool check_inplace ();
166  void parameter_changed_externally (uint32_t, float);
168  bool find_next_event (timepos_t const& start, timepos_t const& end, Evoral::ControlEvent& next_event) const;
169  void start_touch (uint32_t param_id);
170  void end_touch (uint32_t param_id);
172 
174 
177 
180 
181  typedef std::vector<std::shared_ptr<Plugin>> Plugins;
183 
187 
188  std::map <uint32_t, ARDOUR::ChanMapping> _in_map;
189  std::map <uint32_t, ARDOUR::ChanMapping> _out_map;
190 
193 
195 
196  typedef std::map<uint32_t, std::shared_ptr<ReadOnlyControl>> CtrlOutMap;
198 
200  std::atomic<int> _flush;
201 
203 
204  mutable Glib::Threads::Mutex _process_lock;
205 };
206 
207 } // namespace ARDOUR
208 
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:34
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:40
int64_t microseconds_t
Definition: microseconds.h:28