2 Copyright (C) 1998-99 Paul Barton-Davis
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2 of the License, or
6 (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "pbd/error.h"
26 #include "midi++/types.h"
27 #include "midi++/manager.h"
28 #include "midi++/channel.h"
29 #include "midi++/port.h"
30 #include "midi++/mmc.h"
36 Manager
*Manager::theManager
= 0;
38 Manager::Manager (jack_client_t
* jack
)
40 _mmc
= new MachineControl (this, jack
);
42 _mtc_input_port
= add_port (new MIDI::Port ("MTC in", Port::IsInput
, jack
));
43 _mtc_output_port
= add_port (new MIDI::Port ("MTC out", Port::IsOutput
, jack
));
44 _midi_input_port
= add_port (new MIDI::Port ("MIDI control in", Port::IsInput
, jack
));
45 _midi_output_port
= add_port (new MIDI::Port ("MIDI control out", Port::IsOutput
, jack
));
46 _midi_clock_input_port
= add_port (new MIDI::Port ("MIDI clock in", Port::IsInput
, jack
));
47 _midi_clock_output_port
= add_port (new MIDI::Port ("MIDI clock out", Port::IsOutput
, jack
));
54 /* This will delete our MTC etc. ports */
55 for (PortList::iterator p
= _ports
.begin(); p
!= _ports
.end(); ++p
) {
59 if (theManager
== this) {
65 Manager::add_port (Port
* p
)
69 PortsChanged (); /* EMIT SIGNAL */
75 Manager::cycle_start (pframes_t nframes
)
77 for (PortList::iterator p
= _ports
.begin(); p
!= _ports
.end(); ++p
) {
78 (*p
)->cycle_start (nframes
);
85 for (PortList::iterator p
= _ports
.begin(); p
!= _ports
.end(); ++p
) {
90 /** Re-register ports that disappear on JACK shutdown */
92 Manager::reestablish (jack_client_t
* jack
)
94 for (PortList::const_iterator p
= _ports
.begin(); p
!= _ports
.end(); ++p
) {
95 (*p
)->reestablish (jack
);
99 /** Re-connect ports after a reestablish () */
101 Manager::reconnect ()
103 for (PortList::const_iterator p
= _ports
.begin(); p
!= _ports
.end(); ++p
) {
109 Manager::port (string
const & n
)
111 PortList::const_iterator p
= _ports
.begin();
112 while (p
!= _ports
.end() && (*p
)->name() != n
) {
116 if (p
== _ports
.end()) {
124 Manager::create (jack_client_t
* jack
)
126 assert (theManager
== 0);
127 theManager
= new Manager (jack
);
131 Manager::set_port_states (list
<XMLNode
*> s
)
133 for (list
<XMLNode
*>::iterator i
= s
.begin(); i
!= s
.end(); ++i
) {
134 for (PortList::const_iterator j
= _ports
.begin(); j
!= _ports
.end(); ++j
) {
135 (*j
)->set_state (**i
);