Line data Source code
1 : #pragma once 2 : 3 : #include "MIDIReadEvent.hpp" 4 : #include "MIDI_MessageTypes.hpp" 5 : #include <Settings/NamespaceSettings.hpp> 6 : 7 : BEGIN_CS_NAMESPACE 8 : 9 : /// MIDI message variant type (with timestamp). 10 : struct AnyMIDIMessage { 11 : MIDIReadEvent eventType = MIDIReadEvent::NO_MESSAGE; 12 : union Message { 13 : ChannelMessage channelmessage; 14 : SysCommonMessage syscommonmessage; 15 : RealTimeMessage realtimemessage; 16 : SysExMessage sysexmessage; 17 : 18 29 : Message() : realtimemessage(0x00) {} 19 33 : Message(ChannelMessage msg) : channelmessage(msg) {} 20 1 : Message(SysCommonMessage msg) : syscommonmessage(msg) {} 21 2 : Message(RealTimeMessage msg) : realtimemessage(msg) {} 22 4 : Message(SysExMessage msg) : sysexmessage(msg) {} 23 : } message; 24 : uint16_t timestamp = 0xFFFF; 25 : 26 29 : AnyMIDIMessage() = default; 27 33 : AnyMIDIMessage(ChannelMessage message, uint16_t timestamp) 28 33 : : eventType(MIDIReadEvent::CHANNEL_MESSAGE), message(message), 29 33 : timestamp(timestamp) {} 30 1 : AnyMIDIMessage(SysCommonMessage message, uint16_t timestamp) 31 1 : : eventType(MIDIReadEvent::SYSCOMMON_MESSAGE), message(message), 32 1 : timestamp(timestamp) {} 33 2 : AnyMIDIMessage(RealTimeMessage message, uint16_t timestamp) 34 2 : : eventType(MIDIReadEvent::REALTIME_MESSAGE), message(message), 35 2 : timestamp(timestamp) {} 36 4 : AnyMIDIMessage(SysExMessage message, uint16_t timestamp) 37 4 : : eventType(message.isLastChunk() ? MIDIReadEvent::SYSEX_MESSAGE 38 : : MIDIReadEvent::SYSEX_CHUNK), 39 4 : message(message), timestamp(timestamp) {} 40 : }; 41 : 42 : END_CS_NAMESPACE