summaryrefslogtreecommitdiff
path: root/libs/ardour/midi_buffer.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2011-12-22 20:14:47 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2011-12-22 20:14:47 +0000
commited2beaffeef72ddce8ac628cced672851ec5668d (patch)
treebdb318ac3bbfd06b8804e686db19b99ef5297d89 /libs/ardour/midi_buffer.cc
parent2449a787c59b383912115421fdcd7ad4cca2a581 (diff)
main fix: when transport stops, clear per-region per-playlist note trackers even if there is no capture data to process; side effects: remove unused MidiBuffer::merge() and add DEBUG::MidiTrackers as well as more and better MIDI debug tracing facilities
git-svn-id: svn://localhost/ardour2/branches/3.0@11057 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/midi_buffer.cc')
-rw-r--r--libs/ardour/midi_buffer.cc68
1 files changed, 18 insertions, 50 deletions
diff --git a/libs/ardour/midi_buffer.cc b/libs/ardour/midi_buffer.cc
index 8d07c308ee..efb7bba317 100644
--- a/libs/ardour/midi_buffer.cc
+++ b/libs/ardour/midi_buffer.cc
@@ -130,8 +130,6 @@ bool
MidiBuffer::push_back(const Evoral::MIDIEvent<TimeType>& ev)
{
const size_t stamp_size = sizeof(TimeType);
- /*cerr << "MidiBuffer: pushing event @ " << ev.time()
- << " size = " << ev.size() << endl;*/
if (_size + stamp_size + ev.size() >= _capacity) {
cerr << "MidiBuffer::push_back failed (buffer is full)" << endl;
@@ -204,6 +202,7 @@ bool
MidiBuffer::push_back(const jack_midi_event_t& ev)
{
const size_t stamp_size = sizeof(TimeType);
+
if (_size + stamp_size + ev.size >= _capacity) {
cerr << "MidiBuffer::push_back failed (buffer is full)" << endl;
return false;
@@ -214,6 +213,21 @@ MidiBuffer::push_back(const jack_midi_event_t& ev)
return false;
}
+#ifndef NDEBUG
+ if (DEBUG::MidiIO & PBD::debug_bits) {
+ DEBUG_STR_DECL(a);
+ DEBUG_STR_APPEND(a, string_compose ("midibuffer %1 push jack event @ %2 sz %3 ", this, ev.time, ev.size));
+ for (size_t i=0; i < ev.size; ++i) {
+ DEBUG_STR_APPEND(a,hex);
+ DEBUG_STR_APPEND(a,"0x");
+ DEBUG_STR_APPEND(a,(int)ev.buffer[i]);
+ DEBUG_STR_APPEND(a,' ');
+ }
+ DEBUG_STR_APPEND(a,'\n');
+ DEBUG_TRACE (DEBUG::MidiIO, DEBUG_STR(a).str());
+ }
+#endif
+
uint8_t* const write_loc = _data + _size;
*((TimeType*)write_loc) = ev.time;
memcpy(write_loc + stamp_size, ev.buffer, ev.size);
@@ -387,9 +401,9 @@ MidiBuffer::second_simultaneous_midi_byte_is_first (uint8_t a, uint8_t b)
/** Merge \a other into this buffer. Realtime safe. */
bool
-MidiBuffer::merge_in_place(const MidiBuffer &other)
+MidiBuffer::merge_in_place (const MidiBuffer &other)
{
- if (other.size() || size()) {
+ if (other.size() && size()) {
DEBUG_TRACE (DEBUG::MidiIO, string_compose ("merge in place, sizes %1/%2\n", size(), other.size()));
}
@@ -549,49 +563,3 @@ MidiBuffer::merge_in_place(const MidiBuffer &other)
return true;
}
-/** Clear, and merge \a a and \a b into this buffer.
- *
- * \return true if complete merge was successful
- */
-bool
-MidiBuffer::merge(const MidiBuffer& a, const MidiBuffer& b)
-{
- _size = 0;
-
- if (this == &a) {
- return merge_in_place(b);
- } else if (this == &b) {
- return merge_in_place(a);
- }
-
- const_iterator ai = a.begin();
- const_iterator bi = b.begin();
-
- resize(a.size() + b.size());
- while (ai != a.end() && bi != b.end()) {
- if ((*ai).time() < (*bi).time()) {
- memcpy(_data + _size, (*ai).buffer(), (*ai).size());
- _size += (*ai).size();
- ++ai;
- } else {
- memcpy(_data + _size, (*bi).buffer(), (*bi).size());
- _size += (*bi).size();
- ++bi;
- }
- }
-
- while (ai != a.end()) {
- memcpy(_data + _size, (*ai).buffer(), (*ai).size());
- _size += (*ai).size();
- ++ai;
- }
-
- while (bi != b.end()) {
- memcpy(_data + _size, (*bi).buffer(), (*bi).size());
- _size += (*bi).size();
- ++bi;
- }
-
- return true;
-}
-