summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2009-10-24 13:26:56 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2009-10-24 13:26:56 +0000
commitf8fe64a91e7ae7f6ac761e8ae16a485ed70fb994 (patch)
tree7b2942e9bdbb4f1b52d53640b62411c8da9d4e0b /libs/ardour/ardour
parentdbc75e074912fc3647899711e838d4e5b675e175 (diff)
(FULL commit) start of a nominal debug tracing system, with 64 bits available for flags; track notes by region in MidiPlaylist, and resolve them if they are left hanging at region boundaries. note: MIDI playback is still not working 100% though its better now.
git-svn-id: svn://localhost/ardour2/branches/3.0@5903 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/ardour')
-rw-r--r--libs/ardour/ardour/debug.h52
-rw-r--r--libs/ardour/ardour/midi_region.h4
-rw-r--r--libs/ardour/ardour/midi_source.h8
-rw-r--r--libs/ardour/ardour/midi_state_tracker.h12
-rw-r--r--libs/ardour/ardour/smf_source.h2
5 files changed, 68 insertions, 10 deletions
diff --git a/libs/ardour/ardour/debug.h b/libs/ardour/ardour/debug.h
new file mode 100644
index 0000000000..db482275a9
--- /dev/null
+++ b/libs/ardour/ardour/debug.h
@@ -0,0 +1,52 @@
+/*
+ Copyright (C) 2009 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.
+
+*/
+
+#ifndef __ardour_debug_h__
+#define __ardour_debug_h__
+
+#include <sstream>
+
+namespace ARDOUR {
+
+ extern uint64_t debug_bits;
+ void debug_print (std::string str);
+ void set_debug_bits (uint64_t bits);
+
+ namespace DEBUG {
+
+ /* this namespace is so that we can write DEBUG::bit_name */
+
+ enum DebugBits {
+ MidiSourceIO = 0x1
+ };
+ }
+}
+
+#ifndef NDEBUG
+#define DEBUG_TRACE(bits,str) if ((bits) & ARDOUR::debug_bits) { ARDOUR::debug_print (str); }
+#define DEBUG_STR_SET(id,s) std::stringstream __debug_str ## id; __debug_str ## id << s;
+#define DEBUG_STR(id) __debug_str ## id
+#else
+#define DEBUG_TRACE(bits,fmt,...) /*empty*/
+#define DEBUG_STR_SET(a,b) /* empty */
+#define DEBUG_STR(a) /* empty */
+#endif
+
+#endif /* __ardour_debug_h__ */
+
diff --git a/libs/ardour/ardour/midi_region.h b/libs/ardour/ardour/midi_region.h
index f8f663bc78..5bd338b39e 100644
--- a/libs/ardour/ardour/midi_region.h
+++ b/libs/ardour/ardour/midi_region.h
@@ -56,7 +56,7 @@ class MidiRegion : public Region
virtual nframes_t read (Sample*, sframes_t /*pos*/, nframes_t /*cnt*/, int /*channel*/) const { return 0; }
virtual sframes_t readable_length() const { return length(); }
- nframes_t read_at (MidiRingBuffer<nframes_t>& dst,
+ nframes_t read_at (Evoral::EventSink<nframes_t>& dst,
sframes_t position,
nframes_t dur,
uint32_t chan_n = 0,
@@ -105,7 +105,7 @@ class MidiRegion : public Region
MidiRegion (const SourceList &, const XMLNode&);
private:
- nframes_t _read_at (const SourceList&, MidiRingBuffer<nframes_t>& dst,
+ nframes_t _read_at (const SourceList&, Evoral::EventSink<nframes_t>& dst,
sframes_t position,
nframes_t dur,
uint32_t chan_n = 0,
diff --git a/libs/ardour/ardour/midi_source.h b/libs/ardour/ardour/midi_source.h
index 1b452a7c4d..b11387f8de 100644
--- a/libs/ardour/ardour/midi_source.h
+++ b/libs/ardour/ardour/midi_source.h
@@ -58,14 +58,14 @@ class MidiSource : virtual public Source
* \param negative_stamp_offset Offset to subtract from event times written to dst
* \param tracker an optional pointer to MidiStateTracker object, for note on/off tracking
*/
- virtual nframes_t midi_read (MidiRingBuffer<nframes_t>& dst,
+ virtual nframes_t midi_read (Evoral::EventSink<nframes_t>& dst,
sframes_t source_start,
sframes_t start, nframes_t cnt,
sframes_t stamp_offset, sframes_t negative_stamp_offset, MidiStateTracker*) const;
virtual nframes_t midi_write (MidiRingBuffer<nframes_t>& src,
- sframes_t source_start,
- nframes_t cnt);
+ sframes_t source_start,
+ nframes_t cnt);
virtual void append_event_unlocked_beats(const Evoral::Event<Evoral::MusicalTime>& ev) = 0;
@@ -114,7 +114,7 @@ class MidiSource : virtual public Source
protected:
virtual void flush_midi() = 0;
- virtual nframes_t read_unlocked (MidiRingBuffer<nframes_t>& dst,
+ virtual nframes_t read_unlocked (Evoral::EventSink<nframes_t>& dst,
sframes_t position,
sframes_t start, nframes_t cnt,
sframes_t stamp_offset, sframes_t negative_stamp_offset,
diff --git a/libs/ardour/ardour/midi_state_tracker.h b/libs/ardour/ardour/midi_state_tracker.h
index 7b95772cac..76a669838a 100644
--- a/libs/ardour/ardour/midi_state_tracker.h
+++ b/libs/ardour/ardour/midi_state_tracker.h
@@ -23,9 +23,12 @@
#include <bitset>
#include "ardour/midi_buffer.h"
+namespace Evoral {
+template <typename T> class EventSink;
+}
+
namespace ARDOUR {
-template <typename T> class MidiRingBuffer;
/** Tracks played notes, so they can be resolved in potential stuck note
* situations (e.g. looping, transport stop, etc).
@@ -39,14 +42,17 @@ public:
void add (uint8_t note, uint8_t chn);
void remove (uint8_t note, uint8_t chn);
void resolve_notes (MidiBuffer& buffer, nframes64_t time);
- void resolve_notes (MidiRingBuffer<nframes_t>& buffer, nframes64_t time);
+ void resolve_notes (Evoral::EventSink<nframes_t>& buffer, nframes64_t time);
void dump (std::ostream&);
void reset ();
+ bool empty() const { return _on == 0; }
+ uint16_t on() const { return _on; }
private:
void track_note_onoffs(const Evoral::MIDIEvent<MidiBuffer::TimeType>& event);
- uint8_t _active_notes[128*16];
+ uint8_t _active_notes[128*16];
+ uint16_t _on;
};
diff --git a/libs/ardour/ardour/smf_source.h b/libs/ardour/ardour/smf_source.h
index e02f8eddc0..5ded3537e9 100644
--- a/libs/ardour/ardour/smf_source.h
+++ b/libs/ardour/ardour/smf_source.h
@@ -70,7 +70,7 @@ public:
static bool safe_midi_file_extension (const Glib::ustring& path);
private:
- nframes_t read_unlocked (MidiRingBuffer<nframes_t>& dst,
+ nframes_t read_unlocked (Evoral::EventSink<nframes_t>& dst,
sframes_t position,
sframes_t start,
nframes_t cnt,