From 5155a36002b37e0f7728882ddafc09c0b116f99b Mon Sep 17 00:00:00 2001 From: Michael Fisher Date: Fri, 2 Aug 2013 18:23:36 -0500 Subject: [PATCH] Send and Read MIDI Positions the right way --- gtk2_ardour/midi_tracer.cc | 3 +-- libs/ardour/ticker.cc | 9 ++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/gtk2_ardour/midi_tracer.cc b/gtk2_ardour/midi_tracer.cc index 9d6fa44cee..5038cc7b0a 100644 --- a/gtk2_ardour/midi_tracer.cc +++ b/gtk2_ardour/midi_tracer.cc @@ -303,8 +303,7 @@ MidiTracer::tracer (Parser&, byte* msg, size_t len) } else if (len == 3 && msg[0] == MIDI::position) { /* MIDI Song Position */ - uint16_t midi_beats = (uint16_t) msg[1]; - midi_beats |= msg[2]; + int midi_beats = (msg[2] << 7) | msg[1]; s += snprintf (&buf[s], bufsize, "%16s %d\n", "Position", (int) midi_beats); } else { diff --git a/libs/ardour/ticker.cc b/libs/ardour/ticker.cc index 0a4081bec7..f32cdf9415 100644 --- a/libs/ardour/ticker.cc +++ b/libs/ardour/ticker.cc @@ -386,11 +386,10 @@ MidiClockTicker::send_position_event (uint32_t midi_beats, pframes_t offset) } /* split midi beats into a 14bit value */ - MIDI::byte msg[3] = { - MIDI_CMD_COMMON_SONG_POS, - midi_beats & 0x007f, - midi_beats & 0x3f80 - }; + MIDI::byte msg[3]; + msg[0] = MIDI_CMD_COMMON_SONG_POS; + msg[1] = midi_beats & 0x007f; + msg[2] = midi_beats >> 7; _midi_port->midimsg (msg, sizeof (msg), offset);