OSC: Signal for editor mixer change. (Selected or not)
[ardour.git] / libs / ardour / ardour / midi_buffer.h
index 2e2cbf65042cc958bba8eae9ee5659be78e0ef79..8593a4ebb2ad778ce0ccfe7987e01f7383c6f1c5 100644 (file)
 #define __ardour_midi_buffer_h__
 
 #include "evoral/midi_util.h"
+#include "evoral/EventSink.hpp"
+
 #include "midi++/event.h"
+
 #include "ardour/buffer.h"
-#include "ardour/event_type_map.h"
+#include "ardour/parameter_types.h"
 
 namespace ARDOUR {
 
 
 /** Buffer containing 8-bit unsigned char (MIDI) data. */
-class LIBARDOUR_API MidiBuffer : public Buffer
+class LIBARDOUR_API MidiBuffer : public Buffer, public Evoral::EventSink<framepos_t>
 {
 public:
        typedef framepos_t TimeType;
@@ -55,6 +58,9 @@ public:
        bool insert_event(const Evoral::MIDIEvent<TimeType>& event);
        bool merge_in_place(const MidiBuffer &other);
 
+       /** EventSink interface for non-RT use (export, bounce). */
+       uint32_t write(TimeType time, Evoral::EventType type, uint32_t size, const uint8_t* buf);
+
        template<typename BufferType, typename EventType>
                class iterator_base
        {
@@ -77,7 +83,7 @@ public:
                        uint8_t* ev_start = buffer->_data + offset + sizeof(TimeType);
                        int event_size = Evoral::midi_event_size(ev_start);
                        assert(event_size >= 0);
-                       return EventType(EventTypeMap::instance().midi_event_type(*ev_start),
+                       return EventType(midi_parameter_type(*ev_start),
                                        *((TimeType*)(buffer->_data + offset)),
                                        event_size, ev_start);
                }
@@ -86,13 +92,13 @@ public:
                        uint8_t* ev_start = buffer->_data + offset + sizeof(TimeType);
                        int event_size = Evoral::midi_event_size(ev_start);
                        assert(event_size >= 0);
-                       return EventType(EventTypeMap::instance().midi_event_type(*ev_start),
-                                       *((TimeType*)(buffer->_data + offset)),
+                       return EventType(midi_parameter_type(*ev_start),
+                                       *(reinterpret_cast<TimeType*>((uintptr_t)(buffer->_data + offset))),
                                        event_size, ev_start);
                }
 
                inline TimeType * timeptr() {
-                       return ((TimeType*)(buffer->_data + offset));
+                       return reinterpret_cast<TimeType*>((uintptr_t)(buffer->_data + offset));
                }
 
                inline iterator_base<BufferType, EventType>& operator++() {