summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/surfaces/push2/midi_byte_array.cc19
-rw-r--r--libs/surfaces/push2/midi_byte_array.h2
2 files changed, 21 insertions, 0 deletions
diff --git a/libs/surfaces/push2/midi_byte_array.cc b/libs/surfaces/push2/midi_byte_array.cc
index 45d0439a75..e66cd7d287 100644
--- a/libs/surfaces/push2/midi_byte_array.cc
+++ b/libs/surfaces/push2/midi_byte_array.cc
@@ -94,3 +94,22 @@ MidiByteArray & operator << (MidiByteArray & mba, const std::string & st)
mba.insert (mba.end(), st.begin(), st.end());
return mba;
}
+
+bool
+MidiByteArray::compare_n (const MidiByteArray& other, MidiByteArray::size_type n) const
+{
+ MidiByteArray::const_iterator us = begin();
+ MidiByteArray::const_iterator them = other.begin();
+
+ while (n && us != end() && them != other.end()) {
+ if ((*us) != (*them)) {
+ return false;
+ }
+ --n;
+ ++us;
+ ++them;
+ }
+
+ return true;
+}
+
diff --git a/libs/surfaces/push2/midi_byte_array.h b/libs/surfaces/push2/midi_byte_array.h
index 3d3bcecd28..f9ab60e31b 100644
--- a/libs/surfaces/push2/midi_byte_array.h
+++ b/libs/surfaces/push2/midi_byte_array.h
@@ -52,6 +52,8 @@ public:
MidiByteArray( size_t count, MIDI::byte array[] );
+ bool compare_n (const MidiByteArray& other, MidiByteArray::size_type len) const;
+
/**
Accepts a preceding count, and then a list of bytes
*/