Ardour  8.7-15-gadf511264b
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 ();
62 
63  bool is_pre () const { return _pre; }
64 
65  std::shared_ptr<IO> input () const { return _input; }
66  std::shared_ptr<IO> output () const { return _output; }
67 
68  Gtkmm2ext::WindowProxy* window_proxy () const { return _window_proxy; }
69  void set_window_proxy (Gtkmm2ext::WindowProxy* wp) { _window_proxy = wp; }
70 
71  PortManager::AudioInputPorts audio_input_ports () const { return _audio_input_ports; }
72  PortManager::MIDIInputPorts midi_input_ports () const { return _midi_input_ports; }
73 
75 
76  /* Latent */
78 
79  /* PlugInsertBase */
80  uint32_t get_count () const { return 1; }
81  std::shared_ptr<Plugin> plugin (uint32_t num = 0) const { return _plugin; }
82  PluginType type () const { return _plugin->get_info()->type; }
83 
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 
94  virtual bool provides_stats () const { return true; }
95  virtual bool get_stats (PBD::microseconds_t&, PBD::microseconds_t&, double&, double&) const;
96  virtual void clear_stats ();
97 
98  ChanMapping input_map (uint32_t num) const;
99  ChanMapping output_map (uint32_t num) const;
100 
101  /* ControlSet */
102  std::shared_ptr<Evoral::Control> control_factory (const Evoral::Parameter& id);
103 
104  /* GraphNode */
105  std::string graph_node_name () const {
106  return name ();
107  }
108  bool direct_feeds_according_to_reality (std::shared_ptr<GraphNode>, bool* via_send_only = 0);
109  void process ();
110 
111 protected:
113 
114 private:
115  /* disallow copy construction */
116  IOPlug (IOPlug const&);
117 
118  std::string ensure_io_name (std::string) const;
120  void parameter_changed_externally (uint32_t, float);
121 
122  void setup ();
123 
127  bool _pre;
129 
130  typedef std::map<uint32_t, std::shared_ptr<ReadOnlyControl> >CtrlOutMap;
132 
134  std::shared_ptr<IO> _input;
135  std::shared_ptr<IO> _output;
137 
140 
142 
144  std::atomic<int> _stat_reset;
145  std::atomic<int> _reset_meters;
146 };
147 
148 }
149 #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:80
bool can_reset_all_parameters()
ChanCount _n_in
Definition: io_plug.h:124
int set_state(const XMLNode &, int version)
void connect_and_run(samplepos_t, pframes_t)
PBD::TimingStats _timing_stats
Definition: io_plug.h:143
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:133
XMLNode & get_state(void) const
std::atomic< int > _reset_meters
Definition: io_plug.h:145
std::shared_ptr< Plugin > plugin(uint32_t num=0) const
Definition: io_plug.h:81
samplecnt_t signal_latency() const
bool _configuring_io
Definition: io_plug.h:136
bool reset_parameters_to_default()
uint32_t _plugin_signal_latency
Definition: io_plug.h:128
void set_window_proxy(Gtkmm2ext::WindowProxy *wp)
Definition: io_plug.h:69
std::shared_ptr< IO > input() const
Definition: io_plug.h:65
ChanMapping output_map(uint32_t num) const
std::shared_ptr< IO > _output
Definition: io_plug.h:135
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:72
PortManager::MIDIInputPorts _midi_input_ports
Definition: io_plug.h:139
Gtkmm2ext::WindowProxy * window_proxy() const
Definition: io_plug.h:68
Gtkmm2ext::WindowProxy * _window_proxy
Definition: io_plug.h:141
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:105
std::shared_ptr< IO > output() const
Definition: io_plug.h:66
virtual ~IOPlug()
bool direct_feeds_according_to_reality(std::shared_ptr< GraphNode >, bool *via_send_only=0)
std::shared_ptr< IO > _input
Definition: io_plug.h:134
std::string ensure_io_name(std::string) const
IOPlug(IOPlug const &)
virtual bool provides_stats() const
Definition: io_plug.h:94
bool set_name(std::string const &)
std::shared_ptr< ReadOnlyControl > control_output(uint32_t) const
std::atomic< int > _stat_reset
Definition: io_plug.h:144
ChanCount _n_out
Definition: io_plug.h:125
bool is_pre() const
Definition: io_plug.h:63
PluginPtr _plugin
Definition: io_plug.h:126
PortManager::AudioInputPorts audio_input_ports() const
Definition: io_plug.h:71
std::string io_name(std::string const &name="") const
std::string describe_parameter(Evoral::Parameter)
CtrlOutMap _control_outputs
Definition: io_plug.h:131
IOPlug(Session &, std::shared_ptr< Plugin >=std::shared_ptr< Plugin >(), bool pre=true)
PortManager::AudioInputPorts _audio_input_ports
Definition: io_plug.h:138
void set_public_latency(bool)
PluginType type() const
Definition: io_plug.h:82
std::map< uint32_t, std::shared_ptr< ReadOnlyControl > > CtrlOutMap
Definition: io_plug.h:130
std::map< std::string, AudioInputPort, SortByPortName > AudioInputPorts
Definition: port_manager.h:116
std::map< std::string, MIDIInputPort, SortByPortName > MIDIInputPorts
Definition: port_manager.h:117
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:63
Temporal::samplecnt_t samplecnt_t
Temporal::samplepos_t samplepos_t
int64_t microseconds_t
Definition: microseconds.h:29