From f356c99ca232bc1716663766a4e10438a26ed0ca Mon Sep 17 00:00:00 2001 From: Francois Best Date: Fri, 6 Aug 2021 09:35:01 +0200 Subject: [PATCH] chore: Allow copying Messages This is ground work for the `map` Thru function in PR #232. --- src/midi_Message.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/midi_Message.h b/src/midi_Message.h index dadb8960..bbd8d6a1 100644 --- a/src/midi_Message.h +++ b/src/midi_Message.h @@ -54,6 +54,20 @@ struct Message memset(sysexArray, 0, sSysExMaxSize * sizeof(DataByte)); } + inline Message(const Message& inOther) + : channel(inOther.channel) + , type(inOther.type) + , data1(inOther.data1) + , data2(inOther.data2) + , valid(inOther.valid) + , length(inOther.length) + { + if (type == midi::SystemExclusive) + { + memcpy(sysexArray, inOther.sysexArray, sSysExMaxSize * sizeof(DataByte)); + } + } + /*! The maximum size for the System Exclusive array. */ static const unsigned sSysExMaxSize = SysExMaxSize; @@ -94,7 +108,7 @@ struct Message /*! Total Length of the message. */ unsigned length; - + inline unsigned getSysExSize() const { const unsigned size = unsigned(data2) << 8 | data1;