20 #ifndef __ardour_midi_buffer_h__
21 #define __ardour_midi_buffer_h__
26 #include "midi++/event.h"
50 bool push_back(TimeType time,
size_t size,
const uint8_t* data);
52 uint8_t* reserve(TimeType time,
size_t size);
55 size_t size()
const {
return _size; }
56 bool empty()
const {
return _size == 0; }
62 uint32_t write(TimeType time,
Evoral::EventType type, uint32_t size,
const uint8_t* buf);
64 template<
typename BufferType,
typename EventType>
69 : buffer(&b), offset(o) {}
72 : buffer (o.buffer), offset(o.offset) {}
83 uint8_t* ev_start = buffer->_data + offset +
sizeof(TimeType);
85 assert(event_size >= 0);
87 *((TimeType*)(buffer->_data + offset)),
88 event_size, ev_start);
92 uint8_t* ev_start = buffer->_data + offset +
sizeof(TimeType);
94 assert(event_size >= 0);
96 *(reinterpret_cast<TimeType*>((uintptr_t)(buffer->_data + offset))),
97 event_size, ev_start);
101 return reinterpret_cast<TimeType*
>((uintptr_t)(buffer->_data + offset));
105 uint8_t* ev_start = buffer->_data + offset +
sizeof(TimeType);
107 assert(event_size >= 0);
108 offset +=
sizeof(TimeType) + event_size;
113 return (buffer != other.
buffer) || (offset != other.
offset);
117 return (buffer == other.
buffer) && (offset == other.
offset);
127 iterator
begin() {
return iterator(*
this, 0); }
128 iterator
end() {
return iterator(*
this, _size); }
130 const_iterator
begin()
const {
return const_iterator(*
this, 0); }
131 const_iterator
end()
const {
return const_iterator(*
this, _size); }
134 assert (i.
buffer ==
this);
135 uint8_t* ev_start = _data + i.
offset +
sizeof (TimeType);
138 if (event_size < 0) {
143 size_t total_data_deleted =
sizeof(TimeType) + event_size;
145 if (i.
offset + total_data_deleted > _size) {
154 for (a = i.
offset, b = i.
offset + total_data_deleted; b < _size; ++b, ++a) {
158 _size -= total_data_deleted;
165 return iterator (*
this, i.
offset);
168 uint8_t*
data()
const {
return _data; }
175 static bool second_simultaneous_midi_byte_is_first (uint8_t, uint8_t);
179 friend class
iterator_base< const MidiBuffer, const Evoral::MIDIEvent<TimeType> >;
187 #endif // __ardour_midi_buffer_h__
static int midi_event_size(uint8_t status)
const_iterator begin() const
iterator erase(const iterator &i)
iterator_base< const MidiBuffer, const Evoral::MIDIEvent< TimeType > > const_iterator
EventType operator*() const
bool operator==(const iterator_base< BufferType, EventType > &other) const
iterator_base< MidiBuffer, Evoral::MIDIEvent< TimeType > > iterator
iterator_base< BufferType, EventType > & operator++()
AutomationType midi_parameter_type(uint8_t status)
const_iterator end() const
bool operator!=(const iterator_base< BufferType, EventType > &other) const