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