Strip trailing whitespace and fix other whitespace errors (e.g. space/tab mixing...
[ardour.git] / libs / ardour / ardour / delivery.h
1 /*
2     Copyright (C) 2006 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify it
5     under the terms of the GNU General Public License as published by the Free
6     Software Foundation; either version 2 of the License, or (at your option)
7     any later version.
8
9     This program is distributed in the hope that it will be useful, but WITHOUT
10     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12     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     675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19 #ifndef __ardour_delivery_h__
20 #define __ardour_delivery_h__
21
22 #include <string>
23 #include "ardour/types.h"
24 #include "ardour/chan_count.h"
25 #include "ardour/io_processor.h"
26
27 namespace ARDOUR {
28
29 class BufferSet;
30 class IO;
31 class MuteMaster;
32 class Panner;
33
34 class Delivery : public IOProcessor {
35 public:
36         enum Role {
37                 /* main outputs - delivers out-of-place to port buffers, and cannot be removed */
38                 Main   = 0x1,
39                 /* send - delivers to port buffers, leaves input buffers untouched */
40                 Send   = 0x2,
41                 /* insert - delivers to port buffers and receives in-place from port buffers */
42                 Insert = 0x4,
43                 /* listen - internal send used only to deliver to control/monitor bus */
44                 Listen = 0x8,
45                 /* aux - internal send used to deliver to any bus, by user request */
46                 Aux    = 0x10
47         };
48
49         static bool role_requires_output_ports (Role r) { return r == Main || r == Send || r == Insert; }
50
51         /* Delivery to an existing output */
52
53         Delivery (Session& s, boost::shared_ptr<IO> io, boost::shared_ptr<MuteMaster> mm, const std::string& name, Role);
54         Delivery (Session& s, boost::shared_ptr<IO> io, boost::shared_ptr<MuteMaster> mm, const XMLNode&);
55
56         /* Delivery to a new output owned by this object */
57
58         Delivery (Session& s, boost::shared_ptr<MuteMaster> mm, const std::string& name, Role);
59         Delivery (Session&, boost::shared_ptr<MuteMaster> mm, const XMLNode&);
60
61         bool set_name (const std::string& name);
62         std::string display_name() const;
63
64         bool visible() const;
65         Role role() const { return _role; }
66         bool can_support_io_configuration (const ChanCount& in, ChanCount& out) const;
67         bool configure_io (ChanCount in, ChanCount out);
68
69         void run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes);
70
71         /* supplemental method use with MIDI */
72
73         void flush (nframes_t nframes);
74
75         void no_outs_cuz_we_no_monitor(bool);
76
77         void set_solo_level (int32_t sl) { _solo_level = sl; }
78         void set_solo_isolated (bool yn) { _solo_isolated = yn; }
79
80         void cycle_start (nframes_t);
81         void increment_output_offset (nframes_t);
82         void transport_stopped (sframes_t frame);
83
84         BufferSet& output_buffers() { return *_output_buffers; }
85
86         sigc::signal<void> MuteChange;
87
88         static sigc::signal<void,nframes_t> CycleStart;
89
90         XMLNode& state (bool full);
91         int set_state (const XMLNode&);
92
93         /* Panning */
94
95         static int  disable_panners (void);
96         static int  reset_panners (void);
97
98         boost::shared_ptr<Panner> panner() const { return _panner; }
99
100         void reset_panner ();
101         void defer_pan_reset ();
102         void allow_pan_reset ();
103
104         uint32_t pans_required() const { return _configured_input.n_audio(); }
105         void start_pan_touch (uint32_t which);
106         void end_pan_touch (uint32_t which);
107
108   protected:
109         Role        _role;
110         BufferSet*  _output_buffers;
111         gain_t      _current_gain;
112         nframes_t   _output_offset;
113         bool        _no_outs_cuz_we_no_monitor;
114         uint32_t    _solo_level;
115         bool        _solo_isolated;
116         boost::shared_ptr<MuteMaster> _mute_master;
117         bool         no_panner_reset;
118         boost::shared_ptr<Panner> _panner;
119
120         static bool panners_legal;
121         static sigc::signal<int>            PannersLegal;
122
123         int panners_became_legal ();
124         sigc::connection panner_legal_c;
125         void output_changed (IOChange, void*);
126
127         gain_t target_gain ();
128 };
129
130
131 } // namespace ARDOUR
132
133 #endif // __ardour__h__
134