Ardour  9.2-79-gba93f2fe52
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 #if __cplusplus >= 202002L
28 #include <memory>
29 #else
30 #include <boost/smart_ptr/atomic_shared_ptr.hpp>
31 #endif
32 
33 #include "pbd/ringbuffer.h"
34 
36 #include "ardour/types.h"
37 #include "ardour/chan_count.h"
38 #include "ardour/io_processor.h"
39 #include "ardour/midi_buffer.h"
40 #include "ardour/gain_control.h"
41 
42 namespace ARDOUR {
43 
44 class Amp;
45 class BufferSet;
46 class IO;
47 class MuteMaster;
48 class PannerShell;
49 class Panner;
50 class Pannable;
51 
53 {
54 public:
55  enum Role {
56  /* main outputs - delivers out-of-place to port buffers, and cannot be removed */
57  Main = 0x1,
58  /* send - delivers to port buffers, leaves input buffers untouched */
59  Send = 0x2,
60  /* insert - delivers to port buffers and receives in-place from port buffers */
61  Insert = 0x4,
62  /* listen - internal send used only to deliver to control/monitor bus */
63  Listen = 0x8,
64  /* aux - internal send used to deliver to any bus, by user request */
65  Aux = 0x10,
66  /* foldback - internal send used only to deliver to a personal monitor bus */
67  Foldback = 0x20,
68  /* direct outs - used only with LiveTrax, delivers to master bus */
69  DirectOuts = 0x40
70  };
71 
72  static bool role_from_xml (const XMLNode&, Role&);
73 
74  static bool role_requires_output_ports (Role r) { return r == Main || r == Send || r == Insert || r == DirectOuts; }
75 
76  bool does_routing() const { return true; }
77 
78  /* Delivery to an existing output */
79 
80  Delivery (Session& s, std::shared_ptr<IO> io, std::shared_ptr<Pannable>, std::shared_ptr<MuteMaster> mm, const std::string& name, Role);
81 
82  /* Delivery to a new output owned by this object */
83 
84  Delivery (Session& s, std::shared_ptr<Pannable>, std::shared_ptr<MuteMaster> mm, const std::string& name, Role);
86 
87  bool set_name (const std::string& name);
88  std::string display_name() const;
89 
90  Role role() const { return _role; }
93 
94  void activate ();
95  void deactivate ();
96 
97  void run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_sample, double speed, pframes_t nframes, bool);
98 
99  void set_midi_mute_mask (int);
100 
101  /* supplemental method used with MIDI */
102 
103  void flush_buffers (samplecnt_t nframes);
106  void realtime_locate (bool);
107 
108  BufferSet& output_buffers() { return *_output_buffers; }
109 
111 
112  int set_state (const XMLNode&, int version);
113 
114  /* Panning */
115 
116  static int disable_panners (void);
117  static void reset_panners ();
118 
119  std::shared_ptr<PannerShell> panner_shell() const { return _panshell; }
120  std::shared_ptr<Panner> panner() const;
121 
122  void set_gain_control (std::shared_ptr<GainControl> gc);
123 
125  using RTARingBufferPtr = std::shared_ptr<RTARingBuffer>;
126  using RTABufferList = std::vector<RTARingBufferPtr>;
127 #if __cplusplus >= 202002L
128  using RTABufferListPtr = std::shared_ptr<RTABufferList>;
129 #else
130  using RTABufferListPtr = boost::shared_ptr<RTABufferList>;
131 #endif
132 
134  _rtabuffers.store (rb);
135  }
136  bool analysis_active () const;
137  void set_analysis_active (bool);
138 
139  void set_polarity_control (std::shared_ptr<AutomationControl> ac) {
140  _polarity_control = ac;
141  }
142 
143  void unpan ();
144  void reset_panner ();
147 
148  uint32_t pans_required() const { return _configured_input.n_audio(); }
149  virtual uint32_t pan_outs() const;
150 
151  std::shared_ptr<GainControl> gain_control () const {
152  return _gain_control;
153  }
154 
155  std::shared_ptr<AutomationControl> polarity_control () const {
156  return _polarity_control;
157  }
158 
159  std::shared_ptr<Amp> amp() const {
160  return _amp;
161  }
162 
163 protected:
164  XMLNode& state () const;
165 
169  std::shared_ptr<PannerShell> _panshell;
170  std::shared_ptr<Amp> _amp;
171 
173  void maybe_merge_midi_mute (BufferSet&, bool always);
174 
175 private:
177 
178  std::shared_ptr<MuteMaster> _mute_master;
179  std::shared_ptr<GainControl> _gain_control;
180  std::shared_ptr<AutomationControl> _polarity_control;
181 
182 #if __cplusplus >= 202002L
183  std::atomic<std::shared_ptr<RTABufferList>> _rtabuffers;
184 #else
185  boost::atomic_shared_ptr<RTABufferList> _rtabuffers;
186 #endif
187  std::atomic<bool> _rta_active;
188 
189  static bool panners_legal;
190  static PBD::Signal<void()> PannersLegal;
191 
195 
197  std::atomic<int> _midi_mute_mask;
199 
201 };
202 
203 
204 } // namespace ARDOUR
std::shared_ptr< AutomationControl > _polarity_control
Definition: delivery.h:180
uint32_t pans_required() const
Definition: delivery.h:148
std::shared_ptr< MuteMaster > _mute_master
Definition: delivery.h:178
void set_polarity_control(std::shared_ptr< AutomationControl > ac)
Definition: delivery.h:139
std::shared_ptr< GainControl > gain_control() const
Definition: delivery.h:151
XMLNode & state() const
void realtime_locate(bool)
void no_outs_cuz_we_no_monitor(bool)
bool does_routing() const
Definition: delivery.h:76
void defer_pan_reset()
std::shared_ptr< Panner > panner() const
std::string display_name() const
bool _no_panner_reset
Definition: delivery.h:196
BufferSet & output_buffers()
Definition: delivery.h:108
std::atomic< int > _midi_mute_mask
Definition: delivery.h:197
boost::shared_ptr< RTABufferList > RTABufferListPtr
Definition: delivery.h:130
static bool panners_legal
Definition: delivery.h:189
std::vector< RTARingBufferPtr > RTABufferList
Definition: delivery.h:126
PBD::ScopedConnection panner_legal_c
Definition: delivery.h:193
void set_analysis_buffers(RTABufferListPtr rb)
Definition: delivery.h:133
gain_t _current_gain
Definition: delivery.h:168
std::shared_ptr< AutomationControl > polarity_control() const
Definition: delivery.h:155
std::atomic< bool > _rta_active
Definition: delivery.h:187
std::shared_ptr< Amp > _amp
Definition: delivery.h:170
std::shared_ptr< PannerShell > panner_shell() const
Definition: delivery.h:119
void set_gain_control(std::shared_ptr< GainControl > gc)
void output_changed(IOChange)
std::shared_ptr< RTARingBuffer > RTARingBufferPtr
Definition: delivery.h:125
Delivery(Session &s, std::shared_ptr< Pannable >, std::shared_ptr< MuteMaster > mm, const std::string &name, Role)
virtual uint32_t pan_outs() const
boost::atomic_shared_ptr< RTABufferList > _rtabuffers
Definition: delivery.h:185
std::shared_ptr< Amp > amp() const
Definition: delivery.h:159
bool analysis_active() const
static PBD::Signal< void()> PannersLegal
Definition: delivery.h:190
gain_t target_gain()
static int disable_panners(void)
BufferSet * _output_buffers
Definition: delivery.h:167
bool configure_io(ChanCount in, ChanCount out)
void set_analysis_active(bool)
void panners_became_legal()
void flush_buffers(samplecnt_t nframes)
void resize_midi_mute_buffer()
void set_midi_mute_mask(int)
bool can_support_io_configuration(const ChanCount &in, ChanCount &out)
Role role() const
Definition: delivery.h:90
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:169
void allow_pan_reset()
PBD::Signal< void()> MuteChange
Definition: delivery.h:110
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:179
int set_state(const XMLNode &, int version)
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:176
static bool role_requires_output_ports(Role r)
Definition: delivery.h:74
void maybe_merge_midi_mute(BufferSet &, bool always)
MidiBuffer _midi_mute_buffer
Definition: delivery.h:198
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()