Ardour  9.0-pre0-1048-gdef69dd383
delivery.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009-2011 David Robillard <d@drobilla.net>
3  * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
4  * Copyright (C) 2009-2017 Paul Davis <paul@linuxaudiosystems.com>
5  * Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
6  * Copyright (C) 2018 Len Ovens <len@ovenwerks.net>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 
23 #pragma once
24 
25 #include <string>
26 
27 #include "pbd/ringbuffer.h"
28 
30 #include "ardour/types.h"
31 #include "ardour/chan_count.h"
32 #include "ardour/io_processor.h"
33 #include "ardour/gain_control.h"
34 
35 namespace ARDOUR {
36 
37 class Amp;
38 class BufferSet;
39 class IO;
40 class MuteMaster;
41 class PannerShell;
42 class Panner;
43 class Pannable;
44 
46 {
47 public:
48  enum Role {
49  /* main outputs - delivers out-of-place to port buffers, and cannot be removed */
50  Main = 0x1,
51  /* send - delivers to port buffers, leaves input buffers untouched */
52  Send = 0x2,
53  /* insert - delivers to port buffers and receives in-place from port buffers */
54  Insert = 0x4,
55  /* listen - internal send used only to deliver to control/monitor bus */
56  Listen = 0x8,
57  /* aux - internal send used to deliver to any bus, by user request */
58  Aux = 0x10,
59  /* foldback - internal send used only to deliver to a personal monitor bus */
60  Foldback = 0x20,
61  /* direct outs - used only with LiveTrax, delivers to master bus */
62  DirectOuts = 0x40
63  };
64 
65  static bool role_from_xml (const XMLNode&, Role&);
66 
67  static bool role_requires_output_ports (Role r) { return r == Main || r == Send || r == Insert || r == DirectOuts; }
68 
69  bool does_routing() const { return true; }
70 
71  /* Delivery to an existing output */
72 
73  Delivery (Session& s, std::shared_ptr<IO> io, std::shared_ptr<Pannable>, std::shared_ptr<MuteMaster> mm, const std::string& name, Role);
74 
75  /* Delivery to a new output owned by this object */
76 
77  Delivery (Session& s, std::shared_ptr<Pannable>, std::shared_ptr<MuteMaster> mm, const std::string& name, Role);
79 
80  bool set_name (const std::string& name);
81  std::string display_name() const;
82 
83  Role role() const { return _role; }
86 
87  void activate ();
88  void deactivate ();
89 
90  void run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_sample, double speed, pframes_t nframes, bool);
91 
92  /* supplemental method used with MIDI */
93 
94  void flush_buffers (samplecnt_t nframes);
97  void realtime_locate (bool);
98 
99  BufferSet& output_buffers() { return *_output_buffers; }
100 
102 
103  int set_state (const XMLNode&, int version);
104 
105  /* Panning */
106 
107  static int disable_panners (void);
108  static void reset_panners ();
109 
110  std::shared_ptr<PannerShell> panner_shell() const { return _panshell; }
111  std::shared_ptr<Panner> panner() const;
112 
113  void set_gain_control (std::shared_ptr<GainControl> gc);
114 
116  using RTARingBufferPtr = std::shared_ptr<RTARingBuffer>;
117  using RTABufferList = std::vector<RTARingBufferPtr>;
118  using RTABufferListPtr = std::shared_ptr<RTABufferList>;
119 
121  _rtabuffers = rb;
122  }
123  bool analysis_active () const;
124  void set_analysis_active (bool);
125 
126  void set_polarity_control (std::shared_ptr<AutomationControl> ac) {
127  _polarity_control = ac;
128  }
129 
130  void unpan ();
131  void reset_panner ();
134 
135  uint32_t pans_required() const { return _configured_input.n_audio(); }
136  virtual uint32_t pan_outs() const;
137 
138  std::shared_ptr<GainControl> gain_control () const {
139  return _gain_control;
140  }
141 
142  std::shared_ptr<AutomationControl> polarity_control () const {
143  return _polarity_control;
144  }
145 
146  std::shared_ptr<Amp> amp() const {
147  return _amp;
148  }
149 
150 protected:
151  XMLNode& state () const;
152 
156  std::shared_ptr<PannerShell> _panshell;
157  std::shared_ptr<Amp> _amp;
158 
160 
161 private:
163 
164  std::shared_ptr<MuteMaster> _mute_master;
165  std::shared_ptr<GainControl> _gain_control;
166  std::shared_ptr<AutomationControl> _polarity_control;
167 
169  std::atomic<bool> _rta_active;
170 
171  static bool panners_legal;
172  static PBD::Signal<void()> PannersLegal;
173 
176  void output_changed (IOChange, void*);
177 
179 };
180 
181 
182 } // namespace ARDOUR
std::shared_ptr< AutomationControl > _polarity_control
Definition: delivery.h:166
uint32_t pans_required() const
Definition: delivery.h:135
std::shared_ptr< MuteMaster > _mute_master
Definition: delivery.h:164
void set_polarity_control(std::shared_ptr< AutomationControl > ac)
Definition: delivery.h:126
std::shared_ptr< GainControl > gain_control() const
Definition: delivery.h:138
XMLNode & state() const
void realtime_locate(bool)
void no_outs_cuz_we_no_monitor(bool)
bool does_routing() const
Definition: delivery.h:69
void defer_pan_reset()
std::shared_ptr< Panner > panner() const
std::string display_name() const
bool _no_panner_reset
Definition: delivery.h:178
BufferSet & output_buffers()
Definition: delivery.h:99
static bool panners_legal
Definition: delivery.h:171
std::vector< RTARingBufferPtr > RTABufferList
Definition: delivery.h:117
PBD::ScopedConnection panner_legal_c
Definition: delivery.h:175
void set_analysis_buffers(RTABufferListPtr rb)
Definition: delivery.h:120
gain_t _current_gain
Definition: delivery.h:155
std::shared_ptr< AutomationControl > polarity_control() const
Definition: delivery.h:142
std::atomic< bool > _rta_active
Definition: delivery.h:169
std::shared_ptr< Amp > _amp
Definition: delivery.h:157
std::shared_ptr< PannerShell > panner_shell() const
Definition: delivery.h:110
void set_gain_control(std::shared_ptr< GainControl > gc)
RTABufferListPtr _rtabuffers
Definition: delivery.h:168
std::shared_ptr< RTARingBuffer > RTARingBufferPtr
Definition: delivery.h:116
Delivery(Session &s, std::shared_ptr< Pannable >, std::shared_ptr< MuteMaster > mm, const std::string &name, Role)
virtual uint32_t pan_outs() const
std::shared_ptr< Amp > amp() const
Definition: delivery.h:146
bool analysis_active() const
static PBD::Signal< void()> PannersLegal
Definition: delivery.h:172
gain_t target_gain()
static int disable_panners(void)
BufferSet * _output_buffers
Definition: delivery.h:154
bool configure_io(ChanCount in, ChanCount out)
void set_analysis_active(bool)
void panners_became_legal()
void flush_buffers(samplecnt_t nframes)
bool can_support_io_configuration(const ChanCount &in, ChanCount &out)
Role role() const
Definition: delivery.h:83
static bool role_from_xml(const XMLNode &, Role &)
void non_realtime_transport_stop(samplepos_t now, bool flush)
std::shared_ptr< PannerShell > _panshell
Definition: delivery.h:156
void allow_pan_reset()
PBD::Signal< void()> MuteChange
Definition: delivery.h:101
static void reset_panners()
void run(BufferSet &bufs, samplepos_t start_sample, samplepos_t end_sample, double speed, pframes_t nframes, bool)
std::shared_ptr< GainControl > _gain_control
Definition: delivery.h:165
int set_state(const XMLNode &, int version)
void output_changed(IOChange, void *)
std::shared_ptr< RTABufferList > RTABufferListPtr
Definition: delivery.h:118
Delivery(Session &s, std::shared_ptr< IO > io, std::shared_ptr< Pannable >, std::shared_ptr< MuteMaster > mm, const std::string &name, Role)
bool _no_outs_cuz_we_no_monitor
Definition: delivery.h:162
static bool role_requires_output_ports(Role r)
Definition: delivery.h:67
bool set_name(const std::string &name)
Definition: xml++.h:114
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBARDOUR_API
uint32_t pframes_t
Temporal::samplecnt_t samplecnt_t
Temporal::samplepos_t samplepos_t
void flush()