2 Copyright (C) 2006,2007 John Anderson
3 Copyright (C) 2012 Paul Davis
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 using namespace Mackie;
35 Strip::Strip (const std::string& name, int index)
47 /* master strip only */
50 Strip::Strip (Surface& surface, const std::string& name, int index, int unit_index, StripControlDefinition* ctls)
62 /* build the controls for this track, which will automatically add them
66 for (uint32_t i = 0; ctls[i].name[0]; ++i) {
67 ctls[i].factory (surface, ctls[i].base_id + unit_index, unit_index+1, ctls[i].name, *this);
72 TODO could optimise this to use enum, but it's only
73 called during the protocol class instantiation.
75 void Strip::add (Control & control)
79 if (control.name() == "gain") {
80 _gain = reinterpret_cast<Fader*>(&control);
81 } else if (control.name() == "vpot") {
82 _vpot = reinterpret_cast<Pot*>(&control);
83 } else if (control.name() == "recenable") {
84 _recenable = reinterpret_cast<Button*>(&control);
85 } else if (control.name() == "solo") {
86 _solo = reinterpret_cast<Button*>(&control);
87 } else if (control.name() == "mute") {
88 _mute = reinterpret_cast<Button*>(&control);
89 } else if (control.name() == "select") {
90 _select = reinterpret_cast<Button*>(&control);
91 } else if (control.name() == "vselect") {
92 _vselect = reinterpret_cast<Button*>(&control);
93 } else if (control.name() == "fader_touch") {
94 _fader_touch = reinterpret_cast<Button*>(&control);
95 } else if (control.name() == "meter") {
96 _meter = reinterpret_cast<Meter*>(&control);
97 } else if (control.type() == Control::type_led || control.type() == Control::type_led_ring) {
101 os << "Strip::add: unknown control type " << control;
102 throw MackieControlException (os.str());
110 throw MackieControlException ("gain is null");
119 throw MackieControlException ("vpot is null");
127 if (_recenable == 0) {
128 throw MackieControlException ("recenable is null");
137 throw MackieControlException ("solo is null");
145 throw MackieControlException ("mute is null");
154 throw MackieControlException ("select is null");
163 throw MackieControlException ("vselect is null");
171 if (_fader_touch == 0) {
172 throw MackieControlException ("fader_touch is null");
174 return *_fader_touch;
181 throw MackieControlException ("meter is null");
186 std::ostream & Mackie::operator << (std::ostream & os, const Strip & strip)
188 os << typeid (strip).name();
190 os << "has_solo: " << boolalpha << strip.has_solo();
192 os << "has_recenable: " << boolalpha << strip.has_recenable();
194 os << "has_mute: " << boolalpha << strip.has_mute();
196 os << "has_select: " << boolalpha << strip.has_select();
198 os << "has_vselect: " << boolalpha << strip.has_vselect();
200 os << "has_fader_touch: " << boolalpha << strip.has_fader_touch();
202 os << "has_vpot: " << boolalpha << strip.has_vpot();
204 os << "has_gain: " << boolalpha << strip.has_gain();