2 Copyright (C) 1998 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.
24 #include <midi++/types.h>
25 #include <midi++/port.h>
26 #include <midi++/channel.h>
27 #include <midi++/port_request.h>
29 using namespace Select;
32 size_t Port::nports = 0;
34 Port::Port (PortRequest &req)
37 _ok = false; /* derived class must set to true if constructor
47 _devname = req.devname;
48 _tagname = req.tagname;
52 if (_mode == O_RDONLY || _mode == O_RDWR) {
53 input_parser = new Parser (*this);
58 if (_mode == O_WRONLY || _mode == O_RDWR) {
59 output_parser = new Parser (*this);
64 for (int i = 0; i < 16; i++) {
65 _channel[i] = new Channel (i, *this);
68 _channel[i]->connect_input_signals ();
72 _channel[i]->connect_output_signals ();
81 for (int i = 0; i < 16; i++) {
86 /** Send a clock tick message.
87 * \return true on success.
93 static byte clockmsg = 0xf8;
95 if (_mode != O_RDONLY) {
96 return midimsg (&clockmsg, 1);
103 Port::selector_read_callback (Selectable *s, Select::Condition cond)
107 read (buf, sizeof (buf));
111 Port::xforms_read_callback (int cond, int fd, void *ptr)
116 ((Port *)ptr)->read (buf, sizeof (buf));
120 Port::gtk_read_callback (void *ptr, int fd, int cond)
125 ((Port *)ptr)->read (buf, sizeof (buf));
129 Port::write_callback (byte *msg, unsigned int len, void *ptr)
132 ((Port *)ptr)->write (msg, len);