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