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)
39 : _ports (new PortList)
41 _mmc = new MachineControl (this, jack);
43 _mtc_input_port = add_port (new MIDI::Port ("MTC in", Port::IsInput, jack));
44 _mtc_output_port = add_port (new MIDI::Port ("MTC out", Port::IsOutput, jack));
45 _midi_input_port = add_port (new MIDI::Port ("MIDI control in", Port::IsInput, jack));
46 _midi_output_port = add_port (new MIDI::Port ("MIDI control out", Port::IsOutput, jack));
47 _midi_clock_input_port = add_port (new MIDI::Port ("MIDI clock in", Port::IsInput, jack));
48 _midi_clock_output_port = add_port (new MIDI::Port ("MIDI clock out", Port::IsOutput, jack));
55 /* This will delete our MTC etc. ports */
57 boost::shared_ptr<PortList> pr = _ports.reader ();
58 for (PortList::iterator p = pr->begin(); p != pr->end(); ++p) {
62 if (theManager == this) {
68 Manager::add_port (Port* p)
71 RCUWriter<PortList> writer (_ports);
72 boost::shared_ptr<PortList> pw = writer.get_copy ();
76 PortsChanged (); /* EMIT SIGNAL */
82 Manager::remove_port (Port* p)
85 RCUWriter<PortList> writer (_ports);
86 boost::shared_ptr<PortList> pw = writer.get_copy ();
90 PortsChanged (); /* EMIT SIGNAL */
94 Manager::cycle_start (pframes_t nframes)
96 boost::shared_ptr<PortList> pr = _ports.reader ();
98 for (PortList::iterator p = pr->begin(); p != pr->end(); ++p) {
99 (*p)->cycle_start (nframes);
106 boost::shared_ptr<PortList> pr = _ports.reader ();
108 for (PortList::iterator p = pr->begin(); p != pr->end(); ++p) {
113 /** Re-register ports that disappear on JACK shutdown */
115 Manager::reestablish (jack_client_t* jack)
117 boost::shared_ptr<PortList> pr = _ports.reader ();
119 for (PortList::const_iterator p = pr->begin(); p != pr->end(); ++p) {
120 (*p)->reestablish (jack);
124 /** Re-connect ports after a reestablish () */
126 Manager::reconnect ()
128 boost::shared_ptr<PortList> pr = _ports.reader ();
130 for (PortList::const_iterator p = pr->begin(); p != pr->end(); ++p) {
136 Manager::port (string const & n)
138 boost::shared_ptr<PortList> pr = _ports.reader ();
140 PortList::const_iterator p = pr->begin();
141 while (p != pr->end() && (*p)->name() != n) {
145 if (p == pr->end()) {
153 Manager::create (jack_client_t* jack)
155 assert (theManager == 0);
156 theManager = new Manager (jack);
160 Manager::set_port_states (list<XMLNode*> s)
162 boost::shared_ptr<PortList> pr = _ports.reader ();
164 for (list<XMLNode*>::iterator i = s.begin(); i != s.end(); ++i) {
165 for (PortList::const_iterator j = pr->begin(); j != pr->end(); ++j) {
166 (*j)->set_state (**i);