Ardour  9.2-79-gba93f2fe52
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 "pbd/mutex.h"
26 
27 #include "ardour/ardour.h"
29 #include "ardour/chan_mapping.h"
33 #include "ardour/plugin.h"
34 #include "ardour/types.h"
35 
36 namespace Gtkmm2ext
37 {
38 class WindowProxy;
39 }
40 
41 class XMLNode;
42 
43 namespace ARDOUR
44 {
45 class ReadOnlyControl;
46 
48 {
49 public:
50  RegionFxPlugin (Session&, Temporal::TimeDomain const, std::shared_ptr<Plugin> = std::shared_ptr<Plugin> ());
52 
53  /* UI Proxy */
55  {
56  return _window_proxy;
57  }
59  {
60  _window_proxy = wp;
61  }
62 
63  /* Latent */
65  /* TailTime */
67 
68  /* PlugInsertBase */
69  uint32_t get_count () const
70  {
71  return _plugins.size ();
72  }
73  PluginType type () const;
74 
75  std::shared_ptr<Plugin> plugin (uint32_t num = 0) const
76  {
77  if (num < _plugins.size ()) {
78  return _plugins[num];
79  } else {
80  return std::shared_ptr<Plugin>();
81  }
82  }
83 
85  std::shared_ptr<Evoral::Control> control_factory(const Evoral::Parameter& id);
86 
87  bool write_immediate_event (Evoral::EventType event_type, size_t size, const uint8_t* buf);
89 
90  std::shared_ptr<ReadOnlyControl> control_output (uint32_t) const;
91 
94 
96 
98 
99  bool provides_stats () const
100  {
101  return false;
102  }
103  bool get_stats (PBD::microseconds_t&, PBD::microseconds_t&, double&, double&) const
104  {
105  return false;
106  }
107  void clear_stats () {}
108 
109  ChanMapping input_map (uint32_t num) const {
110  if (num < _in_map.size()) {
111  return _in_map.find (num)->second;
112  } else {
113  return ChanMapping ();
114  }
115  }
116 
117  ChanMapping output_map (uint32_t num) const {
118  if (num < _out_map.size()) {
119  return _out_map.find (num)->second;
120  } else {
121  return ChanMapping ();
122  }
123  }
124 
125  /* Stateful */
126  XMLNode& get_state (void) const;
127  int set_state (const XMLNode&, int version);
128 
131 
132  /* Fx */
134 
135  void flush ();
136  int set_block_size (pframes_t nframes);
139 
143 
146 
148  {
149  return _configured_in;
150  }
152  {
153  return _configured_out;
154  }
156  {
157  return _required_buffers;
158  }
159 
160 private:
161  /* disallow copy construction */
163 
164  void add_plugin (std::shared_ptr<Plugin>);
165  void plugin_removed (std::weak_ptr<Plugin>);
166  bool set_count (uint32_t num);
167  bool check_inplace ();
169  void parameter_changed_externally (uint32_t, float);
172  bool find_next_event (timepos_t const& start, timepos_t const& end, Evoral::ControlEvent& next_event) const;
173  void start_touch (uint32_t param_id);
174  void end_touch (uint32_t param_id);
176 
178 
181 
184 
185  typedef std::vector<std::shared_ptr<Plugin>> Plugins;
187 
191 
192  std::map <uint32_t, ARDOUR::ChanMapping> _in_map;
193  std::map <uint32_t, ARDOUR::ChanMapping> _out_map;
194 
197 
199 
200  typedef std::map<uint32_t, std::shared_ptr<ReadOnlyControl>> CtrlOutMap;
202 
204  std::atomic<int> _flush;
205 
207 
209 };
210 
211 } // namespace ARDOUR
212 
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 x_scale_automation(Temporal::ratio_t)
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
void property_changed_externally(uint32_t, Variant)
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:33
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:39
int64_t microseconds_t
Definition: microseconds.h:28