allow alt-drag on stereo panner to move just one side of the stereo field. this wiggl...
[ardour.git] / libs / ardour / panner.cc
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 #include "ardour/buffer_set.h"
21 #include "ardour/debug.h"
22 #include "ardour/panner.h"
23 #include "ardour/pannable.h"
24
25 #include "i18n.h"
26
27 using namespace std;
28 using namespace ARDOUR;
29
30 Panner::Panner (boost::shared_ptr<Pannable> p)
31 {
32         // boost_debug_shared_ptr_mark_interesting (this, "panner");
33         _pannable = p;
34 }
35
36 Panner::~Panner ()
37 {
38         DEBUG_TRACE(PBD::DEBUG::Destruction, string_compose ("panner @ %1 destructor, pannable is %2 @ %3\n", this, _pannable, &_pannable));
39 }
40
41 XMLNode&
42 Panner::get_state ()
43 {
44         return *(new XMLNode (X_("Panner")));
45 }
46
47 void
48 Panner::distribute (BufferSet& ibufs, BufferSet& obufs, gain_t gain_coeff, pframes_t nframes)
49 {
50         uint32_t which = 0;
51
52         for (BufferSet::audio_iterator src = ibufs.audio_begin(); src != ibufs.audio_end(); ++src, ++which) {
53                 distribute_one (*src, obufs, gain_coeff, nframes, which);
54         }
55 }
56
57 void
58 Panner::distribute_automated (BufferSet& ibufs, BufferSet& obufs,
59                               framepos_t start, framepos_t end, pframes_t nframes, pan_t** buffers)
60 {
61         uint32_t which = 0;
62
63         for (BufferSet::audio_iterator src = ibufs.audio_begin(); src != ibufs.audio_end(); ++src, ++which) {
64                 distribute_one_automated (*src, obufs, start, end, nframes, buffers, which);
65         }
66 }
67
68 void
69 Panner::set_automation_style (AutoStyle style)
70 {
71         _pannable->set_automation_style (style);
72 }
73
74 void
75 Panner::set_automation_state (AutoState state)
76 {
77         _pannable->set_automation_state (state);
78 }
79
80 AutoState
81 Panner::automation_state () const
82 {
83         return _pannable->automation_state();
84 }
85
86 AutoStyle
87 Panner::automation_style () const
88 {
89         return _pannable->automation_style ();
90 }
91
92 bool
93 Panner::touching () const
94 {
95         return _pannable->touching ();
96 }
97
98 set<Evoral::Parameter>
99 Panner::what_can_be_automated() const
100 {
101         return _pannable->what_can_be_automated ();
102 }
103
104 string
105 Panner::describe_parameter (Evoral::Parameter p)
106 {
107         return _pannable->describe_parameter (p);
108 }
109
110 string
111 Panner::value_as_string (boost::shared_ptr<AutomationControl> ac) const
112 {
113         return _pannable->value_as_string (ac);
114 }
115
116 int
117 Panner::set_state (XMLNode const &, int)
118 {
119         return 0;
120 }
121
122 void
123 Panner::freeze ()
124 {
125         _frozen++;
126 }
127
128 void
129 Panner::thaw ()
130 {
131         if (_frozen > 0.0) {
132                 _frozen--;
133         }
134 }