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 )
114 , _in_use_timeout( 250 )
121 controls[1].each do |x|
123 #{x.class.name} & Strip::#{x.name}()
125 if ( _#{x.name} == 0 )
126 throw MackieControlException( "#{x.name} is null" );
132 Fader & Strip::gain()
135 throw MackieControlException( "gain is null" );
141 throw MackieControlException( "vpot is null" );
144 Button & Strip::recenable()
146 if ( _recenable == 0 )
147 throw MackieControlException( "recenable is null" );
150 Button & Strip::solo()
153 throw MackieControlException( "solo is null" );
156 Button & Strip::mute()
159 throw MackieControlException( "mute is null" );
162 Button & Strip::select()
165 throw MackieControlException( "select is null" );
168 Button & Strip::vselect()
171 throw MackieControlException( "vselect is null" );
174 Button & Strip::fader_touch()
176 if ( _fader_touch == 0 )
177 throw MackieControlException( "fader_touch is null" );
178 return *_fader_touch;
181 bool Control::in_use() const
186 Control & Control::in_use( bool rhs )
192 ostream & Mackie::operator << ( ostream & os, const Mackie::Control & control )
194 os << typeid( control ).name();
196 os << "name: " << control.name();
198 os << "id: " << "0x" << setw(4) << setfill('0') << hex << control.id() << setfill(' ');
200 os << "type: " << "0x" << setw(2) << setfill('0') << hex << control.type() << setfill(' ');
202 os << "raw_id: " << "0x" << setw(2) << setfill('0') << hex << control.raw_id() << setfill(' ');
204 os << "ordinal: " << dec << control.ordinal();
206 os << "group: " << control.group().name();
212 std::ostream & Mackie::operator << ( std::ostream & os, const Strip & strip )
214 os << typeid( strip ).name();
216 os << "has_solo: " << boolalpha << strip.has_solo();
218 os << "has_recenable: " << boolalpha << strip.has_recenable();
220 os << "has_mute: " << boolalpha << strip.has_mute();
222 os << "has_select: " << boolalpha << strip.has_select();
224 os << "has_vselect: " << boolalpha << strip.has_vselect();
226 os << "has_fader_touch: " << boolalpha << strip.has_fader_touch();
228 os << "has_vpot: " << boolalpha << strip.has_vpot();
230 os << "has_gain: " << boolalpha << strip.has_gain();