From 8f8a4878f30795b7ac5398c8daa6b01b5c6d4468 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 19 Nov 2014 20:47:18 -0500 Subject: [PATCH] Clean up some MIDI code. --- libs/ardour/ardour/midi_playlist.h | 7 ++- libs/ardour/ardour/midi_port.h | 1 - libs/ardour/ardour/midi_source.h | 33 +++++------ libs/ardour/ardour/midi_state_tracker.h | 19 +++++- libs/ardour/midi_source.cc | 79 +++++++++---------------- libs/ardour/midi_state_tracker.cc | 25 +------- 6 files changed, 68 insertions(+), 96 deletions(-) diff --git a/libs/ardour/ardour/midi_playlist.h b/libs/ardour/ardour/midi_playlist.h index b118214c9e..2603de45f7 100644 --- a/libs/ardour/ardour/midi_playlist.h +++ b/libs/ardour/ardour/midi_playlist.h @@ -25,15 +25,20 @@ #include "ardour/ardour.h" #include "ardour/playlist.h" -#include "ardour/midi_state_tracker.h" #include "evoral/Parameter.hpp" +namespace Evoral { +template class EventSink; +} + namespace ARDOUR { class Session; class MidiRegion; class Source; +class MidiStateTracker; + template class MidiRingBuffer; class LIBARDOUR_API MidiPlaylist : public ARDOUR::Playlist diff --git a/libs/ardour/ardour/midi_port.h b/libs/ardour/ardour/midi_port.h index cc9fee1b15..debe29877a 100644 --- a/libs/ardour/ardour/midi_port.h +++ b/libs/ardour/ardour/midi_port.h @@ -25,7 +25,6 @@ #include "ardour/port.h" #include "ardour/midi_buffer.h" -#include "ardour/midi_state_tracker.h" namespace ARDOUR { diff --git a/libs/ardour/ardour/midi_source.h b/libs/ardour/ardour/midi_source.h index 411c76eeea..364b220ebb 100644 --- a/libs/ardour/ardour/midi_source.h +++ b/libs/ardour/ardour/midi_source.h @@ -53,32 +53,29 @@ class LIBARDOUR_API MidiSource : virtual public Source, public boost::enable_sha * \param newsrc MidiSource to which data will be written. Should be a * new, empty source. If it already has contents, the results are * undefined. Source must be writable. - * * \param begin time of earliest event that can be written. * \param end time of latest event that can be written. - * - * Returns zero on success, non-zero if the write failed for any - * reason. - * + * \return zero on success, non-zero if the write failed for any reason. */ int write_to (boost::shared_ptr newsrc, - Evoral::MusicalTime begin = Evoral::MinMusicalTime, - Evoral::MusicalTime end = Evoral::MaxMusicalTime); + Evoral::MusicalTime begin = Evoral::MinMusicalTime, + Evoral::MusicalTime end = Evoral::MaxMusicalTime); /** Read the data in a given time range from the MIDI source. * All time stamps in parameters are in audio frames (even if the source has tempo time). - * \param dst Ring buffer where read events are written - * \param source_start Start position of the SOURCE in this read context - * \param start Start of range to be read - * \param cnt Length of range to be read (in audio frames) - * \param tracker an optional pointer to MidiStateTracker object, for note on/off tracking + * \param dst Ring buffer where read events are written. + * \param source_start Start position of the SOURCE in this read context. + * \param start Start of range to be read. + * \param cnt Length of range to be read (in audio frames). + * \param tracker an optional pointer to MidiStateTracker object, for note on/off tracking. + * \param filtered Parameters whose MIDI messages will not be returned. */ - virtual framecnt_t midi_read (Evoral::EventSink& dst, - framepos_t source_start, - framepos_t start, - framecnt_t cnt, - MidiStateTracker* tracker, - std::set const &) const; + virtual framecnt_t midi_read (Evoral::EventSink& dst, + framepos_t source_start, + framepos_t start, + framecnt_t cnt, + MidiStateTracker* tracker, + const std::set& filtered) const; /** Write data from a MidiRingBuffer to this source. * @param source Source to read from. diff --git a/libs/ardour/ardour/midi_state_tracker.h b/libs/ardour/ardour/midi_state_tracker.h index 046e77f38c..a77ffdada3 100644 --- a/libs/ardour/ardour/midi_state_tracker.h +++ b/libs/ardour/ardour/midi_state_tracker.h @@ -52,9 +52,24 @@ public: return _active_notes[(channel*128)+note] > 0; } -private: - void track_note_onoffs(const Evoral::MIDIEvent& event); + template + void track (const Evoral::Event