44 template<
class SerialPort,
class _Settings = DefaultSettings>
91 bool inArrayContainsBoundaries =
false);
102 inline void beginRpn(
unsigned inNumber,
148 inline bool check()
const;
185 void launchCallback();
187 void (*mNoteOffCallback)(
byte channel,
byte note,
byte velocity);
188 void (*mNoteOnCallback)(
byte channel,
byte note,
byte velocity);
189 void (*mAfterTouchPolyCallback)(
byte channel,
byte note,
byte velocity);
190 void (*mControlChangeCallback)(
byte channel,
byte,
byte);
191 void (*mProgramChangeCallback)(byte channel,
byte);
192 void (*mAfterTouchChannelCallback)(byte channel,
byte);
193 void (*mPitchBendCallback)(byte channel, int);
194 void (*mSystemExclusiveCallback)(byte * array,
unsigned size);
195 void (*mTimeCodeQuarterFrameCallback)(byte data);
196 void (*mSongPositionCallback)(
unsigned beats);
197 void (*mSongSelectCallback)(byte songnumber);
198 void (*mTuneRequestCallback)(void);
199 void (*mClockCallback)(void);
200 void (*mStartCallback)(void);
201 void (*mContinueCallback)(void);
202 void (*mStopCallback)(void);
203 void (*mActiveSensingCallback)(void);
204 void (*mSystemResetCallback)(void);
218 void thruFilter(byte inChannel);
222 inline void handleNullVelocityNoteOnAsNoteOff();
223 inline bool inputFilter(
Channel inChannel);
224 inline void resetInput();
236 byte mPendingMessage[3];
237 unsigned mPendingMessageExpectedLenght;
238 unsigned mPendingMessageIndex;
239 unsigned mCurrentRpnNumber;
240 unsigned mCurrentNrpnNumber;
241 bool mThruActivated : 1;
243 MidiMessage mMessage;
void setHandleProgramChange(void(*fptr)(byte channel, byte number))
void disconnectCallbackFromType(MidiType inType)
Detach an external function from the given type.
void setHandleNoteOn(void(*fptr)(byte channel, byte note, byte velocity))
void sendSongSelect(DataByte inSongNumber)
Send a Song Select message.
void setThruFilterMode(Thru::Mode inThruFilterMode)
Set the filter for thru mirroring.
void sendSongPosition(unsigned inBeats)
Send a Song Position Pointer message.
void turnThruOn(Thru::Mode inThruFilterMode=Thru::Full)
void beginRpn(unsigned inNumber, Channel inChannel)
Start a Registered Parameter Number frame.
void sendProgramChange(DataByte inProgramNumber, Channel inChannel)
Send a Program Change message.
MidiType getType() const
Get the last received message's type.
DataByte getData2() const
Get the second data byte of the last received message.
MIDI Library for the Arduino - Settings.
#define BEGIN_MIDI_NAMESPACE
Channel getChannel() const
Get the channel of the message stored in the structure.
void setHandleSystemExclusive(void(*fptr)(byte *array, unsigned size))
#define END_MIDI_NAMESPACE
void setHandleSongSelect(void(*fptr)(byte songnumber))
unsigned getSysExArrayLength() const
Get the lenght of the System Exclusive array.
bool read()
Read messages from the serial port using the main input channel.
DataByte getData1() const
Get the first data byte of the last received message.
void setHandleClock(void(*fptr)(void))
void beginNrpn(unsigned inNumber, Channel inChannel)
Start a Non-Registered Parameter Number frame.
void begin(Channel inChannel=1)
Call the begin method in the setup() function of the Arduino.
void sendRealTime(MidiType inType)
Send a Real Time (one byte) message.
static Channel getChannelFromStatusByte(byte inStatus)
Returns channel in the range 1-16.
void setHandleStart(void(*fptr)(void))
void endRpn(Channel inChannel)
Terminate an RPN frame. This will send a Null Function to deselect the currently selected RPN...
void setInputChannel(Channel inChannel)
Set the value for the input MIDI channel.
void setHandleSystemReset(void(*fptr)(void))
bool getThruState() const
Channel getInputChannel() const
void endNrpn(Channel inChannel)
Terminate an NRPN frame. This will send a Null Function to deselect the currently selected NRPN...
enum __attribute__((deprecated)) MidiFilterMode
void sendAfterTouch(DataByte inPressure, Channel inChannel)
Send a MonoPhonic AfterTouch message (applies to all notes)
void sendPolyPressure(DataByte inNoteNumber, DataByte inPressure, Channel inChannel) __attribute__((deprecated))
Send a Polyphonic AfterTouch message (applies to a specified note)
void sendRpnDecrement(byte inAmount, Channel inChannel)
void sendNrpnValue(unsigned inValue, Channel inChannel)
Send a 14-bit value for the currently selected NRPN number.
void sendControlChange(DataByte inControlNumber, DataByte inControlValue, Channel inChannel)
Send a Control Change message.
void sendTimeCodeQuarterFrame(DataByte inTypeNibble, DataByte inValuesNibble)
Send a MIDI Time Code Quarter Frame.
void sendNrpnDecrement(byte inAmount, Channel inChannel)
void setHandleSongPosition(void(*fptr)(unsigned beats))
MIDI Library for the Arduino - Inline implementations.
unsigned encodeSysEx(const byte *inData, byte *outSysEx, unsigned inLenght)
Encode System Exclusive messages. SysEx messages are encoded to guarantee transmission of data bytes ...
Thru::Mode getFilterMode() const
void sendPitchBend(int inPitchValue, Channel inChannel)
Send a Pitch Bend message using a signed integer value.
static MidiType getTypeFromStatusByte(byte inStatus)
Extract an enumerated MIDI type from a status byte.
void setHandleActiveSensing(void(*fptr)(void))
MidiInterface(SerialPort &inSerial)
Constructor for MidiInterface.
MIDI Library for the Arduino - Message struct definition.
static bool isChannelMessage(MidiType inType)
void setHandleTimeCodeQuarterFrame(void(*fptr)(byte data))
void sendTuneRequest()
Send a Tune Request message.
void setHandleContinue(void(*fptr)(void))
void sendNrpnIncrement(byte inAmount, Channel inChannel)
MIDI Library for the Arduino - Definitions.
void sendRpnValue(unsigned inValue, Channel inChannel)
Send a 14-bit value for the currently selected RPN number.
unsigned decodeSysEx(const byte *inSysEx, byte *outData, unsigned inLenght)
Decode System Exclusive messages. SysEx messages are encoded to guarantee transmission of data bytes ...
void send(MidiType inType, DataByte inData1, DataByte inData2, Channel inChannel)
Generate and send a MIDI message from the values given.
void sendSysEx(unsigned inLength, const byte *inArray, bool inArrayContainsBoundaries=false)
Generate and send a System Exclusive frame.
void setHandleNoteOff(void(*fptr)(byte channel, byte note, byte velocity))
bool check() const
Check if a valid message is stored in the structure.
void setHandlePitchBend(void(*fptr)(byte channel, int bend))
void setHandleStop(void(*fptr)(void))
void sendNoteOn(DataByte inNoteNumber, DataByte inVelocity, Channel inChannel)
Send a Note On message.
const byte * getSysExArray() const
Get the System Exclusive byte array.
Fully enabled Thru (every incoming message is sent back).
void setHandleTuneRequest(void(*fptr)(void))
~MidiInterface()
Destructor for MidiInterface.
void setHandleControlChange(void(*fptr)(byte channel, byte number, byte value))
void sendNoteOff(DataByte inNoteNumber, DataByte inVelocity, Channel inChannel)
Send a Note Off message.
The main class for MIDI handling. It is templated over the type of serial port to provide abstraction...
void setHandleAfterTouchChannel(void(*fptr)(byte channel, byte pressure))
void sendRpnIncrement(byte inAmount, Channel inChannel)
void setHandleAfterTouchPoly(void(*fptr)(byte channel, byte note, byte pressure))