From bf91ed99ec2b1231c7150bde7f12c8ca573f0834 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 20 Jul 2010 16:27:34 +0000 Subject: add note IDs and use them for looking up notes during a history rebuild. NOTE: INVALIDATES OLDER HISTORY FILES git-svn-id: svn://localhost/ardour2/branches/3.0@7449 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/evoral/evoral/Event.hpp | 30 +-- libs/evoral/evoral/EventList.hpp | 4 +- libs/evoral/evoral/EventRingBuffer.hpp | 3 +- libs/evoral/evoral/EventSink.hpp | 2 +- libs/evoral/evoral/MIDIEvent.hpp | 4 +- libs/evoral/evoral/Note.hpp | 10 +- libs/evoral/evoral/SMF.hpp | 5 +- libs/evoral/evoral/Sequence.hpp | 8 +- libs/evoral/evoral/types.hpp | 6 + libs/evoral/src/Event.cpp | 25 +- libs/evoral/src/Note.cpp | 16 +- libs/evoral/src/SMF.cpp | 57 ++++- libs/evoral/src/Sequence.cpp | 411 +++++++++++++++++---------------- 13 files changed, 340 insertions(+), 241 deletions(-) (limited to 'libs/evoral') diff --git a/libs/evoral/evoral/Event.hpp b/libs/evoral/evoral/Event.hpp index 75dfbdbe3a..2410b3684a 100644 --- a/libs/evoral/evoral/Event.hpp +++ b/libs/evoral/evoral/Event.hpp @@ -26,7 +26,6 @@ #include #include "evoral/types.hpp" - /** If this is not defined, all methods of MidiEvent are RT safe * but MidiEvent will never deep copy and (depending on the scenario) * may not be usable in STL containers, signals, etc. @@ -35,6 +34,9 @@ namespace Evoral { +event_id_t event_id_counter(); +event_id_t next_event_id(); +void init_event_id_counter (event_id_t n); /** An event (much like a type generic jack_midi_event_t) * @@ -43,7 +45,7 @@ namespace Evoral { template struct Event { #ifdef EVORAL_EVENT_ALLOC - Event(EventType type=0, Time time=0, uint32_t size=0, uint8_t* buf=NULL, bool alloc=false); + Event (EventType type=0, Time time=0, uint32_t size=0, uint8_t* buf=NULL, bool alloc=false); /** Copy \a copy. * @@ -56,6 +58,7 @@ struct Event { ~Event(); inline const Event& operator=(const Event& copy) { + _id = copy.id(); // XXX is this right? do we want ID copy semantics? _type = copy._type; _original_time = copy._original_time; _nominal_time = copy._nominal_time; @@ -77,20 +80,6 @@ struct Event { return *this; } - inline void shallow_copy(const Event& copy) { - if (_owns_buf) { - free(_buf); - _buf = false; - _owns_buf = false; - } - - _type = copy._type; - _original_time = copy._nominal_time; - _nominal_time = copy._nominal_time; - _size = copy._size; - _buf = copy._buf; - } - inline void set(uint8_t* buf, uint32_t size, Time t) { if (_owns_buf) { if (_size < size) { @@ -181,6 +170,9 @@ struct Event { inline const uint8_t* buffer() const { return _buf; } inline uint8_t*& buffer() { return _buf; } + inline event_id_t id() const { return _id; } + inline void set_id (event_id_t n) { _id = n; } + protected: EventType _type; /**< Type of event (application relative, NOT MIDI 'type') */ Time _original_time; /**< Sample index (or beat time) at which event is valid */ @@ -189,17 +181,17 @@ protected: uint8_t* _buf; /**< Raw MIDI data */ #ifdef EVORAL_EVENT_ALLOC - bool _owns_buf; /**< Whether buffer is locally allocated */ + bool _owns_buf; /**< Whether buffer is locally allocated */ #endif + event_id_t _id; /** UUID for each event, should probably be 64bit or at least unsigned */ }; - } // namespace Evoral template std::ostream& operator<<(std::ostream& o, const Evoral::Event