2010-07-06 20:40:58 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2010 Paul Davis
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
2013-07-13 08:19:03 -04:00
|
|
|
#include "pbd/localtime_r.h"
|
2013-07-13 08:19:32 -04:00
|
|
|
#include "pbd/timersub.h"
|
2013-07-13 08:19:03 -04:00
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
#include "midi++/parser.h"
|
2013-08-07 22:22:11 -04:00
|
|
|
|
|
|
|
#include "ardour/async_midi_port.h"
|
|
|
|
#include "ardour/midi_port.h"
|
|
|
|
#include "ardour/audioengine.h"
|
2010-01-06 16:56:23 -05:00
|
|
|
|
|
|
|
#include "midi_tracer.h"
|
|
|
|
#include "gui_thread.h"
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
using namespace Gtk;
|
|
|
|
using namespace std;
|
|
|
|
using namespace MIDI;
|
|
|
|
using namespace Glib;
|
|
|
|
|
2010-07-06 20:40:58 -04:00
|
|
|
MidiTracer::MidiTracer ()
|
2011-11-18 19:56:35 -05:00
|
|
|
: ArdourWindow (_("MIDI Tracer"))
|
2010-07-06 20:40:58 -04:00
|
|
|
, parser (0)
|
2010-01-06 16:56:23 -05:00
|
|
|
, line_count_adjustment (200, 1, 2000, 1, 10)
|
|
|
|
, line_count_spinner (line_count_adjustment)
|
2012-02-06 12:19:59 -05:00
|
|
|
, line_count_label (_("Line history: "))
|
2010-01-06 16:56:23 -05:00
|
|
|
, autoscroll (true)
|
|
|
|
, show_hex (true)
|
|
|
|
, collect (true)
|
2012-02-06 12:19:59 -05:00
|
|
|
, show_delta_time (false)
|
2010-06-28 19:07:05 -04:00
|
|
|
, _update_queued (0)
|
2010-01-31 22:33:52 -05:00
|
|
|
, fifo (1024)
|
|
|
|
, buffer_pool ("miditracer", buffer_size, 1024) // 1024 256 byte buffers
|
2010-01-06 16:56:23 -05:00
|
|
|
, autoscroll_button (_("Auto-Scroll"))
|
|
|
|
, base_button (_("Decimal"))
|
|
|
|
, collect_button (_("Enabled"))
|
2012-02-06 12:19:59 -05:00
|
|
|
, delta_time_button (_("Delta times"))
|
2010-01-06 16:56:23 -05:00
|
|
|
{
|
2013-08-07 22:22:11 -04:00
|
|
|
ARDOUR::AudioEngine::instance()->PortRegisteredOrUnregistered.connect
|
|
|
|
(_manager_connection, invalidator (*this), boost::bind (&MidiTracer::ports_changed, this), gui_context());
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2012-02-06 12:19:59 -05:00
|
|
|
_last_receipt.tv_sec = 0;
|
|
|
|
_last_receipt.tv_usec = 0;
|
|
|
|
|
2011-11-18 19:56:35 -05:00
|
|
|
VBox* vbox = manage (new VBox);
|
|
|
|
vbox->set_spacing (4);
|
|
|
|
|
2010-07-06 20:40:58 -04:00
|
|
|
HBox* pbox = manage (new HBox);
|
2011-11-01 21:12:53 -04:00
|
|
|
pbox->set_spacing (6);
|
2010-07-06 20:40:58 -04:00
|
|
|
pbox->pack_start (*manage (new Label (_("Port:"))), false, false);
|
|
|
|
|
|
|
|
_port_combo.signal_changed().connect (sigc::mem_fun (*this, &MidiTracer::port_changed));
|
|
|
|
pbox->pack_start (_port_combo);
|
|
|
|
pbox->show_all ();
|
2011-11-18 19:56:35 -05:00
|
|
|
vbox->pack_start (*pbox, false, false);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
scroller.add (text);
|
2011-11-18 19:56:35 -05:00
|
|
|
vbox->set_border_width (12);
|
|
|
|
vbox->pack_start (scroller, true, true);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
text.show ();
|
2010-01-31 22:33:52 -05:00
|
|
|
text.set_name ("MidiTracerTextView");
|
2010-01-06 16:56:23 -05:00
|
|
|
scroller.show ();
|
|
|
|
scroller.set_size_request (400, 400);
|
|
|
|
|
|
|
|
collect_button.set_active (true);
|
|
|
|
base_button.set_active (false);
|
|
|
|
autoscroll_button.set_active (true);
|
|
|
|
|
|
|
|
line_count_box.set_spacing (6);
|
|
|
|
line_count_box.pack_start (line_count_label, false, false);
|
|
|
|
line_count_box.pack_start (line_count_spinner, false, false);
|
|
|
|
|
|
|
|
line_count_spinner.show ();
|
|
|
|
line_count_label.show ();
|
|
|
|
line_count_box.show ();
|
|
|
|
|
2010-03-14 21:41:01 -04:00
|
|
|
HBox* bbox = manage (new HBox);
|
2011-11-18 19:56:35 -05:00
|
|
|
bbox->add (line_count_box);
|
2012-02-06 12:19:59 -05:00
|
|
|
bbox->add (delta_time_button);
|
2010-03-14 21:41:01 -04:00
|
|
|
bbox->add (base_button);
|
|
|
|
bbox->add (collect_button);
|
|
|
|
bbox->add (autoscroll_button);
|
|
|
|
bbox->show ();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-11-18 19:56:35 -05:00
|
|
|
vbox->pack_start (*bbox, false, false);
|
|
|
|
|
|
|
|
add (*vbox);
|
2010-01-06 16:56:23 -05:00
|
|
|
|
|
|
|
base_button.signal_toggled().connect (sigc::mem_fun (*this, &MidiTracer::base_toggle));
|
|
|
|
collect_button.signal_toggled().connect (sigc::mem_fun (*this, &MidiTracer::collect_toggle));
|
|
|
|
autoscroll_button.signal_toggled().connect (sigc::mem_fun (*this, &MidiTracer::autoscroll_toggle));
|
2012-02-06 12:19:59 -05:00
|
|
|
delta_time_button.signal_toggled().connect (sigc::mem_fun (*this, &MidiTracer::delta_toggle));
|
2010-01-06 16:56:23 -05:00
|
|
|
|
|
|
|
base_button.show ();
|
|
|
|
collect_button.show ();
|
|
|
|
autoscroll_button.show ();
|
|
|
|
|
2010-07-06 20:40:58 -04:00
|
|
|
ports_changed ();
|
|
|
|
port_changed ();
|
2010-01-06 16:56:23 -05:00
|
|
|
}
|
|
|
|
|
2010-01-31 22:33:52 -05:00
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
MidiTracer::~MidiTracer()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-07-06 20:40:58 -04:00
|
|
|
MidiTracer::ports_changed ()
|
|
|
|
{
|
|
|
|
string const c = _port_combo.get_active_text ();
|
|
|
|
_port_combo.clear ();
|
2013-08-07 22:22:11 -04:00
|
|
|
|
|
|
|
ARDOUR::PortManager::PortList pl;
|
|
|
|
ARDOUR::AudioEngine::instance()->get_ports (ARDOUR::DataType::MIDI, pl);
|
|
|
|
|
|
|
|
if (pl.empty()) {
|
|
|
|
_port_combo.set_active_text ("");
|
|
|
|
return;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2013-08-07 22:22:11 -04:00
|
|
|
for (ARDOUR::PortManager::PortList::const_iterator i = pl.begin(); i != pl.end(); ++i) {
|
2010-07-06 20:40:58 -04:00
|
|
|
_port_combo.append_text ((*i)->name());
|
|
|
|
}
|
|
|
|
|
2013-08-07 22:22:11 -04:00
|
|
|
if (c.empty()) {
|
|
|
|
_port_combo.set_active_text (pl.front()->name());
|
|
|
|
} else {
|
|
|
|
_port_combo.set_active_text (c);
|
|
|
|
}
|
2010-07-06 20:40:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiTracer::port_changed ()
|
2010-01-06 16:56:23 -05:00
|
|
|
{
|
2013-08-07 22:22:11 -04:00
|
|
|
using namespace ARDOUR;
|
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
disconnect ();
|
2010-07-06 20:40:58 -04:00
|
|
|
|
2013-08-07 22:22:11 -04:00
|
|
|
boost::shared_ptr<ARDOUR::Port> p = AudioEngine::instance()->get_port_by_name (_port_combo.get_active_text());
|
|
|
|
|
|
|
|
if (!p) {
|
|
|
|
std::cerr << "port not found\n";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-08-13 13:24:05 -04:00
|
|
|
/* The inheritance heirarchy makes this messy. AsyncMIDIPort has two
|
|
|
|
* available MIDI::Parsers what we could connect to, ::self_parser()
|
|
|
|
* (from ARDOUR::MidiPort) and ::parser() from MIDI::Port. One day,
|
|
|
|
* this mess will all go away ...
|
|
|
|
*/
|
|
|
|
|
2013-08-07 22:22:11 -04:00
|
|
|
boost::shared_ptr<AsyncMIDIPort> async = boost::dynamic_pointer_cast<AsyncMIDIPort> (p);
|
2010-07-06 20:40:58 -04:00
|
|
|
|
2013-08-07 22:22:11 -04:00
|
|
|
if (!async) {
|
2010-07-06 20:40:58 -04:00
|
|
|
|
2013-08-13 13:24:05 -04:00
|
|
|
boost::shared_ptr<ARDOUR::MidiPort> mp = boost::dynamic_pointer_cast<ARDOUR::MidiPort> (p);
|
|
|
|
|
|
|
|
if (mp) {
|
|
|
|
mp->self_parser().any.connect_same_thread (_parser_connection, boost::bind (&MidiTracer::tracer, this, _1, _2, _3));
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
async->parser()->any.connect_same_thread (_parser_connection, boost::bind (&MidiTracer::tracer, this, _1, _2, _3));
|
2010-07-06 20:40:58 -04:00
|
|
|
}
|
2010-01-06 16:56:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiTracer::disconnect ()
|
|
|
|
{
|
2010-07-06 20:40:58 -04:00
|
|
|
_parser_connection.disconnect ();
|
2010-01-06 16:56:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiTracer::tracer (Parser&, byte* msg, size_t len)
|
|
|
|
{
|
|
|
|
stringstream ss;
|
|
|
|
struct timeval tv;
|
2010-01-31 22:33:52 -05:00
|
|
|
char* buf;
|
2010-01-06 16:56:23 -05:00
|
|
|
struct tm now;
|
|
|
|
size_t bufsize;
|
|
|
|
size_t s;
|
|
|
|
|
|
|
|
gettimeofday (&tv, 0);
|
|
|
|
|
2010-01-31 22:33:52 -05:00
|
|
|
buf = (char *) buffer_pool.alloc ();
|
|
|
|
bufsize = buffer_size;
|
|
|
|
|
2012-02-06 12:19:59 -05:00
|
|
|
if (_last_receipt.tv_sec != 0 && show_delta_time) {
|
|
|
|
struct timeval delta;
|
|
|
|
timersub (&tv, &_last_receipt, &delta);
|
|
|
|
s = snprintf (buf, bufsize, "+%02" PRId64 ":%06" PRId64, (int64_t) delta.tv_sec, (int64_t) delta.tv_usec);
|
|
|
|
bufsize -= s;
|
|
|
|
} else {
|
|
|
|
localtime_r (&tv.tv_sec, &now);
|
|
|
|
s = strftime (buf, bufsize, "%H:%M:%S", &now);
|
|
|
|
bufsize -= s;
|
|
|
|
s += snprintf (&buf[s], bufsize, ".%06" PRId64, (int64_t) tv.tv_usec);
|
|
|
|
bufsize -= s;
|
|
|
|
}
|
|
|
|
|
|
|
|
_last_receipt = tv;
|
2010-01-31 22:33:52 -05:00
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
switch ((eventType) msg[0]&0xf0) {
|
|
|
|
case off:
|
|
|
|
if (show_hex) {
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s chn %2d %02x %02x\n", "NoteOff", (msg[0]&0xf)+1, (int) msg[1], (int) msg[2]);
|
|
|
|
} else {
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s chn %2d %-3d %-3d\n", "NoteOff", (msg[0]&0xf)+1, (int) msg[1], (int) msg[2]);
|
|
|
|
}
|
|
|
|
break;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
case on:
|
|
|
|
if (show_hex) {
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s chn %2d %02x %02x\n", "NoteOn", (msg[0]&0xf)+1, (int) msg[1], (int) msg[2]);
|
|
|
|
} else {
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s chn %2d %-3d %-3d\n", "NoteOn", (msg[0]&0xf)+1, (int) msg[1], (int) msg[2]);
|
|
|
|
}
|
|
|
|
break;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
case polypress:
|
|
|
|
if (show_hex) {
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s chn %2d %02x\n", "PolyPressure", (msg[0]&0xf)+1, (int) msg[1]);
|
|
|
|
} else {
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s chn %2d %-3d\n", "PolyPressure", (msg[0]&0xf)+1, (int) msg[1]);
|
|
|
|
}
|
|
|
|
break;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
case MIDI::controller:
|
|
|
|
if (show_hex) {
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s chn %2d %02x %02x\n", "Controller", (msg[0]&0xf)+1, (int) msg[1], (int) msg[2]);
|
|
|
|
} else {
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s chn %2d %2d %-3d\n", "Controller", (msg[0]&0xf)+1, (int) msg[1], (int) msg[2]);
|
|
|
|
}
|
|
|
|
break;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
case program:
|
|
|
|
if (show_hex) {
|
2010-05-15 19:57:41 -04:00
|
|
|
s += snprintf (&buf[s], bufsize, "%16s chn %2d %02x\n", "Program Change", (msg[0]&0xf)+1, (int) msg[1]);
|
2010-01-06 16:56:23 -05:00
|
|
|
} else {
|
2010-05-15 19:57:41 -04:00
|
|
|
s += snprintf (&buf[s], bufsize, "%16s chn %2d %-3d\n", "Program Change", (msg[0]&0xf)+1, (int) msg[1]);
|
2010-01-06 16:56:23 -05:00
|
|
|
}
|
|
|
|
break;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
case chanpress:
|
|
|
|
if (show_hex) {
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s chn %2d %02x/%-3d\n", "Channel Pressure", (msg[0]&0xf)+1, (int) msg[1], (int) msg[1]);
|
|
|
|
} else {
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s chn %2d %02x/%-3d\n", "Channel Pressure", (msg[0]&0xf)+1, (int) msg[1], (int) msg[1]);
|
|
|
|
}
|
|
|
|
break;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
case MIDI::pitchbend:
|
|
|
|
if (show_hex) {
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s chn %2d %02x\n", "Pitch Bend", (msg[0]&0xf)+1, (int) msg[1]);
|
|
|
|
} else {
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s chn %2d %-3d\n", "Pitch Bend", (msg[0]&0xf)+1, (int) msg[1]);
|
|
|
|
}
|
|
|
|
break;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
case MIDI::sysex:
|
|
|
|
if (len == 1) {
|
|
|
|
switch (msg[0]) {
|
|
|
|
case 0xf8:
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s\n", "Clock");
|
|
|
|
break;
|
|
|
|
case 0xfa:
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s\n", "Start");
|
|
|
|
break;
|
|
|
|
case 0xfb:
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s\n", "Continue");
|
|
|
|
break;
|
|
|
|
case 0xfc:
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s\n", "Stop");
|
|
|
|
break;
|
|
|
|
case 0xfe:
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s\n", "Active Sense");
|
|
|
|
break;
|
|
|
|
case 0xff:
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s\n", "Reset");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s %02x\n", "Sysex", (int) msg[1]);
|
|
|
|
break;
|
2011-06-01 13:00:29 -04:00
|
|
|
}
|
2010-02-02 12:47:05 -05:00
|
|
|
|
2010-07-07 19:49:29 -04:00
|
|
|
} else if (len > 5 && msg[0] == 0xf0 && msg[1] == 0x7f && msg[3] == 0x06) {
|
|
|
|
/* MMC */
|
|
|
|
int cmd = msg[4];
|
|
|
|
if (cmd == 0x44 && msg[5] == 0x06 && msg[6] == 0x01) {
|
|
|
|
s += snprintf (
|
|
|
|
&buf[s], bufsize, " MMC locate to %02d:%02d:%02d:%02d.%02d\n",
|
|
|
|
msg[7], msg[8], msg[9], msg[10], msg[11]
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
std::string name;
|
|
|
|
if (cmd == 0x1) {
|
|
|
|
name = "STOP";
|
|
|
|
} else if (cmd == 0x3) {
|
|
|
|
name = "DEFERRED PLAY";
|
|
|
|
} else if (cmd == 0x6) {
|
|
|
|
name = "RECORD STROBE";
|
|
|
|
} else if (cmd == 0x7) {
|
|
|
|
name = "RECORD EXIT";
|
|
|
|
} else if (cmd == 0x8) {
|
|
|
|
name = "RECORD PAUSE";
|
|
|
|
}
|
|
|
|
if (!name.empty()) {
|
|
|
|
s += snprintf (&buf[s], bufsize, " MMC command %s\n", name.c_str());
|
2010-01-06 16:56:23 -05:00
|
|
|
} else {
|
2010-07-07 19:49:29 -04:00
|
|
|
s += snprintf (&buf[s], bufsize, " MMC command %02x\n", cmd);
|
2010-01-06 16:56:23 -05:00
|
|
|
}
|
2010-07-07 19:49:29 -04:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-07-07 19:49:29 -04:00
|
|
|
} else if (len == 10 && msg[0] == 0xf0 && msg[1] == 0x7f && msg[9] == 0xf7) {
|
2010-06-29 09:46:18 -04:00
|
|
|
|
2010-07-07 19:49:29 -04:00
|
|
|
/* MTC full frame */
|
|
|
|
s += snprintf (
|
|
|
|
&buf[s], bufsize, " MTC full frame to %02d:%02d:%02d:%02d\n", msg[5] & 0x1f, msg[6], msg[7], msg[8]
|
|
|
|
);
|
2013-08-01 01:55:58 -04:00
|
|
|
} else if (len == 3 && msg[0] == MIDI::position) {
|
2010-07-07 19:49:29 -04:00
|
|
|
|
2013-08-01 01:55:58 -04:00
|
|
|
/* MIDI Song Position */
|
2013-08-02 19:23:36 -04:00
|
|
|
int midi_beats = (msg[2] << 7) | msg[1];
|
2013-08-01 01:55:58 -04:00
|
|
|
s += snprintf (&buf[s], bufsize, "%16s %d\n", "Position", (int) midi_beats);
|
2010-07-07 19:49:29 -04:00
|
|
|
} else {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-07-07 19:49:29 -04:00
|
|
|
/* other sys-ex */
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-07-07 19:49:29 -04:00
|
|
|
s += snprintf (&buf[s], bufsize, "%16s (%d) = [", "Sysex", (int) len);
|
|
|
|
bufsize -= s;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-07-07 19:49:29 -04:00
|
|
|
for (unsigned int i = 0; i < len && bufsize > 3; ++i) {
|
|
|
|
if (i > 0) {
|
|
|
|
s += snprintf (&buf[s], bufsize, " %02x", msg[i]);
|
|
|
|
} else {
|
|
|
|
s += snprintf (&buf[s], bufsize, "%02x", msg[i]);
|
2010-06-29 09:46:18 -04:00
|
|
|
}
|
2010-07-07 19:49:29 -04:00
|
|
|
bufsize -= s;
|
2010-01-06 16:56:23 -05:00
|
|
|
}
|
2010-07-07 19:49:29 -04:00
|
|
|
s += snprintf (&buf[s], bufsize, "]\n");
|
2010-01-06 16:56:23 -05:00
|
|
|
}
|
|
|
|
break;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
case MIDI::song:
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s\n", "Song");
|
|
|
|
break;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
case MIDI::tune:
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s\n", "Tune");
|
|
|
|
break;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
case MIDI::eox:
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s\n", "EOX");
|
|
|
|
break;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
case MIDI::timing:
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s\n", "Timing");
|
|
|
|
break;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
case MIDI::start:
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s\n", "Start");
|
|
|
|
break;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
case MIDI::stop:
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s\n", "Stop");
|
|
|
|
break;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
case MIDI::contineu:
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s\n", "Continue");
|
|
|
|
break;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
case active:
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s\n", "Active Sense");
|
|
|
|
break;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
default:
|
|
|
|
s += snprintf (&buf[s], bufsize, "%16s\n", "Unknown");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If you want to append more to the line, uncomment this first
|
2010-01-31 22:33:52 -05:00
|
|
|
// bufsize -= s;
|
|
|
|
|
|
|
|
fifo.write (&buf, 1);
|
2010-01-06 16:56:23 -05:00
|
|
|
|
2013-08-14 12:40:49 -04:00
|
|
|
if (g_atomic_int_get (const_cast<gint*> (&_update_queued)) == 0) {
|
2010-03-30 11:18:43 -04:00
|
|
|
gui_context()->call_slot (invalidator (*this), boost::bind (&MidiTracer::update, this));
|
2013-08-14 12:40:49 -04:00
|
|
|
g_atomic_int_inc (const_cast<gint*> (&_update_queued));
|
2010-01-31 22:33:52 -05:00
|
|
|
}
|
2010-01-06 16:56:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-01-31 22:33:52 -05:00
|
|
|
MidiTracer::update ()
|
2010-01-06 16:56:23 -05:00
|
|
|
{
|
2010-01-31 22:33:52 -05:00
|
|
|
bool updated = false;
|
2013-08-14 12:40:49 -04:00
|
|
|
g_atomic_int_dec_and_test (const_cast<gint*> (&_update_queued));
|
2010-01-31 22:33:52 -05:00
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
RefPtr<TextBuffer> buf (text.get_buffer());
|
|
|
|
|
|
|
|
int excess = buf->get_line_count() - line_count_adjustment.get_value();
|
|
|
|
|
|
|
|
if (excess > 0) {
|
|
|
|
buf->erase (buf->begin(), buf->get_iter_at_line (excess));
|
|
|
|
}
|
|
|
|
|
2010-01-31 22:33:52 -05:00
|
|
|
char *str;
|
|
|
|
|
|
|
|
while (fifo.read (&str, 1)) {
|
|
|
|
buf->insert (buf->end(), string (str));
|
|
|
|
buffer_pool.release (str);
|
|
|
|
updated = true;
|
|
|
|
}
|
2010-01-06 16:56:23 -05:00
|
|
|
|
2010-01-31 22:33:52 -05:00
|
|
|
if (updated && autoscroll) {
|
2010-01-06 16:56:23 -05:00
|
|
|
scroller.get_vadjustment()->set_value (scroller.get_vadjustment()->get_upper());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiTracer::base_toggle ()
|
|
|
|
{
|
|
|
|
show_hex = !base_button.get_active();
|
|
|
|
}
|
|
|
|
|
2012-02-06 12:19:59 -05:00
|
|
|
void
|
|
|
|
MidiTracer::delta_toggle ()
|
|
|
|
{
|
|
|
|
show_delta_time = delta_time_button.get_active();
|
|
|
|
}
|
|
|
|
|
2010-01-06 16:56:23 -05:00
|
|
|
void
|
|
|
|
MidiTracer::collect_toggle ()
|
|
|
|
{
|
|
|
|
if (collect_button.get_active ()) {
|
2010-07-06 20:40:58 -04:00
|
|
|
port_changed ();
|
2010-01-06 16:56:23 -05:00
|
|
|
} else {
|
|
|
|
disconnect ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiTracer::autoscroll_toggle ()
|
|
|
|
{
|
|
|
|
autoscroll = autoscroll_button.get_active ();
|
|
|
|
}
|