FastLED 3.9.15
Loading...
Searching...
No Matches
MidiInterface< Transport, _Settings, _Platform > Class Template Reference

Detailed Description

template<class Transport, class _Settings = DefaultSettings, class _Platform = DefaultPlatform>
class MidiInterface< Transport, _Settings, _Platform >

The main class for MIDI handling. It is templated over the type of serial port to provide abstraction from the hardware interface, meaning you can use HardwareSerial, SoftwareSerial or ak47's Uart classes. The only requirement is that the class implements the begin, read, write and available methods.

Definition at line 54 of file MIDI.h.

#include <MIDI.h>

+ Collaboration diagram for MidiInterface< Transport, _Settings, _Platform >:

Public Types

typedef Message< Settings::SysExMaxSize > MidiMessage
 
typedef _Platform Platform
 
typedef _Settings Settings
 

Public Member Functions

 MidiInterface (Transport &)
 Constructor for MidiInterface.
 
 ~MidiInterface ()
 Destructor for MidiInterface.
 
void begin (Channel inChannel=1)
 Call the begin method in the setup() function of the Arduino.
 
void beginNrpn (unsigned inNumber, Channel inChannel)
 Start a Non-Registered Parameter Number frame.
 
void beginRpn (unsigned inNumber, Channel inChannel)
 Start a Registered Parameter Number frame.
 
bool check () const
 Check if a valid message is stored in the structure.
 
void disconnectCallbackFromType (MidiType inType)
 Detach an external function from the given type.
 
void endNrpn (Channel inChannel)
 Terminate an NRPN frame. This will send a Null Function to deselect the currently selected NRPN.
 
void endRpn (Channel inChannel)
 Terminate an RPN frame. This will send a Null Function to deselect the currently selected RPN.
 
Channel getChannel () const
 Get the channel of the message stored in the structure.
 
DataByte getData1 () const
 Get the first data byte of the last received message.
 
DataByte getData2 () const
 Get the second data byte of the last received message.
 
Thru::Mode getFilterMode () const
 
Channel getInputChannel () const
 
const bytegetSysExArray () const
 Get the System Exclusive byte array.
 
unsigned getSysExArrayLength () const
 Get the length of the System Exclusive array.
 
bool getThruState () const
 
Transport * getTransport ()
 
MidiType getType () const
 Get the last received message's type.
 
bool read ()
 Read messages from the serial port using the main input channel.
 
bool read (Channel inChannel)
 Read messages on a specified channel.
 
void send (const MidiMessage &)
 Send a MIDI message.
 
void send (MidiType inType, DataByte inData1, DataByte inData2, Channel inChannel)
 Generate and send a MIDI message from the values given.
 
void sendActiveSensing ()
 
void sendAfterTouch (DataByte inNoteNumber, DataByte inPressure, Channel inChannel)
 Send a Polyphonic AfterTouch message (applies to a specified note)
 
void sendAfterTouch (DataByte inPressure, Channel inChannel)
 Send a MonoPhonic AfterTouch message (applies to all notes)
 
void sendClock ()
 
void sendCommon (MidiType inType, unsigned=0)
 Send a Common message. Common messages reset the running status.
 
void sendContinue ()
 
void sendControlChange (DataByte inControlNumber, DataByte inControlValue, Channel inChannel)
 Send a Control Change message.
 
void sendNoteOff (DataByte inNoteNumber, DataByte inVelocity, Channel inChannel)
 Send a Note Off message.
 
void sendNoteOn (DataByte inNoteNumber, DataByte inVelocity, Channel inChannel)
 Send a Note On message.
 
void sendNrpnDecrement (byte inAmount, Channel inChannel)
 
void sendNrpnIncrement (byte inAmount, Channel inChannel)
 
void sendNrpnValue (byte inMsb, byte inLsb, Channel inChannel)
 Send separate MSB/LSB values for the currently selected NRPN number.
 
void sendNrpnValue (unsigned inValue, Channel inChannel)
 Send a 14-bit value for the currently selected NRPN number.
 
void sendPitchBend (double inPitchValue, Channel inChannel)
 Send a Pitch Bend message using a floating point value.
 
void sendPitchBend (int inPitchValue, Channel inChannel)
 Send a Pitch Bend message using a signed integer value.
 
void sendPolyPressure (DataByte inNoteNumber, DataByte inPressure, Channel inChannel)
 Send a Polyphonic AfterTouch message (applies to a specified note)
 
void sendProgramChange (DataByte inProgramNumber, Channel inChannel)
 Send a Program Change message.
 
void sendRealTime (MidiType inType)
 Send a Real Time (one byte) message.
 
void sendRpnDecrement (byte inAmount, Channel inChannel)
 
void sendRpnIncrement (byte inAmount, Channel inChannel)
 
void sendRpnValue (byte inMsb, byte inLsb, Channel inChannel)
 Send separate MSB/LSB values for the currently selected RPN number.
 
void sendRpnValue (unsigned inValue, Channel inChannel)
 Send a 14-bit value for the currently selected RPN number.
 
void sendSongPosition (unsigned inBeats)
 Send a Song Position Pointer message.
 
void sendSongSelect (DataByte inSongNumber)
 Send a Song Select message.
 
void sendStart ()
 
void sendStop ()
 
void sendSysEx (unsigned inLength, const byte *inArray, bool inArrayContainsBoundaries=false)
 Generate and send a System Exclusive frame.
 
void sendSystemReset ()
 
void sendTick ()
 
void sendTimeCodeQuarterFrame (DataByte inData)
 Send a MIDI Time Code Quarter Frame.
 
void sendTimeCodeQuarterFrame (DataByte inTypeNibble, DataByte inValuesNibble)
 Send a MIDI Time Code Quarter Frame.
 
void sendTuneRequest ()
 Send a Tune Request message.
 
void setHandleActiveSensing (ActiveSensingCallback fptr)
 
void setHandleAfterTouchChannel (AfterTouchChannelCallback fptr)
 
void setHandleAfterTouchPoly (AfterTouchPolyCallback fptr)
 
void setHandleClock (ClockCallback fptr)
 
void setHandleContinue (ContinueCallback fptr)
 
void setHandleControlChange (ControlChangeCallback fptr)
 
void setHandleError (ErrorCallback fptr)
 
void setHandleMessage (void(*fptr)(const MidiMessage &))
 
void setHandleNoteOff (NoteOffCallback fptr)
 
void setHandleNoteOn (NoteOnCallback fptr)
 
void setHandlePitchBend (PitchBendCallback fptr)
 
void setHandleProgramChange (ProgramChangeCallback fptr)
 
void setHandleSongPosition (SongPositionCallback fptr)
 
void setHandleSongSelect (SongSelectCallback fptr)
 
void setHandleStart (StartCallback fptr)
 
void setHandleStop (StopCallback fptr)
 
void setHandleSystemExclusive (SystemExclusiveCallback fptr)
 
void setHandleSystemReset (SystemResetCallback fptr)
 
void setHandleTick (TickCallback fptr)
 
void setHandleTimeCodeQuarterFrame (TimeCodeQuarterFrameCallback fptr)
 
void setHandleTuneRequest (TuneRequestCallback fptr)
 
void setInputChannel (Channel inChannel)
 Set the value for the input MIDI channel.
 
void setThruFilterMode (Thru::Mode inThruFilterMode)
 Set the filter for thru mirroring.
 
void turnThruOff ()
 
void turnThruOn (Thru::Mode inThruFilterMode=Thru::Full)
 

Static Public Member Functions

static Channel getChannelFromStatusByte (byte inStatus)
 Returns channel in the range 1-16.
 
static MidiType getTypeFromStatusByte (byte inStatus)
 Extract an enumerated MIDI type from a status byte.
 
static bool isChannelMessage (MidiType inType)
 

Private Member Functions

StatusByte getStatus (MidiType inType, Channel inChannel) const
 
void handleNullVelocityNoteOnAsNoteOff ()
 
bool inputFilter (Channel inChannel)
 
void launchCallback ()
 
bool parse ()
 
void resetInput ()
 
void thruFilter (byte inChannel)
 
void UpdateLastSentTime ()
 

Private Attributes

ActiveSensingCallback mActiveSensingCallback = nullptr
 
AfterTouchChannelCallback mAfterTouchChannelCallback = nullptr
 
AfterTouchPolyCallback mAfterTouchPolyCallback = nullptr
 
ClockCallback mClockCallback = nullptr
 
ContinueCallback mContinueCallback = nullptr
 
ControlChangeCallback mControlChangeCallback = nullptr
 
unsigned mCurrentNrpnNumber
 
unsigned mCurrentRpnNumber
 
ErrorCallback mErrorCallback = nullptr
 
Channel mInputChannel
 
int8_t mLastError
 
unsigned long mLastMessageReceivedTime
 
unsigned long mLastMessageSentTime
 
MidiMessage mMessage
 
void(* mMessageCallback )(const MidiMessage &message) = nullptr
 
NoteOffCallback mNoteOffCallback = nullptr
 
NoteOnCallback mNoteOnCallback = nullptr
 
byte mPendingMessage [3]
 
unsigned mPendingMessageExpectedLength
 
unsigned mPendingMessageIndex
 
PitchBendCallback mPitchBendCallback = nullptr
 
ProgramChangeCallback mProgramChangeCallback = nullptr
 
bool mReceiverActiveSensingActivated
 
StatusByte mRunningStatus_RX
 
StatusByte mRunningStatus_TX
 
unsigned long mSenderActiveSensingPeriodicity
 
SongPositionCallback mSongPositionCallback = nullptr
 
SongSelectCallback mSongSelectCallback = nullptr
 
StartCallback mStartCallback = nullptr
 
StopCallback mStopCallback = nullptr
 
SystemExclusiveCallback mSystemExclusiveCallback = nullptr
 
SystemResetCallback mSystemResetCallback = nullptr
 
bool mThruActivated: 1
 
Thru::Mode mThruFilterMode: 7
 
TickCallback mTickCallback = nullptr
 
TimeCodeQuarterFrameCallback mTimeCodeQuarterFrameCallback = nullptr
 
Transport & mTransport
 
TuneRequestCallback mTuneRequestCallback = nullptr
 

The documentation for this class was generated from the following files: