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.
21 #ifndef __fd_midiport_h__
22 #define __fd_midiport_h__
32 #include <midi++/port.h>
33 #include <midi++/port_request.h>
37 class FD_MidiPort : public Port
41 FD_MidiPort (PortRequest &req,
42 const std::string &dirpath,
43 const std::string &pattern);
45 virtual ~FD_MidiPort () {
49 virtual int selectable() const;
50 static std::vector<std::string *> *list_devices ();
54 virtual void open (PortRequest &req);
58 virtual int write (byte *msg, size_t msglen,
59 timestamp_t timestamp) {
62 if ((_mode & O_ACCMODE) == O_RDONLY) {
67 return do_slow_write (msg, msglen);
70 if ((nwritten = ::write (_fd, msg, msglen)) > 0) {
71 bytes_written += nwritten;
74 output_parser->raw_preparse
75 (*output_parser, msg, nwritten);
76 for (int i = 0; i < nwritten; i++) {
77 output_parser->scanner (msg[i]);
79 output_parser->raw_postparse
80 (*output_parser, msg, nwritten);
86 virtual int read (byte *buf, size_t max,
87 timestamp_t timestamp);
90 static std::string *midi_dirpath;
91 static std::string *midi_filename_pattern;
93 int do_slow_write (byte *msg, unsigned int msglen);
98 #endif // __fd_midiport_h__