summaryrefslogtreecommitdiff
path: root/libs/ardour/midi_state_tracker.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ardour/midi_state_tracker.cc')
-rw-r--r--libs/ardour/midi_state_tracker.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/libs/ardour/midi_state_tracker.cc b/libs/ardour/midi_state_tracker.cc
index 342d9d0e58..a8f803a8a0 100644
--- a/libs/ardour/midi_state_tracker.cc
+++ b/libs/ardour/midi_state_tracker.cc
@@ -18,6 +18,10 @@
*/
#include <iostream>
+
+#include "pbd/compose.h"
+
+#include "ardour/debug.h"
#include "ardour/event_type_map.h"
#include "ardour/midi_ring_buffer.h"
#include "ardour/midi_source.h"
@@ -35,6 +39,7 @@ MidiStateTracker::MidiStateTracker ()
void
MidiStateTracker::reset ()
{
+ DEBUG_TRACE (PBD::DEBUG::MidiTrackers, string_compose ("%1: reset\n", this));
memset (_active_notes, 0, sizeof (_active_notes));
_on = 0;
}
@@ -54,6 +59,8 @@ MidiStateTracker::add (uint8_t note, uint8_t chn)
{
++_active_notes[note + 128 * chn];
++_on;
+ DEBUG_TRACE (PBD::DEBUG::MidiTrackers, string_compose ("MST @ %1 ON %2/%3 total on %4\n",
+ this, (int) note, (int) chn, _on));
}
void
@@ -71,6 +78,8 @@ MidiStateTracker::remove (uint8_t note, uint8_t chn)
break;
}
+ DEBUG_TRACE (PBD::DEBUG::MidiTrackers, string_compose ("MST @ %1 OFF %2/%3 total on %4\n",
+ this, (int) note, (int) chn, _on));
}
void
@@ -78,6 +87,8 @@ MidiStateTracker::track (const MidiBuffer::iterator &from, const MidiBuffer::ite
{
looped = false;
+ DEBUG_TRACE (PBD::DEBUG::MidiTrackers, string_compose ("%1 track notes, looped = %2\n", this, looped));
+
for (MidiBuffer::iterator i = from; i != to; ++i) {
const Evoral::MIDIEvent<MidiBuffer::TimeType> ev(*i, false);
if (ev.event_type() == LoopEventType) {
@@ -100,6 +111,8 @@ MidiStateTracker::track (const MidiBuffer::iterator &from, const MidiBuffer::ite
void
MidiStateTracker::resolve_notes (MidiBuffer &dst, framepos_t time)
{
+ DEBUG_TRACE (PBD::DEBUG::MidiTrackers, string_compose ("%1 MB-resolve notes @ %2 on = %3\n", this, time, _on));
+
if (!_on) {
return;
}
@@ -112,6 +125,8 @@ MidiStateTracker::resolve_notes (MidiBuffer &dst, framepos_t time)
(MIDI_CMD_NOTE_OFF, time, 3, buffer, false);
dst.push_back (noteoff);
_active_notes[note + 128 * channel]--;
+ DEBUG_TRACE (PBD::DEBUG::MidiTrackers, string_compose ("%1: MB-resolved note %2/%3 at %4\n",
+ this, (int) note, (int) channel, time));
}
}
}
@@ -123,6 +138,8 @@ MidiStateTracker::resolve_notes (Evoral::EventSink<framepos_t> &dst, framepos_t
{
uint8_t buf[3];
+ DEBUG_TRACE (PBD::DEBUG::MidiTrackers, string_compose ("%1 EVS-resolve notes @ %2 on = %3\n", this, time, _on));
+
if (!_on) {
return;
}
@@ -135,6 +152,8 @@ MidiStateTracker::resolve_notes (Evoral::EventSink<framepos_t> &dst, framepos_t
buf[2] = 0;
dst.write (time, EventTypeMap::instance().midi_event_type (buf[0]), 3, buf);
_active_notes[note + 128 * channel]--;
+ DEBUG_TRACE (PBD::DEBUG::MidiTrackers, string_compose ("%1: EVS-resolved note %2/%3 at %4\n",
+ this, (int) note, (int) channel, time));
}
}
}
@@ -144,6 +163,8 @@ MidiStateTracker::resolve_notes (Evoral::EventSink<framepos_t> &dst, framepos_t
void
MidiStateTracker::resolve_notes (MidiSource& src, Evoral::MusicalTime time)
{
+ DEBUG_TRACE (PBD::DEBUG::MidiTrackers, string_compose ("%1 MS-resolve notes @ %2 on = %3\n", this, time, _on));
+
if (!_on) {
return;
}
@@ -159,6 +180,8 @@ MidiStateTracker::resolve_notes (MidiSource& src, Evoral::MusicalTime time)
ev.set_note (note);
ev.set_velocity (0);
src.append_event_unlocked_beats (ev);
+ DEBUG_TRACE (PBD::DEBUG::MidiTrackers, string_compose ("%1: MS-resolved note %2/%3 at %4\n",
+ this, (int) note, (int) channel, time));
_active_notes[note + 128 * channel]--;
/* don't stack events up at the same time */
time += 1.0/128.0;