summaryrefslogtreecommitdiff
path: root/libs/surfaces/mackie/route_signal.cc
blob: fb6cf5b092c114938e81cd324020d69b078c4031 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
	Copyright (C) 2006,2007 John Anderson

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "route_signal.h"

#include "ardour/route.h"
#include "ardour/track.h"
#include "ardour/panner.h"

#include "mackie_control_protocol.h"

#include <stdexcept>

using namespace ARDOUR;
using namespace Mackie;
using namespace std;

void RouteSignal::connect()
{
	if (_strip.has_solo()) {
		connections.add_connection (_route->solo_control()->Changed.connect(boost::bind (&MackieControlProtocol::notify_solo_changed, &_mcp, this)));
	}

	if (_strip.has_mute()) {
		connections.add_connection (_route->mute_control()->Changed.connect(boost::bind (&MackieControlProtocol::notify_mute_changed, &_mcp, this)));
	}

	if (_strip.has_gain()) {
		connections.add_connection (_route->gain_control()->Changed.connect(boost::bind (&MackieControlProtocol::notify_gain_changed, &_mcp, this, false)));
	}

	connections.add_connection (_route->NameChanged.connect (boost::bind (&MackieControlProtocol::notify_name_changed, &_mcp, this)));
	
	if (_route->panner()) {
		connections.add_connection (_route->panner()->Changed.connect(boost::bind (&MackieControlProtocol::notify_panner_changed, &_mcp, this, false)));
		
		for ( unsigned int i = 0; i < _route->panner()->npanners(); ++i ) {
			connections.add_connection (_route->panner()->streampanner(i).Changed.connect (boost::bind (&MackieControlProtocol::notify_panner_changed, &_mcp, this, false)));
		}
	}
	
	boost::shared_ptr<Track> trk = boost::dynamic_pointer_cast<ARDOUR::Track>(_route);
	if (trk) {
		connections.add_connection (trk->rec_enable_control()->Changed .connect(boost::bind (&MackieControlProtocol::notify_record_enable_changed, &_mcp, this)));
	}
	
	// TODO this works when a currently-banked route is made inactive, but not
	// when a route is activated which should be currently banked.
	connections.add_connection (_route->active_changed.connect (boost::bind (&MackieControlProtocol::notify_active_changed, &_mcp, this)));

	// TODO
	// SelectedChanged
	// RemoteControlIDChanged. Better handled at Session level.
}

void RouteSignal::disconnect()
{
	connections.drop_connections ();
}

void RouteSignal::notify_all()
{
#ifdef DEBUG
	cout << "RouteSignal::notify_all for " << _strip << endl;
#endif
	if ( _strip.has_solo() )
		_mcp.notify_solo_changed( this );
	
	if ( _strip.has_mute() )
		_mcp.notify_mute_changed( this );
	
	if ( _strip.has_gain() )
		_mcp.notify_gain_changed( this );
	
	_mcp.notify_name_changed( this );
	
	if ( _strip.has_vpot() )
		_mcp.notify_panner_changed( this );
	
	if ( _strip.has_recenable() )
		_mcp.notify_record_enable_changed( this );
#ifdef DEBUG
	cout << "RouteSignal::notify_all finish" << endl;
#endif
}