rename all Evoral source from .(hpp|cpp)$ to .(h|cc)
[ardour.git] / libs / ardour / ardour / send.h
1 /*
2  * Copyright (C) 2006-2009 David Robillard <d@drobilla.net>
3  * Copyright (C) 2007-2017 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
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_send_h__
24 #define __ardour_send_h__
25
26 #include <string>
27
28 #include "pbd/stateful.h"
29
30 #include "ardour/ardour.h"
31 #include "ardour/delivery.h"
32
33 namespace ARDOUR {
34
35 class PeakMeter;
36 class Amp;
37 class GainControl;
38 class DelayLine;
39
40 /** Internal Abstraction for Sends (and MixbusSends) */
41 class LIBARDOUR_API LatentSend
42 {
43 public:
44         LatentSend ();
45         virtual ~LatentSend() {}
46
47         samplecnt_t get_delay_in () const { return _delay_in; }
48         samplecnt_t get_delay_out () const { return _delay_out; }
49
50         /* should only be called by Route::update_signal_latency */
51         virtual void set_delay_in (samplecnt_t) = 0;
52
53         /* should only be called by InternalReturn::set_playback_offset
54          * (via Route::update_signal_latency)
55          */
56         virtual void set_delay_out (samplecnt_t, size_t bus = 0) = 0;
57
58         static PBD::Signal0<void> ChangedLatency;
59
60 protected:
61         samplecnt_t _delay_in;
62         samplecnt_t _delay_out;
63 };
64
65 class LIBARDOUR_API Send : public Delivery, public LatentSend
66 {
67 public:
68         Send (Session&, boost::shared_ptr<Pannable> pannable, boost::shared_ptr<MuteMaster>, Delivery::Role r = Delivery::Send, bool ignore_bitslot = false);
69         virtual ~Send ();
70
71         uint32_t bit_slot() const { return _bitslot; }
72
73         bool display_to_user() const;
74         bool is_foldback () const { return _role == Foldback; }
75
76         boost::shared_ptr<Amp> amp() const { return _amp; }
77         boost::shared_ptr<PeakMeter> meter() const { return _meter; }
78         boost::shared_ptr<GainControl> gain_control() const { return _gain_control; }
79
80         bool metering() const { return _metering; }
81         void set_metering (bool yn) { _metering = yn; }
82
83         int set_state(const XMLNode&, int version);
84
85         PBD::Signal0<void> SelfDestruct;
86         void set_remove_on_disconnect (bool b) { _remove_on_disconnect = b; }
87         bool remove_on_disconnect () const { return _remove_on_disconnect; }
88
89         uint32_t pans_required() const { return _configured_input.n_audio(); }
90
91         void run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_sample, double speed, pframes_t nframes, bool);
92
93         bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
94         bool configure_io (ChanCount in, ChanCount out);
95
96         /* latency compensation */
97         void set_delay_in (samplecnt_t);
98         void set_delay_out (samplecnt_t, size_t bus = 0);
99         samplecnt_t get_delay_in () const { return _delay_in; }
100         samplecnt_t get_delay_out () const { return _delay_out; }
101         samplecnt_t signal_latency () const;
102
103         void activate ();
104         void deactivate ();
105
106         bool set_name (const std::string& str);
107
108         static std::string name_and_id_new_send (Session&, Delivery::Role r, uint32_t&, bool);
109
110 protected:
111         XMLNode& state ();
112
113         bool _metering;
114         boost::shared_ptr<GainControl> _gain_control;
115         boost::shared_ptr<Amp> _amp;
116         boost::shared_ptr<PeakMeter> _meter;
117         boost::shared_ptr<DelayLine> _send_delay;
118         boost::shared_ptr<DelayLine> _thru_delay;
119
120 private:
121         /* disallow copy construction */
122         Send (const Send&);
123
124         void panshell_changed ();
125         void snd_output_changed (IOChange, void*);
126
127         void update_delaylines ();
128
129         int set_state_2X (XMLNode const &, int);
130
131         uint32_t    _bitslot;
132         bool        _remove_on_disconnect;
133 };
134
135 } // namespace ARDOUR
136
137 #endif /* __ardour_send_h__ */