Arduino MIDI Library  Version 4.3.1
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 1063 of file MIDI.hpp.

1064 {
1065  return mMessage.valid;
1066 }
bool valid
Definition: midi_Message.h:89

§ 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 1021 of file MIDI.hpp.

1022 {
1023  return mMessage.channel;
1024 }
Channel channel
Definition: midi_Message.h:61

§ getChannelFromStatusByte()

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

Returns channel in the range 1-16.

Definition at line 1117 of file MIDI.hpp.

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

§ 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 1028 of file MIDI.hpp.

1029 {
1030  return mMessage.data1;
1031 }
DataByte data1
Definition: midi_Message.h:71

§ 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 1035 of file MIDI.hpp.

1036 {
1037  return mMessage.data2;
1038 }
DataByte data2
Definition: midi_Message.h:77

§ getInputChannel()

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

Definition at line 1071 of file MIDI.hpp.

1072 {
1073  return mInputChannel;
1074 }

§ 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 1045 of file MIDI.hpp.

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

§ 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 1056 of file MIDI.hpp.

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

§ 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 1010 of file MIDI.hpp.

1011 {
1012  return mMessage.type;
1013 }
MidiType type
Definition: midi_Message.h:66

§ 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 1094 of file MIDI.hpp.

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

§ isChannelMessage()

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

Definition at line 1123 of file MIDI.hpp.

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

§ 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 643 of file MIDI.hpp.

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

§ 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 651 of file MIDI.hpp.

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

§ 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 1081 of file MIDI.hpp.

1082 {
1083  mInputChannel = inChannel;
1084 }