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