Ardour  9.0-rc1-21-gd5464b39db
io_plug.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 _libardour_io_plug_h_
20 #define _libardour_io_plug_h_
21 
22 #include <atomic>
23 
24 #include "pbd/timing.h"
25 
26 #include "ardour/ardour.h"
28 #include "ardour/buffer_set.h"
29 #include "ardour/latent.h"
30 #include "ardour/graphnode.h"
31 #include "ardour/plugin.h"
32 #include "ardour/port_manager.h"
33 #include "ardour/session_object.h"
35 
36 namespace Gtkmm2ext {
37 class WindowProxy;
38 }
39 
40 namespace ARDOUR {
41 
42 class IO;
43 class ReadOnlyControl;
44 
45 class LIBARDOUR_API IOPlug : public SessionObject, public PlugInsertBase, public Latent, public GraphNode
46 {
47 public:
48  IOPlug (Session&, std::shared_ptr<Plugin> = std::shared_ptr<Plugin>(), bool pre = true);
49  virtual ~IOPlug ();
50 
51  bool set_name (std::string const&);
52 
53  std::string io_name (std::string const& name = "") const;
54 
55  XMLNode& get_state (void) const;
56  int set_state (const XMLNode&, int version);
57 
60  void set_public_latency (bool);
61  bool ensure_io ();
63 
64  bool is_pre () const { return _pre; }
65 
66  std::shared_ptr<IO> input () const { return _input; }
67  std::shared_ptr<IO> output () const { return _output; }
68 
69  Gtkmm2ext::WindowProxy* window_proxy () const { return _window_proxy; }
70  void set_window_proxy (Gtkmm2ext::WindowProxy* wp) { _window_proxy = wp; }
71 
72  PortManager::AudioInputPorts audio_input_ports () const { return _audio_input_ports; }
73  PortManager::MIDIInputPorts midi_input_ports () const { return _midi_input_ports; }
74 
76 
77  /* Latent */
79 
80  /* PlugInsertBase */
81  uint32_t get_count () const { return 1; }
82  std::shared_ptr<Plugin> plugin (uint32_t num = 0) const { return _plugin; }
83  PluginType type () const { return _plugin->get_info()->type; }
84 
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 
95  virtual bool provides_stats () const { return true; }
96  virtual bool get_stats (PBD::microseconds_t&, PBD::microseconds_t&, double&, double&) const;
97  virtual void clear_stats ();
98 
99  ChanMapping input_map (uint32_t num) const;
100  ChanMapping output_map (uint32_t num) const;
101 
102  /* ControlSet */
103  std::shared_ptr<Evoral::Control> control_factory (const Evoral::Parameter& id);
104 
105  /* GraphNode */
106  std::string graph_node_name () const {
107  return name ();
108  }
109  bool direct_feeds_according_to_reality (std::shared_ptr<GraphNode>, bool* via_send_only = 0);
110  void process ();
111 
112 protected:
114 
115 private:
116  /* disallow copy construction */
117  IOPlug (IOPlug const&);
118 
119  std::string ensure_io_name (std::string) const;
121  void parameter_changed_externally (uint32_t, float);
124 
125  void setup ();
126 
130  bool _pre;
132 
133  typedef std::map<uint32_t, std::shared_ptr<ReadOnlyControl> >CtrlOutMap;
135 
137  std::shared_ptr<IO> _input;
138  std::shared_ptr<IO> _output;
140 
143 
145 
147  std::atomic<int> _stat_reset;
148  std::atomic<int> _reset_meters;
149 };
150 
151 }
152 #endif
void create_parameters()
virtual bool get_stats(PBD::microseconds_t &, PBD::microseconds_t &, double &, double &) const
uint32_t get_count() const
Definition: io_plug.h:81
bool can_reset_all_parameters()
ChanCount _n_in
Definition: io_plug.h:127
int set_state(const XMLNode &, int version)
void connect_and_run(samplepos_t, pframes_t)
PBD::TimingStats _timing_stats
Definition: io_plug.h:146
bool write_immediate_event(Evoral::EventType event_type, size_t size, const uint8_t *buf)
ChanMapping input_map(uint32_t num) const
BufferSet _bufs
Definition: io_plug.h:136
XMLNode & get_state(void) const
std::atomic< int > _reset_meters
Definition: io_plug.h:148
void processor_change(RouteProcessorChange const &)
std::shared_ptr< Plugin > plugin(uint32_t num=0) const
Definition: io_plug.h:82
samplecnt_t signal_latency() const
bool _configuring_io
Definition: io_plug.h:139
bool reset_parameters_to_default()
uint32_t _plugin_signal_latency
Definition: io_plug.h:131
void set_window_proxy(Gtkmm2ext::WindowProxy *wp)
Definition: io_plug.h:70
std::shared_ptr< IO > input() const
Definition: io_plug.h:66
ChanMapping output_map(uint32_t num) const
std::shared_ptr< IO > _output
Definition: io_plug.h:138
void reset_input_meters()
bool load_preset(Plugin::PresetRecord)
int set_block_size(pframes_t)
std::shared_ptr< Evoral::Control > control_factory(const Evoral::Parameter &id)
PortManager::MIDIInputPorts midi_input_ports() const
Definition: io_plug.h:73
PortManager::MIDIInputPorts _midi_input_ports
Definition: io_plug.h:142
Gtkmm2ext::WindowProxy * window_proxy() const
Definition: io_plug.h:69
Gtkmm2ext::WindowProxy * _window_proxy
Definition: io_plug.h:144
UIElements ui_elements() const
virtual void clear_stats()
void parameter_changed_externally(uint32_t, float)
std::string graph_node_name() const
Definition: io_plug.h:106
std::shared_ptr< IO > output() const
Definition: io_plug.h:67
virtual ~IOPlug()
void property_changed_externally(uint32_t, Variant)
bool direct_feeds_according_to_reality(std::shared_ptr< GraphNode >, bool *via_send_only=0)
std::shared_ptr< IO > _input
Definition: io_plug.h:137
std::string ensure_io_name(std::string) const
IOPlug(IOPlug const &)
virtual bool provides_stats() const
Definition: io_plug.h:95
bool set_name(std::string const &)
std::shared_ptr< ReadOnlyControl > control_output(uint32_t) const
std::atomic< int > _stat_reset
Definition: io_plug.h:147
ChanCount _n_out
Definition: io_plug.h:128
bool is_pre() const
Definition: io_plug.h:64
PluginPtr _plugin
Definition: io_plug.h:129
PortManager::AudioInputPorts audio_input_ports() const
Definition: io_plug.h:72
std::string io_name(std::string const &name="") const
std::string describe_parameter(Evoral::Parameter)
CtrlOutMap _control_outputs
Definition: io_plug.h:134
IOPlug(Session &, std::shared_ptr< Plugin >=std::shared_ptr< Plugin >(), bool pre=true)
PortManager::AudioInputPorts _audio_input_ports
Definition: io_plug.h:141
void set_public_latency(bool)
PluginType type() const
Definition: io_plug.h:83
std::map< uint32_t, std::shared_ptr< ReadOnlyControl > > CtrlOutMap
Definition: io_plug.h:133
void set_pretty_port_names()
std::map< std::string, AudioInputPort, SortByPortName > AudioInputPorts
Definition: port_manager.h:115
std::map< std::string, MIDIInputPort, SortByPortName > MIDIInputPorts
Definition: port_manager.h:116
Definition: xml++.h:114
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBARDOUR_API
uint32_t pframes_t
std::shared_ptr< Plugin > PluginPtr
Definition: plugin.h:61
Temporal::samplecnt_t samplecnt_t
Temporal::samplepos_t samplepos_t
int64_t microseconds_t
Definition: microseconds.h:28