diff --git a/libs/ardour/ardour/midi_buffer.h b/libs/ardour/ardour/midi_buffer.h index b6966faa06..2e2cbf6504 100644 --- a/libs/ardour/ardour/midi_buffer.h +++ b/libs/ardour/ardour/midi_buffer.h @@ -56,14 +56,16 @@ public: bool merge_in_place(const MidiBuffer &other); template - class iterator_base { + class iterator_base + { public: - iterator_base(BufferType& b, framecnt_t o) - : buffer(&b), offset(o) {} - iterator_base(const iterator_base& o) - : buffer (o.buffer), offset(o.offset) {} - - inline iterator_base operator= (const iterator_base& o) { + iterator_base(BufferType& b, framecnt_t o) + : buffer(&b), offset(o) {} + + iterator_base(const iterator_base& o) + : buffer (o.buffer), offset(o.offset) {} + + inline iterator_base operator= (const iterator_base& o) { if (&o != this) { buffer = o.buffer; offset = o.offset; @@ -79,6 +81,7 @@ public: *((TimeType*)(buffer->_data + offset)), event_size, ev_start); } + inline EventType operator*() { uint8_t* ev_start = buffer->_data + offset + sizeof(TimeType); int event_size = Evoral::midi_event_size(ev_start); @@ -99,12 +102,15 @@ public: offset += sizeof(TimeType) + event_size; return *this; } + inline bool operator!=(const iterator_base& other) const { return (buffer != other.buffer) || (offset != other.offset); } + inline bool operator==(const iterator_base& other) const { return (buffer == other.buffer) && (offset == other.offset); } + BufferType* buffer; size_t offset; }; @@ -118,7 +124,7 @@ public: const_iterator begin() const { return const_iterator(*this, 0); } const_iterator end() const { return const_iterator(*this, _size); } - iterator erase(const iterator& i) { + iterator erase(const iterator& i) { assert (i.buffer == this); uint8_t* ev_start = _data + i.offset + sizeof (TimeType); int event_size = Evoral::midi_event_size (ev_start); @@ -161,7 +167,7 @@ public: * its MIDI status byte. */ static bool second_simultaneous_midi_byte_is_first (uint8_t, uint8_t); - + private: friend class iterator_base< MidiBuffer, Evoral::MIDIEvent >; friend class iterator_base< const MidiBuffer, const Evoral::MIDIEvent >; @@ -170,7 +176,6 @@ private: pframes_t _size; }; - } // namespace ARDOUR #endif // __ardour_midi_buffer_h__