merge 3.0-panexp (pan experiments) branch, revisions 8534-8585 into 3.0, thus ending...
[ardour.git] / libs / ardour / ardour / pannable.h
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
20 #ifndef __libardour_pannable_h__
21 #define __libardour_pannable_h__
22
23 #include <string>
24
25 #include <boost/shared_ptr.hpp>
26
27 #include "pbd/stateful.h"
28 #include "evoral/Parameter.hpp"
29
30 #include "ardour/automatable.h"
31 #include "ardour/session_handle.h"
32
33 namespace ARDOUR {
34
35 class Session;
36 class AutomationControl;
37 class Panner;
38
39 struct Pannable : public PBD::Stateful, public Automatable, public SessionHandleRef {
40         Pannable (Session& s);
41
42         boost::shared_ptr<AutomationControl> pan_azimuth_control;
43         boost::shared_ptr<AutomationControl> pan_elevation_control;
44         boost::shared_ptr<AutomationControl> pan_width_control;
45         boost::shared_ptr<AutomationControl> pan_frontback_control;
46         boost::shared_ptr<AutomationControl> pan_lfe_control;
47         
48         boost::shared_ptr<Panner> panner() const { return _panner; }
49         void set_panner(boost::shared_ptr<Panner>);
50
51         Session& session() { return _session; }
52
53         void set_automation_state (AutoState);
54         AutoState automation_state() const { return _auto_state; }
55         PBD::Signal1<void, AutoState> automation_state_changed;
56
57         void set_automation_style (AutoStyle m);
58         AutoStyle automation_style() const { return _auto_style; }
59         PBD::Signal0<void> automation_style_changed;
60
61         bool automation_playback() const {
62                 return (_auto_state & Play) || ((_auto_state & Touch) && !touching());
63         }
64         bool automation_write () const {
65                 return ((_auto_state & Write) || ((_auto_state & Touch) && touching()));
66         }
67
68         void start_touch (double when);
69         void stop_touch (bool mark, double when);
70         bool touching() const { return g_atomic_int_get (&_touching); }
71         bool writing() const { return _auto_state == Write; }
72         bool touch_enabled() const { return _auto_state == Touch; }
73
74         XMLNode& get_state ();
75         XMLNode& state (bool full_state);
76         int set_state (const XMLNode&, int version);
77
78         bool has_state() const { return _has_state; }
79
80   protected:
81         boost::shared_ptr<Panner> _panner;
82         AutoState _auto_state;
83         AutoStyle _auto_style;
84         gint      _touching;
85         bool      _has_state;
86         uint32_t  _responding_to_control_auto_state_change;
87
88         void control_auto_state_changed (AutoState);
89 };
90
91 } // namespace 
92
93 #endif /* __libardour_pannable_h__ */