9ad49c12c5808308c4a6d8fc9f0b60671a1b2f47
[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/audio_buffer.h"
21 #include "ardour/buffer_set.h"
22 #include "ardour/panner.h"
23 #include "ardour/pannable.h"
24 #include "ardour/session.h"
25 #include "ardour/utils.h"
26
27 using namespace std;
28 using namespace ARDOUR;
29
30 Panner::Panner (boost::shared_ptr<Pannable> p)
31         : _pannable (p)
32         , _bypassed (false)
33 {
34 }
35
36 Panner::~Panner ()
37 {
38 }
39
40 void
41 Panner::set_bypassed (bool yn)
42 {
43         if (yn != _bypassed) {
44                 _bypassed = yn;
45                 StateChanged ();
46         }
47 }
48
49 int
50 Panner::set_state (const XMLNode& node, int version)
51 {
52         const XMLProperty* prop;
53         XMLNodeConstIterator iter;
54
55         if ((prop = node.property (X_("bypassed"))) != 0) {
56                 set_bypassed (string_is_affirmative (prop->value()));
57         }
58
59         return 0;
60 }
61
62 XMLNode&
63 Panner::get_state ()
64 {
65         XMLNode* node = new XMLNode (X_("Panner"));
66
67         node->add_property (X_("bypassed"), (bypassed() ? "yes" : "no"));
68
69         return *node;
70 }
71
72 void
73 Panner::distribute (BufferSet& ibufs, BufferSet& obufs, gain_t gain_coeff, pframes_t nframes)
74 {
75         uint32_t which = 0;
76
77         for (BufferSet::audio_iterator src = ibufs.audio_begin(); src != ibufs.audio_end(); ++src, ++which) {
78                 distribute_one (*src, obufs, gain_coeff, nframes, which);
79         }
80 }
81
82 void
83 Panner::distribute_automated (BufferSet& ibufs, BufferSet& obufs,
84                               framepos_t start, framepos_t end, pframes_t nframes, pan_t** buffers)
85 {
86         uint32_t which = 0;
87
88         for (BufferSet::audio_iterator src = ibufs.audio_begin(); src != ibufs.audio_end(); ++src, ++which) {
89                 distribute_one_automated (*src, obufs, start, end, nframes, buffers, which);
90         }
91 }
92
93 void
94 Panner::set_automation_style (AutoStyle style)
95 {
96         _pannable->set_automation_style (style);
97 }
98
99 void
100 Panner::set_automation_state (AutoState state)
101 {
102         _pannable->set_automation_state (state);
103 }
104
105 AutoState
106 Panner::automation_state () const
107 {
108         return _pannable->automation_state();
109 }
110
111 AutoStyle
112 Panner::automation_style () const
113 {
114         return _pannable->automation_style ();
115 }
116
117 bool
118 Panner::touching () const
119 {
120         return _pannable->touching ();
121 }
122
123 set<Evoral::Parameter> 
124 Panner::what_can_be_automated() const
125 {
126         return _pannable->what_can_be_automated ();
127 }
128
129 string
130 Panner::describe_parameter (Evoral::Parameter p)
131 {
132         return _pannable->describe_parameter (p);
133 }
134
135 string 
136 Panner::value_as_string (boost::shared_ptr<AutomationControl> ac) const
137 {
138         return _pannable->value_as_string (ac);
139 }