No more doxygen warnings for gtk2_arodur/*
[ardour.git] / libs / midi++2 / miditrace.cc
1 /*
2  * Copyright (C) 2007-2015 Paul Davis <paul@linuxaudiosystems.com>
3  *
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.
8  *
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.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18
19 #include <cstdio>
20 #include <fcntl.h>
21
22 #include "pbd/error.h"
23 #include "pbd/textreceiver.h"
24
25 Transmitter error (Transmitter::Error);
26 Transmitter info (Transmitter::Info);
27 Transmitter warning (Transmitter::Warning);
28 Transmitter fatal (Transmitter::Fatal);
29 TextReceiver text_receiver ("mmctest");
30
31 #include "midi++/port.h"
32 #include "midi++/manager.h"
33
34 using namespace MIDI;
35
36 Port *port;
37 PortRequest midi_device;
38
39 int
40 setup_midi ()
41
42 {
43         midi_device.devname = "/dev/snd/midiC0D0";
44         midi_device.tagname = "trident";
45         midi_device.mode = O_RDWR;
46         midi_device.type = Port::ALSA_RawMidi;
47
48         if ((port = MIDI::Manager::instance()->add_port (midi_device)) == 0) {
49                 info << "MIDI port is not valid" << endmsg;
50                 return -1;
51         }
52
53         return 0;
54 }
55
56 main (int argc, char *argv[])
57
58 {
59         byte buf[1];
60
61         text_receiver.listen_to (error);
62         text_receiver.listen_to (info);
63         text_receiver.listen_to (fatal);
64         text_receiver.listen_to (warning);
65
66         if (setup_midi ()) {
67                 exit (1);
68         }
69
70         port->input()->trace (true, &cout);
71
72         while (1) {
73                 if (port->read (buf, 1) < 0) {
74                         error << "cannot read byte"
75                               << endmsg;
76                         break;
77                 }
78         }
79 }
80
81