aa5428a329a873cab1f759a5bf746915b197cee4
[ardour.git] / libs / panners / 1in2out / panner_1in2out.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_1in2out_h__
21 #define __ardour_panner_1in2out_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/types.h"
34 #include "ardour/panner.h"
35
36
37 namespace ARDOUR {
38
39 class Panner1in2out : public Panner
40 {
41   public:
42         Panner1in2out (boost::shared_ptr<Pannable>);
43         ~Panner1in2out ();
44
45     ARDOURPANNER_API void ARDOURPANNER_APICALLTYPE set_position (double);
46     ARDOURPANNER_API bool ARDOURPANNER_APICALLTYPE clamp_position (double&);
47         std::pair<double, double> position_range () const;
48
49         double position() const;
50
51         ChanCount in() const { return ChanCount (DataType::AUDIO, 1); }
52         ChanCount out() const { return ChanCount (DataType::AUDIO, 2); }
53
54         std::set<Evoral::Parameter> what_can_be_automated() const;
55
56         static Panner* factory (boost::shared_ptr<Pannable>, boost::shared_ptr<Speakers>);
57
58         std::string describe_parameter (Evoral::Parameter);
59         std::string value_as_string (boost::shared_ptr<AutomationControl>) const;
60
61         XMLNode& get_state ();
62
63         void reset ();
64
65   protected:
66         float left;
67         float right;
68         float desired_left;
69         float desired_right;
70         float left_interp;
71         float right_interp;
72
73         void distribute_one (AudioBuffer& src, BufferSet& obufs, gain_t gain_coeff, pframes_t nframes, uint32_t which);
74         void distribute_one_automated (AudioBuffer& srcbuf, BufferSet& obufs,
75                                        framepos_t start, framepos_t end, pframes_t nframes,
76                                        pan_t** buffers, uint32_t which);
77
78         void update ();
79 };
80
81 } // namespace
82
83 #endif /* __ardour_panner_1in2out_h__ */