summaryrefslogtreecommitdiff
path: root/libs/surfaces/mackie/route_signal.cc
blob: b01b5e0cf5f99ce59cae0a9464573291b5a641b6 (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
/*
	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 <ardour/types.h>

#include "mackie_control_protocol.h"

#include <stdexcept>

using namespace Mackie;

void RouteSignal::connect()
{
	if ( _strip.has_solo() )
		_solo_changed_connection = _route.solo_control()->Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_solo_changed ), this ) );
	
	if ( _strip.has_mute() )
		_mute_changed_connection = _route.mute_control()->Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_mute_changed ), this ) );
	
	if ( _strip.has_gain() )
		_gain_changed_connection = _route.control(ARDOUR::GainAutomation)->Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_gain_changed ), this ) );
		
	_name_changed_connection = _route.NameChanged.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_name_changed ), this ) );
	
	if ( _route.panner().size() == 1 )
	{
		_panner_changed_connection = _route.panner()[0]->Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_panner_changed ), this ) );
	}
	
	try
	{
		_record_enable_changed_connection =
			dynamic_cast<ARDOUR::Track&>( _route ).rec_enable_control()->Changed
				.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_record_enable_changed ), this ) )
		;
	}
	catch ( std::bad_cast & )
	{
		// this should catch the dynamic_cast to Track, if what we're working
		// with can't be record-enabled
	}

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

void RouteSignal::disconnect()
{
	_solo_changed_connection.disconnect();
	_mute_changed_connection.disconnect();
	_gain_changed_connection.disconnect();
	_name_changed_connection.disconnect();
	_panner_changed_connection.disconnect();
	_record_enable_changed_connection.disconnect();
}

void RouteSignal::notify_all()
{
	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 );
}