Control Surface new-input
MIDI Control Surface library for Arduino
USBMIDI_Interface.ipp
Go to the documentation of this file.
2 
4 
5 // Reading MIDI
6 // -----------------------------------------------------------------------------
7 
8 template <class Backend>
10  auto pullpacket = [this](typename Backend::MIDIUSBPacket_t &packet) {
11  packet = backend.read();
12  return packet[0] != 0x00;
13  };
14  return parser.pull(LambdaPuller(std::move(pullpacket)));
15 }
16 
17 template <class Backend>
20 }
21 
22 template <class Backend>
25 }
26 
27 // Retrieving the received messages
28 // -----------------------------------------------------------------------------
29 
30 template <class Backend>
32  return parser.getChannelMessage();
33 }
34 
35 template <class Backend>
38  return parser.getSysCommonMessage();
39 }
40 
41 template <class Backend>
43  return parser.getRealTimeMessage();
44 }
45 
46 template <class Backend>
48  return parser.getSysExMessage();
49 }
50 
51 // Sending MIDI
52 // -----------------------------------------------------------------------------
53 
54 template <class Backend>
56  ChannelMessage msg) {
57  sender.sendChannelMessage(msg, Sender{this});
58  if (alwaysSendImmediately_)
59  backend.sendNow();
60 }
61 
62 template <class Backend>
64  SysCommonMessage msg) {
65  sender.sendSysCommonMessage(msg, Sender{this});
66  if (alwaysSendImmediately_)
67  backend.sendNow();
68 }
69 
70 template <class Backend>
72  sender.sendSysEx(msg, Sender{this});
73  if (alwaysSendImmediately_)
74  backend.sendNow();
75 }
76 
77 template <class Backend>
79  sender.sendRealTimeMessage(msg, Sender{this});
80  if (alwaysSendImmediately_)
81  backend.sendNow();
82 }
83 
LambdaPuller_< Lambda > LambdaPuller(Lambda &&lambda)
MIDIReadEvent
Values returned by the MIDI reading functions.
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
ChannelMessage getChannelMessage() const
Return the received channel voice message.
RealTimeMessage getRealTimeMessage() const
Return the received real-time message.
void sendChannelMessageImpl(ChannelMessage) override
Low-level function for sending a MIDI channel voice message.
void handleStall() override
Call back that should finish any MIDI messages that are in progress, and un-stall the pipe or MIDI so...
void update() override
Read the MIDI interface and call the callback if a message was received.
SysCommonMessage getSysCommonMessage() const
Return the received system common message.
void sendRealTimeImpl(RealTimeMessage) override
Low-level function for sending a MIDI real-time message.
void sendSysExImpl(SysExMessage) override
Low-level function for sending a system exclusive MIDI message.
void sendSysCommonImpl(SysCommonMessage) override
Low-level function for sending a MIDI system common message.
MIDIReadEvent read()
Try reading and parsing a single incoming MIDI message.
SysExMessage getSysExMessage() const
Return the received system exclusive message.
static void updateIncoming(MIDIInterface_t *iface)
Read, parse and dispatch incoming MIDI messages on the given interface.
remove_reference< T >::type && move(T &&t)
Definition: move.h:16
Functor to send USB MIDI packets.
virtual void handleStall()=0
Call back that should finish any MIDI messages that are in progress, and un-stall the pipe or MIDI so...