globally remove all trailing whitespace from ardour code base.
[ardour.git] / libs / panners / 2in2out / panner_2in2out.h
1 /*
2     Copyright (C) 2004-2011 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __ardour_panner_2in2out_h__
21 #define __ardour_panner_2in2out_h__
22
23 #include <cmath>
24 #include <cassert>
25 #include <vector>
26 #include <string>
27 #include <iostream>
28
29 #include "pbd/stateful.h"
30 #include "pbd/controllable.h"
31 #include "pbd/cartesian.h"
32
33 #include "ardour/automation_control.h"
34 #include "ardour/automatable.h"
35 #include "ardour/panner.h"
36 #include "ardour/types.h"
37
38 namespace ARDOUR {
39
40 class Panner2in2out : public Panner
41 {
42   public:
43         Panner2in2out (boost::shared_ptr<Pannable>);
44         ~Panner2in2out ();
45
46         ChanCount in() const { return ChanCount (DataType::AUDIO, 2); }
47         ChanCount out() const { return ChanCount (DataType::AUDIO, 2); }
48
49         bool clamp_position (double&);
50         bool clamp_width (double&);
51
52         std::pair<double, double> position_range () const;
53         std::pair<double, double> width_range () const;
54         
55         void set_position (double);
56         void set_width (double);
57
58         double position () const;
59         double width () const;
60
61         std::set<Evoral::Parameter> what_can_be_automated() const;
62
63         static Panner* factory (boost::shared_ptr<Pannable>, boost::shared_ptr<Speakers>);
64
65         std::string describe_parameter (Evoral::Parameter);
66         std::string value_as_string (boost::shared_ptr<AutomationControl>) const;
67
68         XMLNode& get_state ();
69
70         void update ();
71
72         void reset ();
73         void thaw ();
74
75   protected:
76         float left[2];
77         float right[2];
78         float desired_left[2];
79         float desired_right[2];
80         float left_interp[2];
81         float right_interp[2];
82
83   private:
84         bool clamp_stereo_pan (double& direction_as_lr_fract, double& width);
85
86         void distribute_one (AudioBuffer& srcbuf, BufferSet& obufs, gain_t gain_coeff, pframes_t nframes, uint32_t which);
87         void distribute_one_automated (AudioBuffer& srcbuf, BufferSet& obufs,
88                                        framepos_t start, framepos_t end, pframes_t nframes,
89                                        pan_t** buffers, uint32_t which);
90 };
91
92 } // namespace
93
94 #endif /* __ardour_panner_2in2out_h__ */