2 Copyright (C) 1999 Paul Barton-Davis
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.
20 #ifndef __fd_midiport_h__
21 #define __fd_midiport_h__
31 #include <midi++/port.h>
35 class FD_MidiPort : public Port
39 FD_MidiPort (const XMLNode& node,
40 const std::string &dirpath,
41 const std::string &pattern);
43 virtual ~FD_MidiPort () {
47 virtual int selectable() const;
49 static std::vector<std::string *> *list_devices ();
53 virtual void open (const Port::Descriptor&);
55 virtual int write (byte *msg, size_t msglen) {
58 if ((_mode & O_ACCMODE) == O_RDONLY) {
63 return do_slow_write (msg, msglen);
66 if ((nwritten = ::write (_fd, msg, msglen)) > 0) {
67 bytes_written += nwritten;
70 output_parser->raw_preparse
71 (*output_parser, msg, nwritten);
72 for (int i = 0; i < nwritten; i++) {
73 output_parser->scanner (msg[i]);
75 output_parser->raw_postparse
76 (*output_parser, msg, nwritten);
82 virtual int read (byte *buf, size_t max);
85 static std::string *midi_dirpath;
86 static std::string *midi_filename_pattern;
88 int do_slow_write (byte *msg, unsigned int msglen);
93 #endif // __fd_midiport_h__