Fix MIDI CC record/playback crash.
[ardour.git] / libs / evoral / evoral / Sequence.hpp
index 484afa84598d16008b5f812ebe4d2568dae24a5b..4e6420fbb19ce88633585a7d157691ff72cbf518 100644 (file)
 #include "evoral/visibility.h"
 #include "evoral/types.hpp"
 #include "evoral/Note.hpp"
-#include "evoral/Parameter.hpp"
 #include "evoral/ControlSet.hpp"
 #include "evoral/ControlList.hpp"
 #include "evoral/PatchChange.hpp"
 
 namespace Evoral {
 
+class Parameter;
 class TypeMap;
 template<typename Time> class EventSink;
 template<typename Time> class Note;
@@ -105,10 +105,12 @@ public:
                ResolveStuckNotes
        };
 
-       void end_write (StuckNoteOption, Time when = 0);
+       void end_write (StuckNoteOption, Time when = Time());
 
        void append(const Event<Time>& ev, Evoral::event_id_t evid);
 
+       const TypeMap& type_map() const { return _type_map; }
+
        inline size_t n_notes() const { return _notes.size(); }
        inline bool   empty()   const { return _notes.empty() && _sysexes.empty() && _patch_changes.empty() && ControlSet::controls_empty(); }
 
@@ -127,7 +129,7 @@ public:
        struct EarlierNoteComparator {
                inline bool operator()(const boost::shared_ptr< const Note<Time> > a,
                                       const boost::shared_ptr< const Note<Time> > b) const {
-                       return musical_time_less_than (a->time(), b->time());
+                       return a->time() < b->time();
                }
        };
 
@@ -135,7 +137,7 @@ public:
                typedef const Note<Time>* value_type;
                inline bool operator()(const boost::shared_ptr< const Note<Time> > a,
                                       const boost::shared_ptr< const Note<Time> > b) const {
-                       return musical_time_greater_than (a->time(), b->time());
+                       return a->time() > b->time();
                }
        };
 
@@ -143,7 +145,7 @@ public:
                typedef const Note<Time>* value_type;
                inline bool operator()(const boost::shared_ptr< const Note<Time> > a,
                                       const boost::shared_ptr< const Note<Time> > b) const {
-                       return musical_time_greater_than (a->end_time(), b->end_time());
+                       return a->end_time() > b->end_time();
                }
        };
 
@@ -187,7 +189,7 @@ public:
 
        struct EarlierSysExComparator {
                inline bool operator() (constSysExPtr a, constSysExPtr b) const {
-                       return musical_time_less_than (a->time(), b->time());
+                       return a->time() < b->time();
                }
        };
 
@@ -200,7 +202,7 @@ public:
 
        struct EarlierPatchChangeComparator {
                inline bool operator() (constPatchChangePtr a, constPatchChangePtr b) const {
-                       return musical_time_less_than (a->time(), b->time());
+                       return a->time() < b->time();
                }
        };
 
@@ -215,7 +217,7 @@ private:
 public:
 
        /** Read iterator */
-       class LIBEVORAL_API /* Added by JE - */ const_iterator {
+       class LIBEVORAL_API const_iterator {
        public:
                const_iterator();
                const_iterator(const Sequence<Time>& seq, Time t, bool, std::set<Evoral::Parameter> const &);
@@ -240,6 +242,9 @@ public:
        private:
                friend class Sequence<Time>;
 
+               Time choose_next(Time earliest_t);
+               void set_event();
+
                typedef std::vector<ControlIterator> ControlIterators;
                enum MIDIMessageType { NIL, NOTE_ON, NOTE_OFF, CONTROL, SYSEX, PATCH_CHANGE };
 
@@ -262,7 +267,7 @@ public:
        };
 
        const_iterator begin (
-               Time t = 0,
+               Time t = Time(),
                bool force_discrete = false,
                std::set<Evoral::Parameter> const & f = std::set<Evoral::Parameter> ()) const {
                return const_iterator (*this, t, force_discrete, f);