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 #ifndef __ardour_delivery_h__ 24 #define __ardour_delivery_h__ 25 26 #include <string> 27 28 #include "ardour/libardour_visibility.h" 29 #include "ardour/types.h" 30 #include "ardour/chan_count.h" 31 #include "ardour/io_processor.h" 32 #include "ardour/gain_control.h" 33 34 namespace ARDOUR { 35 36 class BufferSet; 37 class IO; 38 class MuteMaster; 39 class PannerShell; 40 class Panner; 41 class Pannable; 42 43 class LIBARDOUR_API Delivery : public IOProcessor 44 { 45 public: 46 enum Role { 47 /* main outputs - delivers out-of-place to port buffers, and cannot be removed */ 48 Main = 0x1, 49 /* send - delivers to port buffers, leaves input buffers untouched */ 50 Send = 0x2, 51 /* insert - delivers to port buffers and receives in-place from port buffers */ 52 Insert = 0x4, 53 /* listen - internal send used only to deliver to control/monitor bus */ 54 Listen = 0x8, 55 /* aux - internal send used to deliver to any bus, by user request */ 56 Aux = 0x10, 57 /* foldback - internal send used only to deliver to a personal monitor bus */ 58 Foldback = 0x20 59 }; 60 role_requires_output_ports(Role r)61 static bool role_requires_output_ports (Role r) { return r == Main || r == Send || r == Insert; } 62 does_routing()63 bool does_routing() const { return true; } 64 65 /* Delivery to an existing output */ 66 67 Delivery (Session& s, boost::shared_ptr<IO> io, boost::shared_ptr<Pannable>, boost::shared_ptr<MuteMaster> mm, const std::string& name, Role); 68 69 /* Delivery to a new output owned by this object */ 70 71 Delivery (Session& s, boost::shared_ptr<Pannable>, boost::shared_ptr<MuteMaster> mm, const std::string& name, Role); 72 ~Delivery (); 73 74 bool set_name (const std::string& name); 75 std::string display_name() const; 76 role()77 Role role() const { return _role; } 78 bool can_support_io_configuration (const ChanCount& in, ChanCount& out); 79 bool configure_io (ChanCount in, ChanCount out); 80 81 void run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_sample, double speed, pframes_t nframes, bool); 82 83 /* supplemental method used with MIDI */ 84 85 void flush_buffers (samplecnt_t nframes); 86 void no_outs_cuz_we_no_monitor(bool); 87 void non_realtime_transport_stop (samplepos_t now, bool flush); 88 void realtime_locate (bool); 89 output_buffers()90 BufferSet& output_buffers() { return *_output_buffers; } 91 92 PBD::Signal0<void> MuteChange; 93 94 int set_state (const XMLNode&, int version); 95 96 /* Panning */ 97 98 static int disable_panners (void); 99 static void reset_panners (); 100 panner_shell()101 boost::shared_ptr<PannerShell> panner_shell() const { return _panshell; } 102 boost::shared_ptr<Panner> panner() const; 103 add_gain(boost::shared_ptr<GainControl> gc)104 void add_gain (boost::shared_ptr<GainControl> gc) { 105 _gain_control = gc; 106 } 107 108 void unpan (); 109 void reset_panner (); 110 void defer_pan_reset (); 111 void allow_pan_reset (); 112 pans_required()113 uint32_t pans_required() const { return _configured_input.n_audio(); } 114 virtual uint32_t pan_outs() const; 115 116 protected: 117 XMLNode& state (); 118 119 Role _role; 120 BufferSet* _output_buffers; 121 gain_t _current_gain; 122 boost::shared_ptr<PannerShell> _panshell; 123 124 gain_t target_gain (); 125 126 private: 127 bool _no_outs_cuz_we_no_monitor; 128 129 boost::shared_ptr<MuteMaster> _mute_master; 130 boost::shared_ptr<GainControl> _gain_control; 131 132 static bool panners_legal; 133 static PBD::Signal0<void> PannersLegal; 134 135 void panners_became_legal (); 136 PBD::ScopedConnection panner_legal_c; 137 void output_changed (IOChange, void*); 138 139 bool _no_panner_reset; 140 }; 141 142 143 } // namespace ARDOUR 144 145 #endif // __ardour__h__ 146 147