2 Copyright (C) 2006,2007 John Anderson
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.
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.
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.
20 #include "mackie_midi_builder.h"
26 using namespace Mackie;
29 void Group::add( Control & control )
31 _controls.push_back( &control );
34 Strip::Strip( const std::string & name, int index )
49 TODO could optimise this to use enum, but it's only
50 called during the protocol class instantiation.
57 controls = sf.groups.find{|x| x[0] =~ /strip/}.each{|x| puts x[1]}
58 controls[1].each {|x| puts "\telse if ( control.name() == \"#{x.name}\" )\n\t{\n\t\t_#{x.name} = reinterpret_cast<#{x.class.name}*>(&control);\n\t}\n"}
60 void Strip::add( Control & control )
62 Group::add( control );
63 if ( control.name() == "gain" )
65 _gain = reinterpret_cast<Fader*>(&control);
67 else if ( control.name() == "vpot" )
69 _vpot = reinterpret_cast<Pot*>(&control);
71 else if ( control.name() == "recenable" )
73 _recenable = reinterpret_cast<Button*>(&control);
75 else if ( control.name() == "solo" )
77 _solo = reinterpret_cast<Button*>(&control);
79 else if ( control.name() == "mute" )
81 _mute = reinterpret_cast<Button*>(&control);
83 else if ( control.name() == "select" )
85 _select = reinterpret_cast<Button*>(&control);
87 else if ( control.name() == "vselect" )
89 _vselect = reinterpret_cast<Button*>(&control);
91 else if ( control.name() == "fader_touch" )
93 _fader_touch = reinterpret_cast<Button*>(&control);
95 else if ( control.type() == Control::type_led || control.type() == Control::type_led_ring )
98 cout << "Strip::add not adding " << control << endl;
103 os << "Strip::add: unknown control type " << control;
104 throw MackieControlException( os.str() );
108 Control::Control( int id, int ordinal, std::string name, Group & group )
110 , _ordinal( ordinal )
120 controls[1].each do |x|
122 #{x.class.name} & Strip::#{x.name}()
124 if ( _#{x.name} == 0 )
125 throw MackieControlException( "#{x.name} is null" );
131 Fader & Strip::gain()
134 throw MackieControlException( "gain is null" );
140 throw MackieControlException( "vpot is null" );
143 Button & Strip::recenable()
145 if ( _recenable == 0 )
146 throw MackieControlException( "recenable is null" );
149 Button & Strip::solo()
152 throw MackieControlException( "solo is null" );
155 Button & Strip::mute()
158 throw MackieControlException( "mute is null" );
161 Button & Strip::select()
164 throw MackieControlException( "select is null" );
167 Button & Strip::vselect()
170 throw MackieControlException( "vselect is null" );
173 Button & Strip::fader_touch()
175 if ( _fader_touch == 0 )
176 throw MackieControlException( "fader_touch is null" );
177 return *_fader_touch;
180 /** @return true if the control is in use, or false otherwise.
181 Buttons are `in use' when they are held down.
182 Faders with touch support are `in use' when they are being touched.
183 Pots, or faders without touch support, are `in use' from the first move
184 event until a timeout after the last move event.
187 Control::in_use () const
193 Control::set_in_use (bool in_use)
198 ostream & Mackie::operator << ( ostream & os, const Mackie::Control & control )
200 os << typeid( control ).name();
202 os << "name: " << control.name();
204 os << "id: " << "0x" << setw(4) << setfill('0') << hex << control.id() << setfill(' ');
206 os << "type: " << "0x" << setw(2) << setfill('0') << hex << control.type() << setfill(' ');
208 os << "raw_id: " << "0x" << setw(2) << setfill('0') << hex << control.raw_id() << setfill(' ');
210 os << "ordinal: " << dec << control.ordinal();
212 os << "group: " << control.group().name();
218 std::ostream & Mackie::operator << ( std::ostream & os, const Strip & strip )
220 os << typeid( strip ).name();
222 os << "has_solo: " << boolalpha << strip.has_solo();
224 os << "has_recenable: " << boolalpha << strip.has_recenable();
226 os << "has_mute: " << boolalpha << strip.has_mute();
228 os << "has_select: " << boolalpha << strip.has_select();
230 os << "has_vselect: " << boolalpha << strip.has_vselect();
232 os << "has_fader_touch: " << boolalpha << strip.has_fader_touch();
234 os << "has_vpot: " << boolalpha << strip.has_vpot();
236 os << "has_gain: " << boolalpha << strip.has_gain();