Optimize plugin-processing for non-automated params
[ardour.git] / libs / ardour / pan_controllable.cc
1 /*
2     Copyright (C) 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 #include "ardour/pannable.h"
20 #include "ardour/panner.h"
21 #include "ardour/pan_controllable.h"
22
23 using namespace ARDOUR;
24
25 void
26 PanControllable::actually_set_value (double v, Controllable::GroupControlDisposition group_override)
27 {
28         boost::shared_ptr<Panner> p = owner->panner();
29
30         if (!p) {
31                 /* no panner: just do it */
32                 AutomationControl::actually_set_value (v, group_override);
33                 return;
34         }
35
36         bool can_set = false;
37
38         switch (parameter().type()) {
39                 case PanWidthAutomation:
40                         can_set = p->clamp_width (v);
41                         break;
42                 case PanAzimuthAutomation:
43                         can_set = p->clamp_position (v);
44                         break;
45                 case PanElevationAutomation:
46                         can_set = p->clamp_elevation (v);
47                         break;
48                 default:
49                         break;
50         }
51
52         if (can_set) {
53                 AutomationControl::actually_set_value (v, group_override);
54         }
55 }
56
57 std::string
58 PanControllable::get_user_string () const
59 {
60         return owner->value_as_string (shared_from_this());
61 }