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.
22 #include <pbd/error.h>
23 #include <pbd/convert.h>
25 #include <midi++/types.h>
26 #include <midi++/factory.h>
27 #include <midi++/nullmidi.h>
28 #include <midi++/fifomidi.h>
30 std::string MIDI::Null_MidiPort::typestring = "null";
31 std::string MIDI::FIFO_MidiPort::typestring = "fifo";
34 #include <midi++/alsa_sequencer.h>
35 #include <midi++/alsa_rawmidi.h>
37 std::string MIDI::ALSA_SequencerMidiPort::typestring = "alsa/sequencer";
38 std::string MIDI::ALSA_RawMidiPort::typestring = "alsa/raw";
43 #include <midi++/coremidi_midiport.h>
45 std::string MIDI::CoreMidi_MidiPort::typestring = "coremidi";
47 #endif // WITH_COREMIDI
55 PortFactory::create_port (const XMLNode& node)
57 Port::Descriptor desc (node);
62 case Port::ALSA_RawMidi:
63 port = new ALSA_RawMidiPort (node);
66 case Port::ALSA_Sequencer:
67 port = new ALSA_SequencerMidiPort (node);
72 case Port::CoreMidi_MidiPort:
73 port = new CoreMidi_MidiPort (node);
75 #endif // WITH_COREMIDI
78 port = new Null_MidiPort (node);
82 port = new FIFO_MidiPort (node);
93 PortFactory::ignore_duplicate_devices (Port::Type type)
99 case Port::ALSA_Sequencer:
105 case Port::CoreMidi_MidiPort:
108 #endif // WITH_COREMIDI
118 PortFactory::get_known_ports (vector<PortSet>& ports)
122 n += ALSA_SequencerMidiPort::discover (ports);
126 n += CoreMidi_MidiPort::discover (ports);
127 #endif // WITH_COREMIDI
133 PortFactory::default_port_type ()
137 return "alsa/sequencer";
142 #endif // WITH_COREMIDI
144 PBD::fatal << "programming error: no default port type defined in midifactory.cc" << endmsg;
148 PortFactory::string_to_type (const string& xtype)
152 } else if (strings_equal_ignore_case (xtype, ALSA_RawMidiPort::typestring)) {
153 return Port::ALSA_RawMidi;
154 } else if (strings_equal_ignore_case (xtype, ALSA_SequencerMidiPort::typestring)) {
155 return Port::ALSA_Sequencer;
158 } else if (strings_equal_ignore_case (xtype, CoreMidi_MidiPort::typestring)) {
159 return Port::CoreMidi_MidiPort;
161 } else if (strings_equal_ignore_case (xtype, Null_MidiPort::typestring)) {
163 } else if (strings_equal_ignore_case (xtype, FIFO_MidiPort::typestring)) {
167 return Port::Unknown;
171 PortFactory::mode_to_string (int mode)
173 if (mode == O_RDONLY) {
175 } else if (mode == O_WRONLY) {
183 PortFactory::string_to_mode (const string& str)
185 if (strings_equal_ignore_case (str, "output") || strings_equal_ignore_case (str, "out")) {
187 } else if (strings_equal_ignore_case (str, "input") || strings_equal_ignore_case (str, "in")) {