9c45e6034199f6a0113848ffa090948ae85b61d6
[ardour.git] / libs / ardour / ardour / midiport_manager.h
1 /*
2     Copyright (C) 1998 Paul Barton-Davis
3     
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.
8
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.
13
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.
17
18 */
19
20 #ifndef __midiport_manager_h__
21 #define __midiport_manager_h__
22
23 #include <list>
24
25 #include <string>
26
27 #include "pbd/rcu.h"
28
29 #include "midi++/types.h"
30 #include "midi++/port.h"
31
32 #include "ardour/types.h"
33
34 namespace ARDOUR {
35
36 class MidiPort;
37 class Port;
38
39 class MidiPortManager {
40   public:
41     MidiPortManager();
42     virtual ~MidiPortManager ();
43         
44     MidiPort* add_port (MidiPort *);
45     void remove_port (MidiPort *);
46
47     MidiPort* port (const std::string&);
48     
49     /* Ports used for control. These are read/written to outside of the
50      * process callback (asynchronously with respect to when data
51      * actually arrives). 
52      *
53      * More detail: we do actually read/write data for these ports
54      * inside the process callback, but incoming data is only parsed
55      * and outgoing data is only generated *outside* the process
56      * callback. 
57      */
58
59     MIDI::Port* midi_input_port () { return _midi_input_port; }
60     MIDI::Port* midi_output_port () { return _midi_output_port; }
61     
62     /* Ports used for synchronization. These have their I/O handled inside the
63      * process callback.
64      */
65
66     boost::shared_ptr<MidiPort> mtc_input_port() const { return _mtc_input_port; }
67     boost::shared_ptr<MidiPort> mtc_output_port() const { return _mtc_output_port; }
68     boost::shared_ptr<MidiPort> midi_clock_input_port() const { return _midi_clock_input_port; }
69     boost::shared_ptr<MidiPort> midi_clock_output_port() const { return _midi_clock_output_port; }
70     
71     void set_port_states (std::list<XMLNode*>);
72
73     PBD::Signal0<void> PortsChanged;
74
75   protected:
76     /* asynchronously handled ports: MIDI::Port */
77     MIDI::Port* _midi_input_port;
78     MIDI::Port* _midi_output_port;
79     boost::shared_ptr<Port> _midi_in;
80     boost::shared_ptr<Port> _midi_out;
81
82     /* synchronously handled ports: ARDOUR::MidiPort */
83     boost::shared_ptr<MidiPort> _mtc_input_port;
84     boost::shared_ptr<MidiPort> _mtc_output_port;
85     boost::shared_ptr<MidiPort> _midi_clock_input_port;
86     boost::shared_ptr<MidiPort> _midi_clock_output_port;
87
88     void create_ports ();
89
90 };
91
92 } // namespace MIDI
93
94 #endif  // __midi_port_manager_h__