Apply panners/automation patch from torbenh (Panner is-a Processor).
[ardour.git] / libs / surfaces / mackie / route_signal.cc
1 /*
2         Copyright (C) 2006,2007 John Anderson
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 #include "route_signal.h"
19
20 #include <ardour/route.h>
21 #include <ardour/track.h>
22 #include <ardour/panner.h>
23 #include <ardour/types.h>
24
25 #include "mackie_control_protocol.h"
26
27 #include <stdexcept>
28
29 using namespace Mackie;
30
31 void RouteSignal::connect()
32 {
33         if ( _strip.has_solo() )
34                 _solo_changed_connection = _route.solo_control()->Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_solo_changed ), this ) );
35         
36         if ( _strip.has_mute() )
37                 _mute_changed_connection = _route.mute_control()->Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_mute_changed ), this ) );
38         
39         if ( _strip.has_gain() )
40                 _gain_changed_connection = _route.gain_control()->Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_gain_changed ), this ) );
41                 
42         _name_changed_connection = _route.NameChanged.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_name_changed ), this ) );
43         
44         if ( _route.panner().npanners() == 1 )
45         {
46                 _panner_changed_connection = _route.panner().pan_control(0)->Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_panner_changed ), this ) );
47         }
48         
49         try
50         {
51                 _record_enable_changed_connection =
52                         dynamic_cast<ARDOUR::Track&>( _route ).rec_enable_control()->Changed
53                                 .connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_record_enable_changed ), this ) )
54                 ;
55         }
56         catch ( std::bad_cast & )
57         {
58                 // this should catch the dynamic_cast to Track, if what we're working
59                 // with can't be record-enabled
60         }
61
62         // TODO
63         // active_changed
64         // SelectedChanged
65         // RemoteControlIDChanged. Better handled at Session level.
66 }
67
68 void RouteSignal::disconnect()
69 {
70         _solo_changed_connection.disconnect();
71         _mute_changed_connection.disconnect();
72         _gain_changed_connection.disconnect();
73         _name_changed_connection.disconnect();
74         _panner_changed_connection.disconnect();
75         _record_enable_changed_connection.disconnect();
76 }
77
78 void RouteSignal::notify_all()
79 {
80         if ( _strip.has_solo() )
81                 _mcp.notify_solo_changed( this );
82         
83         if ( _strip.has_mute() )
84                 _mcp.notify_mute_changed( this );
85         
86         if ( _strip.has_gain() )
87                 _mcp.notify_gain_changed( this );
88         
89         _mcp.notify_name_changed( this );
90         
91         if ( _strip.has_vpot() )
92                 _mcp.notify_panner_changed( this );
93         
94         if ( _strip.has_recenable() )
95                 _mcp.notify_record_enable_changed( this );
96 }