Arduino MIDI Library  Version 4.3
MIDI Input

Modules

 Callbacks
 

Functions

bool MidiInterface< SerialPort, _Settings >::read ()
 Read messages from the serial port using the main input channel. More...
 
bool MidiInterface< SerialPort, _Settings >::read (Channel inChannel)
 Read messages on a specified channel. More...
 
MidiType MidiInterface< SerialPort, _Settings >::getType () const
 Get the last received message's type. More...
 
Channel MidiInterface< SerialPort, _Settings >::getChannel () const
 Get the channel of the message stored in the structure. More...
 
DataByte MidiInterface< SerialPort, _Settings >::getData1 () const
 Get the first data byte of the last received message. More...
 
DataByte MidiInterface< SerialPort, _Settings >::getData2 () const
 Get the second data byte of the last received message. More...
 
const byteMidiInterface< SerialPort, _Settings >::getSysExArray () const
 Get the System Exclusive byte array. More...
 
unsigned MidiInterface< SerialPort, _Settings >::getSysExArrayLength () const
 Get the lenght of the System Exclusive array. More...
 
bool MidiInterface< SerialPort, _Settings >::check () const
 Check if a valid message is stored in the structure. More...
 
Channel MidiInterface< SerialPort, _Settings >::getInputChannel () const
 
void MidiInterface< SerialPort, _Settings >::setInputChannel (Channel inChannel)
 Set the value for the input MIDI channel. More...
 
static MidiType MidiInterface< SerialPort, _Settings >::getTypeFromStatusByte (byte inStatus)
 Extract an enumerated MIDI type from a status byte. More...
 
static Channel MidiInterface< SerialPort, _Settings >::getChannelFromStatusByte (byte inStatus)
 Returns channel in the range 1-16. More...
 
static bool MidiInterface< SerialPort, _Settings >::isChannelMessage (MidiType inType)
 

Detailed Description

Function Documentation

§ check()

template<class SerialPort , class Settings >
bool MidiInterface< SerialPort, Settings >::check ( ) const
inline

Check if a valid message is stored in the structure.

Definition at line 1064 of file MIDI.hpp.

1065 {
1066  return mMessage.valid;
1067 }
bool valid
Definition: midi_Message.h:90

§ getChannel()

template<class SerialPort , class Settings >
Channel MidiInterface< SerialPort, Settings >::getChannel ( ) const
inline

Get the channel of the message stored in the structure.

Returns
Channel range is 1 to 16. For non-channel messages, this will return 0.

Definition at line 1022 of file MIDI.hpp.

1023 {
1024  return mMessage.channel;
1025 }
Channel channel
Definition: midi_Message.h:62

§ getChannelFromStatusByte()

template<class SerialPort , class Settings >
Channel MidiInterface< SerialPort, Settings >::getChannelFromStatusByte ( byte  inStatus)
inlinestatic

Returns channel in the range 1-16.

Definition at line 1118 of file MIDI.hpp.

1119 {
1120  return (inStatus & 0x0f) + 1;
1121 }

§ getData1()

template<class SerialPort , class Settings >
DataByte MidiInterface< SerialPort, Settings >::getData1 ( ) const
inline

Get the first data byte of the last received message.

Definition at line 1029 of file MIDI.hpp.

1030 {
1031  return mMessage.data1;
1032 }
DataByte data1
Definition: midi_Message.h:72

§ getData2()

template<class SerialPort , class Settings >
DataByte MidiInterface< SerialPort, Settings >::getData2 ( ) const
inline

Get the second data byte of the last received message.

Definition at line 1036 of file MIDI.hpp.

1037 {
1038  return mMessage.data2;
1039 }
DataByte data2
Definition: midi_Message.h:78

§ getInputChannel()

template<class SerialPort , class Settings >
Channel MidiInterface< SerialPort, Settings >::getInputChannel ( ) const
inline

Definition at line 1072 of file MIDI.hpp.

1073 {
1074  return mInputChannel;
1075 }

§ getSysExArray()

template<class SerialPort , class Settings >
const byte * MidiInterface< SerialPort, Settings >::getSysExArray ( ) const
inline

Get the System Exclusive byte array.

See also
getSysExArrayLength to get the array's length in bytes.

Definition at line 1046 of file MIDI.hpp.

1047 {
1048  return mMessage.sysexArray;
1049 }
DataByte sysexArray[sSysExMaxSize]
Definition: midi_Message.h:84

§ getSysExArrayLength()

template<class SerialPort , class Settings >
unsigned MidiInterface< SerialPort, Settings >::getSysExArrayLength ( ) const
inline

Get the lenght of the System Exclusive array.

It is coded using data1 as LSB and data2 as MSB.

Returns
The array's length, in bytes.

Definition at line 1057 of file MIDI.hpp.

1058 {
1059  return mMessage.getSysExSize();
1060 }
unsigned getSysExSize() const
Definition: midi_Message.h:92

§ getType()

template<class SerialPort , class Settings >
MidiType MidiInterface< SerialPort, Settings >::getType ( ) const
inline

Get the last received message's type.

Returns an enumerated type.

See also
MidiType

Definition at line 1011 of file MIDI.hpp.

1012 {
1013  return mMessage.type;
1014 }
MidiType type
Definition: midi_Message.h:67

§ getTypeFromStatusByte()

template<class SerialPort , class Settings >
MidiType MidiInterface< SerialPort, Settings >::getTypeFromStatusByte ( byte  inStatus)
inlinestatic

Extract an enumerated MIDI type from a status byte.

This is a utility static method, used internally, made public so you can handle MidiTypes more easily.

Definition at line 1095 of file MIDI.hpp.

1096 {
1097  if ((inStatus < 0x80) ||
1098  (inStatus == 0xf4) ||
1099  (inStatus == 0xf5) ||
1100  (inStatus == 0xf9) ||
1101  (inStatus == 0xfD))
1102  {
1103  // Data bytes and undefined.
1104  return InvalidType;
1105  }
1106  if (inStatus < 0xf0)
1107  {
1108  // Channel message, remove channel nibble.
1109  return MidiType(inStatus & 0xf0);
1110  }
1111 
1112  return MidiType(inStatus);
1113 }
For notifying errors.
Definition: midi_Defs.h:68
MidiType
Definition: midi_Defs.h:66

§ isChannelMessage()

template<class SerialPort , class Settings >
bool MidiInterface< SerialPort, Settings >::isChannelMessage ( MidiType  inType)
inlinestatic

Definition at line 1124 of file MIDI.hpp.

1125 {
1126  return (inType == NoteOff ||
1127  inType == NoteOn ||
1128  inType == ControlChange ||
1129  inType == AfterTouchPoly ||
1130  inType == AfterTouchChannel ||
1131  inType == PitchBend ||
1132  inType == ProgramChange);
1133 }
Polyphonic AfterTouch.
Definition: midi_Defs.h:71
Channel (monophonic) AfterTouch.
Definition: midi_Defs.h:74
Program Change.
Definition: midi_Defs.h:73
Note On.
Definition: midi_Defs.h:70
Control Change / Channel Mode.
Definition: midi_Defs.h:72
Pitch Bend.
Definition: midi_Defs.h:75
Note Off.
Definition: midi_Defs.h:69

§ read() [1/2]

template<class SerialPort , class Settings >
bool MidiInterface< SerialPort, Settings >::read ( )
inline

Read messages from the serial port using the main input channel.

Returns
True if a valid message has been stored in the structure, false if not. A valid message is a message that matches the input channel.

If the Thru is enabled and the message matches the filter, it is sent back on the MIDI output.
See also
see setInputChannel()

Definition at line 644 of file MIDI.hpp.

645 {
646  return read(mInputChannel);
647 }
bool read()
Read messages from the serial port using the main input channel.
Definition: MIDI.hpp:644

§ read() [2/2]

template<class SerialPort , class Settings >
bool MidiInterface< SerialPort, Settings >::read ( Channel  inChannel)
inline

Read messages on a specified channel.

Definition at line 652 of file MIDI.hpp.

653 {
654  if (inChannel >= MIDI_CHANNEL_OFF)
655  return false; // MIDI Input disabled.
656 
657  if (!parse())
658  return false;
659 
660  handleNullVelocityNoteOnAsNoteOff();
661  const bool channelMatch = inputFilter(inChannel);
662 
663  if (channelMatch)
664  {
665  launchCallback();
666  }
667 
668  thruFilter(inChannel);
669 
670  return channelMatch;
671 }
#define MIDI_CHANNEL_OFF
Definition: midi_Defs.h:50

§ setInputChannel()

template<class SerialPort , class Settings >
void MidiInterface< SerialPort, Settings >::setInputChannel ( Channel  inChannel)
inline

Set the value for the input MIDI channel.

Parameters
inChannelthe channel value. Valid values are 1 to 16, MIDI_CHANNEL_OMNI if you want to listen to all channels, and MIDI_CHANNEL_OFF to disable input.

Definition at line 1082 of file MIDI.hpp.

1083 {
1084  mInputChannel = inChannel;
1085 }