+ 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);
+
+ if (event_size < 0) {
+ /* unknown size, sysex: return end() */
+ return end();
+ }
+
+ size_t total_data_deleted = sizeof(TimeType) + event_size;
+
+ if (i.offset + total_data_deleted > _size) {
+ _size = 0;
+ return end();
+ }
+
+ /* we need to avoid the temporary malloc that memmove would do,
+ so copy by hand. remember: this is small amounts of data ...
+ */
+ size_t a, b;
+ for (a = i.offset, b = i.offset + total_data_deleted; b < _size; ++b, ++a) {
+ _data[a] = _data[b];
+ }
+
+ _size -= total_data_deleted;
+
+ /* all subsequent iterators are now invalid, and the one we
+ * return should refer to the event we copied, which was after
+ * the one we just erased.
+ */
+
+ return iterator (*this, i.offset);
+ }
+
+ uint8_t* data() const { return _data; }
+
+ /**
+ * returns true if the message with the second argument as its MIDI
+ * status byte should preceed the message with the first argument as
+ * its MIDI status byte.
+ */
+ static bool second_simultaneous_midi_byte_is_first (uint8_t, uint8_t);
+