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.
18 #ifndef surface_port_h
19 #define surface_port_h
21 #include <sigc++/signal.h>
23 #include "midi_byte_array.h"
34 Make a relationship between a midi port and a Mackie device.
36 class SurfacePort : public sigc::trackable
39 SurfacePort( MIDI::Port & port, int number );
40 virtual ~SurfacePort() {}
42 // when this is successful, active() should return true
43 virtual void open() = 0;
44 virtual void close() = 0;
46 /// read bytes from the port. They'll either end up in the
47 /// parser, or if that's not active they'll be returned
50 /// an easier way to output bytes via midi
51 void write( const MidiByteArray & );
53 /// write a sysex message
54 void write_sysex( const MidiByteArray & mba );
55 void write_sysex( MIDI::byte msg );
57 // return the correct sysex header for this port
58 virtual const MidiByteArray & sysex_hdr() const = 0;
60 MIDI::Port & port() { return _port; }
61 const MIDI::Port & port() const { return _port; }
63 // all control notofications are sent from here
64 sigc::signal<void, SurfacePort &, Control &, const ControlState &> control_event;
66 // emitted just before the port goes into initialisation
67 // where it tries to establish that its device is connected
68 sigc::signal<void> init_event;
70 // emitted when the port completes initialisation successfully
71 sigc::signal<void> active_event;
73 // emitted when the port goes inactive (ie a read or write failed)
74 sigc::signal<void> inactive_event;
76 // the port number - master is 0, extenders are 1,2,3,4
77 virtual int number() const { return _number; }
79 // number of strips handled by this port. Usually 8.
80 virtual int strips() const = 0;
82 virtual bool active() const { return _active; }
83 virtual void active( bool yn ) { _active = yn; }
91 std::ostream & operator << ( std::ostream & , const SurfacePort & port );