Rewrite Sequence::const_iterator.
[ardour.git] / libs / evoral / evoral / midi_util.h
index 5dfc3c70fdf7325d099f09ee4b8c4bef2ef6e619..e290a4141d8a8cd8bf5218b2b364157f3a0ee2cf 100644 (file)
 #ifndef EVORAL_MIDI_UTIL_H
 #define EVORAL_MIDI_UTIL_H
 
+#include <stdint.h>
+#include <stdbool.h>
 #include <assert.h>
-
 #include "evoral/midi_events.h"
 
 namespace Evoral {
 
+
 /** Return the size of the given event including the status byte,
  * or -1 if unknown (e.g. sysex)
  */
 static inline int
-midi_event_size(unsigned char status)
+midi_event_size(uint8_t status)
 {
        // if we have a channel event
        if (status >= 0x80 && status < 0xF0) {
@@ -92,6 +94,18 @@ midi_event_size(uint8_t* buffer)
        }
 }
 
+/** Return true iff the given buffer is a valid MIDI event */
+static inline bool
+midi_event_is_valid(uint8_t* buffer, size_t len)
+{
+       uint8_t status = buffer[0];
+       if (status < 0x80) {
+               return false;
+       }
+       return true;
+}
+
+
 } // namespace Evoral
 
 #endif // EVORAL_MIDI_UTIL_H