$Id$
*/
+#include <cstring>
#include <cstdlib>
#include <unistd.h>
-#include <string>
+#include <cstring>
#include <iostream>
+#include <iterator>
#include <midi++/types.h>
#include <midi++/parser.h>
default:
return "unknow MIDI event type";
}
-};
+}
Parser::Parser (Port &p)
: _port (p)
void
Parser::trace_event (Parser &p, byte *msg, size_t len)
-
{
eventType type;
ostream *o;
<< "Channel "
<< (msg[0]&0xF)+1
<< " Pitch Bend "
- << ((msg[1]<<7)|msg[2])
+ << ((msg[2]<<7)|msg[1])
<< endmsg;
break;
void
Parser::trace (bool onoff, ostream *o, const string &prefix)
-
{
trace_connection.disconnect ();
if (onoff) {
+ cerr << "enabling tracing for port " << _port.name() << endl;
trace_stream = o;
trace_prefix = prefix;
- trace_connection = any.connect
- (mem_fun (*this, &Parser::trace_event));
+ trace_connection = any.connect (mem_fun (*this, &Parser::trace_event));
} else {
trace_prefix = "";
trace_stream = 0;
return;
}
-/*
- * realtime_msg(inbyte)
- *
- * Call the real-time function for the specified byte, immediately.
+/** Call the real-time function for the specified byte, immediately.
* These can occur anywhere, so they don't change the state.
*/
-
void
Parser::realtime_msg(unsigned char inbyte)
switch (inbyte) {
case 0xf8:
- timing (*this);
+ timing (*this, _midi_clock_timestamp);
break;
case 0xfa:
- start (*this);
+ start (*this, _midi_clock_timestamp);
break;
case 0xfb:
- contineu (*this);
+ contineu (*this, _midi_clock_timestamp);
break;
case 0xfc:
- stop (*this);
+ stop (*this, _midi_clock_timestamp);
break;
case 0xfe:
/* !!! active sense message in realtime_msg: should not reach here
any (*this, &inbyte, 1);
}
-/*
- * channel_msg(inbyte)
- *
- * Interpret a Channel (voice or mode) Message status byte.
- */
+/** Interpret a Channel (voice or mode) Message status byte.
+ */
void
Parser::channel_msg(unsigned char inbyte)
{
}
}
-/*
- * system_msg(inbyte)
- *
- * Initialize (and possibly emit) the signals for the
+/** Initialize (and possibly emit) the signals for the
* specified byte. Set the state that the state-machine
* should go into. If the signal is not emitted
* immediately, it will be when the state machine gets to
* the end of the MIDI message.
*/
-
void
Parser::system_msg (unsigned char inbyte)
{
case MIDI::pitchbend:
channel_active_preparse[chan_i] (*this);
- pitchbend (*this, (msg[1]<<7)|msg[2]);
- channel_pitchbend[chan_i] (*this, (msg[1]<<7)|msg[2]);
+ pitchbend (*this, (msg[2]<<7)|msg[1]);
+ channel_pitchbend[chan_i] (*this, (msg[2]<<7)|msg[1]);
channel_active_postparse[chan_i] (*this);
break;