2 Copyright (C) 2012 Paul 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.
23 #include "pbd/error.h"
24 #include "pbd/textreceiver.h"
26 Transmitter error (Transmitter::Error);
27 Transmitter info (Transmitter::Info);
28 Transmitter warning (Transmitter::Warning);
29 Transmitter fatal (Transmitter::Fatal);
30 TextReceiver text_receiver ("mmctest");
32 #include "midi++/port.h"
33 #include "midi++/manager.h"
34 #include "midi++/mmc.h"
40 PortRequest midi_device;
43 MachineControl::CommandSignature cs;
44 MachineControl::ResponseSignature rs;
50 midi_device.devname = "/dev/snd/midiC0D0";
51 midi_device.tagname = "trident";
52 midi_device.mode = O_RDWR;
53 midi_device.type = Port::ALSA_RawMidi;
55 if ((port = MIDI::Manager::instance()->add_port (midi_device)) == 0) {
56 info << "MIDI port is not valid" << endmsg;
60 mmc = new MachineControl (*port, 0.0, cs, rs);
66 do_deferred_play (MachineControl &mmc)
69 cout << "Deferred Play" << endl;
73 do_stop (MachineControl &mmc)
76 cout << "Stop" << endl;
80 do_ffwd (MachineControl &mmc)
83 cout << "Fast Forward" << endl;
87 do_rewind (MachineControl &mmc)
90 cout << "Rewind" << endl;
94 do_record_status (MachineControl &mmc, size_t track, bool enabled)
97 cout << "Track " << track + 1 << (enabled ? " enabled" : " disabled")
101 main (int argc, char *argv[])
106 text_receiver.listen_to (error);
107 text_receiver.listen_to (info);
108 text_receiver.listen_to (fatal);
109 text_receiver.listen_to (warning);
116 mmc->DeferredPlay.connect (mem_fun (do_deferred_play));
117 mmc->FastForward.connect (mem_fun (do_ffwd));
118 mmc->Rewind.connect (mem_fun (do_rewind));
119 mmc->Stop.connect (mem_fun (do_stop));
120 mmc->TrackRecordStatusChange.connect (mem_fun (do_record_status));
123 if (port->read (buf, 1) < 0) {
124 error << "cannot read byte"