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)
35 : _currently_in_cycle(false)
36 , _nframes_this_cycle(0)
38 _ok = false; /* derived class must set to true if constructor
48 _devname = req.devname;
49 _tagname = req.tagname;
53 if (_mode == O_RDONLY || _mode == O_RDWR) {
54 input_parser = new Parser (*this);
59 if (_mode == O_WRONLY || _mode == O_RDWR) {
60 output_parser = new Parser (*this);
65 for (int i = 0; i < 16; i++) {
66 _channel[i] = new Channel (i, *this);
69 _channel[i]->connect_input_signals ();
73 _channel[i]->connect_output_signals ();
82 for (int i = 0; i < 16; i++) {
87 /** Send a clock tick message.
88 * \return true on success.
91 Port::clock (timestamp_t timestamp)
93 static byte clockmsg = 0xf8;
95 if (_mode != O_RDONLY) {
96 return midimsg (&clockmsg, 1, timestamp);
103 Port::cycle_start (nframes_t nframes)
105 _currently_in_cycle = true;
106 _nframes_this_cycle = nframes;
112 _currently_in_cycle = false;
113 _nframes_this_cycle = 0;