From 7bb64074e18eebe9f94921e1db925e13d37ec489 Mon Sep 17 00:00:00 2001 From: lathoub Date: Mon, 9 Mar 2020 09:00:17 +0100 Subject: [PATCH] renamed Encoder -> Transport, added MidiType to beginTransmission in serialMIDI --- src/MIDI.h | 6 +- src/MIDI.hpp | 340 +++++++++++++++++++++++------------------------ src/serialMIDI.h | 2 +- 3 files changed, 174 insertions(+), 174 deletions(-) diff --git a/src/MIDI.h b/src/MIDI.h index 9ae8ca9..5e91f26 100644 --- a/src/MIDI.h +++ b/src/MIDI.h @@ -44,7 +44,7 @@ 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. */ -template +template class MidiInterface { public: @@ -52,7 +52,7 @@ public: typedef _Platform Platform; public: - inline MidiInterface(Encoder&); + inline MidiInterface(Transport&); inline ~MidiInterface(); public: @@ -231,7 +231,7 @@ private: typedef Message MidiMessage; private: - Encoder& mEncoder; + Transport& mTransport; private: Channel mInputChannel; diff --git a/src/MIDI.hpp b/src/MIDI.hpp index 821742f..7f86ec9 100644 --- a/src/MIDI.hpp +++ b/src/MIDI.hpp @@ -30,9 +30,9 @@ BEGIN_MIDI_NAMESPACE /// \brief Constructor for MidiInterface. -template -inline MidiInterface::MidiInterface(Encoder& inEncoder) - : mEncoder(inEncoder) +template +inline MidiInterface::MidiInterface(Transport& inTransport) + : mTransport(inTransport) , mInputChannel(0) , mRunningStatus_RX(InvalidType) , mRunningStatus_TX(InvalidType) @@ -69,8 +69,8 @@ inline MidiInterface::MidiInterface(Encoder& inEnco This is not really useful for the Arduino, as it is never called... */ -template -inline MidiInterface::~MidiInterface() +template +inline MidiInterface::~MidiInterface() { } @@ -82,11 +82,11 @@ inline MidiInterface::~MidiInterface() - Input channel set to 1 if no value is specified - Full thru mirroring */ -template -void MidiInterface::begin(Channel inChannel) +template +void MidiInterface::begin(Channel inChannel) { // Initialise the Serial port - mEncoder.begin(); + mTransport.begin(); mInputChannel = inChannel; mRunningStatus_TX = InvalidType; @@ -130,8 +130,8 @@ void MidiInterface::begin(Channel inChannel) This is an internal method, use it only if you need to send raw data from your code, at your own risks. */ -template -void MidiInterface::send(MidiType inType, +template +void MidiInterface::send(MidiType inType, DataByte inData1, DataByte inData2, Channel inChannel) @@ -152,7 +152,7 @@ void MidiInterface::send(MidiType inType, const StatusByte status = getStatus(inType, inChannel); - if (mEncoder.beginTransmission(inType)) + if (mTransport.beginTransmission(inType)) { if (Settings::UseRunningStatus) { @@ -160,23 +160,23 @@ void MidiInterface::send(MidiType inType, { // New message, memorise and send header mRunningStatus_TX = status; - mEncoder.write(mRunningStatus_TX); + mTransport.write(mRunningStatus_TX); } } else { // Don't care about running status, send the status byte. - mEncoder.write(status); + mTransport.write(status); } // Then send data - mEncoder.write(inData1); + mTransport.write(inData1); if (inType != ProgramChange && inType != AfterTouchChannel) { - mEncoder.write(inData2); + mTransport.write(inData2); } - mEncoder.endTransmission(); + mTransport.endTransmission(); } } else if (inType >= Clock && inType <= SystemReset) @@ -199,8 +199,8 @@ void MidiInterface::send(MidiType inType, Take a look at the values, names and frequencies of notes here: http://www.phys.unsw.edu.au/jw/notes.html */ -template -void MidiInterface::sendNoteOn(DataByte inNoteNumber, +template +void MidiInterface::sendNoteOn(DataByte inNoteNumber, DataByte inVelocity, Channel inChannel) { @@ -218,8 +218,8 @@ void MidiInterface::sendNoteOn(DataByte inNoteNumbe Take a look at the values, names and frequencies of notes here: http://www.phys.unsw.edu.au/jw/notes.html */ -template -void MidiInterface::sendNoteOff(DataByte inNoteNumber, +template +void MidiInterface::sendNoteOff(DataByte inNoteNumber, DataByte inVelocity, Channel inChannel) { @@ -230,8 +230,8 @@ void MidiInterface::sendNoteOff(DataByte inNoteNumb \param inProgramNumber The Program to select (0 to 127). \param inChannel The channel on which the message will be sent (1 to 16). */ -template -void MidiInterface::sendProgramChange(DataByte inProgramNumber, +template +void MidiInterface::sendProgramChange(DataByte inProgramNumber, Channel inChannel) { send(ProgramChange, inProgramNumber, 0, inChannel); @@ -243,8 +243,8 @@ void MidiInterface::sendProgramChange(DataByte inPr \param inChannel The channel on which the message will be sent (1 to 16). @see MidiControlChangeNumber */ -template -void MidiInterface::sendControlChange(DataByte inControlNumber, +template +void MidiInterface::sendControlChange(DataByte inControlNumber, DataByte inControlValue, Channel inChannel) { @@ -258,8 +258,8 @@ void MidiInterface::sendControlChange(DataByte inCo Note: this method is deprecated and will be removed in a future revision of the library, @see sendAfterTouch to send polyphonic and monophonic AfterTouch messages. */ -template -void MidiInterface::sendPolyPressure(DataByte inNoteNumber, +template +void MidiInterface::sendPolyPressure(DataByte inNoteNumber, DataByte inPressure, Channel inChannel) { @@ -270,8 +270,8 @@ void MidiInterface::sendPolyPressure(DataByte inNot \param inPressure The amount of AfterTouch to apply to all notes. \param inChannel The channel on which the message will be sent (1 to 16). */ -template -void MidiInterface::sendAfterTouch(DataByte inPressure, +template +void MidiInterface::sendAfterTouch(DataByte inPressure, Channel inChannel) { send(AfterTouchChannel, inPressure, 0, inChannel); @@ -283,8 +283,8 @@ void MidiInterface::sendAfterTouch(DataByte inPress \param inChannel The channel on which the message will be sent (1 to 16). @see Replaces sendPolyPressure (which is now deprecated). */ -template -void MidiInterface::sendAfterTouch(DataByte inNoteNumber, +template +void MidiInterface::sendAfterTouch(DataByte inNoteNumber, DataByte inPressure, Channel inChannel) { @@ -297,8 +297,8 @@ void MidiInterface::sendAfterTouch(DataByte inNoteN center value is 0. \param inChannel The channel on which the message will be sent (1 to 16). */ -template -void MidiInterface::sendPitchBend(int inPitchValue, +template +void MidiInterface::sendPitchBend(int inPitchValue, Channel inChannel) { const unsigned bend = unsigned(inPitchValue - int(MIDI_PITCHBEND_MIN)); @@ -312,8 +312,8 @@ void MidiInterface::sendPitchBend(int inPitchValue, and +1.0f (max upwards bend), center value is 0.0f. \param inChannel The channel on which the message will be sent (1 to 16). */ -template -void MidiInterface::sendPitchBend(double inPitchValue, +template +void MidiInterface::sendPitchBend(double inPitchValue, Channel inChannel) { const int scale = inPitchValue > 0.0 ? MIDI_PITCHBEND_MAX : MIDI_PITCHBEND_MIN; @@ -330,25 +330,25 @@ void MidiInterface::sendPitchBend(double inPitchVal default value for ArrayContainsBoundaries is set to 'false' for compatibility with previous versions of the library. */ -template -void MidiInterface::sendSysEx(unsigned inLength, +template +void MidiInterface::sendSysEx(unsigned inLength, const byte* inArray, bool inArrayContainsBoundaries) { const bool writeBeginEndBytes = !inArrayContainsBoundaries; - if (mEncoder.beginTransmission(MidiType::SystemExclusiveStart)) + if (mTransport.beginTransmission(MidiType::SystemExclusiveStart)) { if (writeBeginEndBytes) - mEncoder.write(MidiType::SystemExclusiveStart); + mTransport.write(MidiType::SystemExclusiveStart); for (unsigned i = 0; i < inLength; ++i) - mEncoder.write(inArray[i]); + mTransport.write(inArray[i]); if (writeBeginEndBytes) - mEncoder.write(MidiType::SystemExclusiveEnd); + mTransport.write(MidiType::SystemExclusiveEnd); - mEncoder.endTransmission(); + mTransport.endTransmission(); } if (Settings::UseRunningStatus) @@ -360,13 +360,13 @@ void MidiInterface::sendSysEx(unsigned inLength, When a MIDI unit receives this message, it should tune its oscillators (if equipped with any). */ -template -void MidiInterface::sendTuneRequest() +template +void MidiInterface::sendTuneRequest() { - if (mEncoder.beginTransmission(MidiType::TuneRequest)) + if (mTransport.beginTransmission(MidiType::TuneRequest)) { - mEncoder.write(TuneRequest); - mEncoder.endTransmission(); + mTransport.write(TuneRequest); + mTransport.endTransmission(); } if (Settings::UseRunningStatus) @@ -379,8 +379,8 @@ void MidiInterface::sendTuneRequest() \param inValuesNibble MTC data See MIDI Specification for more information. */ -template -void MidiInterface::sendTimeCodeQuarterFrame(DataByte inTypeNibble, +template +void MidiInterface::sendTimeCodeQuarterFrame(DataByte inTypeNibble, DataByte inValuesNibble) { const byte data = byte((((inTypeNibble & 0x07) << 4) | (inValuesNibble & 0x0f))); @@ -393,14 +393,14 @@ void MidiInterface::sendTimeCodeQuarterFrame(DataBy \param inData if you want to encode directly the nibbles in your program, you can send the byte here. */ -template -void MidiInterface::sendTimeCodeQuarterFrame(DataByte inData) +template +void MidiInterface::sendTimeCodeQuarterFrame(DataByte inData) { - if (mEncoder.beginTransmission(MidiType::TimeCodeQuarterFrame)) + if (mTransport.beginTransmission(MidiType::TimeCodeQuarterFrame)) { - mEncoder.write((byte)TimeCodeQuarterFrame); - mEncoder.write(inData); - mEncoder.endTransmission(); + mTransport.write((byte)TimeCodeQuarterFrame); + mTransport.write(inData); + mTransport.endTransmission(); } if (Settings::UseRunningStatus) @@ -410,15 +410,15 @@ void MidiInterface::sendTimeCodeQuarterFrame(DataBy /*! \brief Send a Song Position Pointer message. \param inBeats The number of beats since the start of the song. */ -template -void MidiInterface::sendSongPosition(unsigned inBeats) +template +void MidiInterface::sendSongPosition(unsigned inBeats) { - if (mEncoder.beginTransmission(MidiType::SongPosition)) + if (mTransport.beginTransmission(MidiType::SongPosition)) { - mEncoder.write((byte)SongPosition); - mEncoder.write(inBeats & 0x7f); - mEncoder.write((inBeats >> 7) & 0x7f); - mEncoder.endTransmission(); + mTransport.write((byte)SongPosition); + mTransport.write(inBeats & 0x7f); + mTransport.write((inBeats >> 7) & 0x7f); + mTransport.endTransmission(); } if (Settings::UseRunningStatus) @@ -426,14 +426,14 @@ void MidiInterface::sendSongPosition(unsigned inBea } /*! \brief Send a Song Select message */ -template -void MidiInterface::sendSongSelect(DataByte inSongNumber) +template +void MidiInterface::sendSongSelect(DataByte inSongNumber) { - if (mEncoder.beginTransmission(MidiType::SongSelect)) + if (mTransport.beginTransmission(MidiType::SongSelect)) { - mEncoder.write((byte)MidiType::SongSelect); - mEncoder.write(inSongNumber & 0x7f); - mEncoder.endTransmission(); + mTransport.write((byte)MidiType::SongSelect); + mTransport.write(inSongNumber & 0x7f); + mTransport.endTransmission(); } if (Settings::UseRunningStatus) @@ -446,8 +446,8 @@ void MidiInterface::sendSongSelect(DataByte inSongN Start, Stop, Continue, Clock, ActiveSensing and SystemReset. @see MidiType */ -template -void MidiInterface::sendRealTime(MidiType inType) +template +void MidiInterface::sendRealTime(MidiType inType) { // Do not invalidate Running Status for real-time messages // as they can be interleaved within any message. @@ -460,10 +460,10 @@ void MidiInterface::sendRealTime(MidiType inType) case Continue: case ActiveSensing: case SystemReset: - if (mEncoder.beginTransmission(inType)) + if (mTransport.beginTransmission(inType)) { - mEncoder.write((byte)inType); - mEncoder.endTransmission(); + mTransport.write((byte)inType); + mTransport.endTransmission(); } break; default: @@ -476,8 +476,8 @@ void MidiInterface::sendRealTime(MidiType inType) \param inNumber The 14-bit number of the RPN you want to select. \param inChannel The channel on which the message will be sent (1 to 16). */ -template -inline void MidiInterface::beginRpn(unsigned inNumber, +template +inline void MidiInterface::beginRpn(unsigned inNumber, Channel inChannel) { if (mCurrentRpnNumber != inNumber) @@ -494,8 +494,8 @@ inline void MidiInterface::beginRpn(unsigned inNumb \param inValue The 14-bit value of the selected RPN. \param inChannel The channel on which the message will be sent (1 to 16). */ -template -inline void MidiInterface::sendRpnValue(unsigned inValue, +template +inline void MidiInterface::sendRpnValue(unsigned inValue, Channel inChannel) {; const byte valMsb = 0x7f & (inValue >> 7); @@ -509,8 +509,8 @@ inline void MidiInterface::sendRpnValue(unsigned in \param inLsb The LSB part of the value to send. Meaning depends on RPN number. \param inChannel The channel on which the message will be sent (1 to 16). */ -template -inline void MidiInterface::sendRpnValue(byte inMsb, +template +inline void MidiInterface::sendRpnValue(byte inMsb, byte inLsb, Channel inChannel) { @@ -521,8 +521,8 @@ inline void MidiInterface::sendRpnValue(byte inMsb, /* \brief Increment the value of the currently selected RPN number by the specified amount. \param inAmount The amount to add to the currently selected RPN value. */ -template -inline void MidiInterface::sendRpnIncrement(byte inAmount, +template +inline void MidiInterface::sendRpnIncrement(byte inAmount, Channel inChannel) { sendControlChange(DataIncrement, inAmount, inChannel); @@ -531,8 +531,8 @@ inline void MidiInterface::sendRpnIncrement(byte in /* \brief Decrement the value of the currently selected RPN number by the specified amount. \param inAmount The amount to subtract to the currently selected RPN value. */ -template -inline void MidiInterface::sendRpnDecrement(byte inAmount, +template +inline void MidiInterface::sendRpnDecrement(byte inAmount, Channel inChannel) { sendControlChange(DataDecrement, inAmount, inChannel); @@ -542,8 +542,8 @@ inline void MidiInterface::sendRpnDecrement(byte in This will send a Null Function to deselect the currently selected RPN. \param inChannel The channel on which the message will be sent (1 to 16). */ -template -inline void MidiInterface::endRpn(Channel inChannel) +template +inline void MidiInterface::endRpn(Channel inChannel) { sendControlChange(RPNLSB, 0x7f, inChannel); sendControlChange(RPNMSB, 0x7f, inChannel); @@ -556,8 +556,8 @@ inline void MidiInterface::endRpn(Channel inChannel \param inNumber The 14-bit number of the NRPN you want to select. \param inChannel The channel on which the message will be sent (1 to 16). */ -template -inline void MidiInterface::beginNrpn(unsigned inNumber, +template +inline void MidiInterface::beginNrpn(unsigned inNumber, Channel inChannel) { if (mCurrentNrpnNumber != inNumber) @@ -574,8 +574,8 @@ inline void MidiInterface::beginNrpn(unsigned inNum \param inValue The 14-bit value of the selected NRPN. \param inChannel The channel on which the message will be sent (1 to 16). */ -template -inline void MidiInterface::sendNrpnValue(unsigned inValue, +template +inline void MidiInterface::sendNrpnValue(unsigned inValue, Channel inChannel) {; const byte valMsb = 0x7f & (inValue >> 7); @@ -589,8 +589,8 @@ inline void MidiInterface::sendNrpnValue(unsigned i \param inLsb The LSB part of the value to send. Meaning depends on NRPN number. \param inChannel The channel on which the message will be sent (1 to 16). */ -template -inline void MidiInterface::sendNrpnValue(byte inMsb, +template +inline void MidiInterface::sendNrpnValue(byte inMsb, byte inLsb, Channel inChannel) { @@ -601,8 +601,8 @@ inline void MidiInterface::sendNrpnValue(byte inMsb /* \brief Increment the value of the currently selected NRPN number by the specified amount. \param inAmount The amount to add to the currently selected NRPN value. */ -template -inline void MidiInterface::sendNrpnIncrement(byte inAmount, +template +inline void MidiInterface::sendNrpnIncrement(byte inAmount, Channel inChannel) { sendControlChange(DataIncrement, inAmount, inChannel); @@ -611,8 +611,8 @@ inline void MidiInterface::sendNrpnIncrement(byte i /* \brief Decrement the value of the currently selected NRPN number by the specified amount. \param inAmount The amount to subtract to the currently selected NRPN value. */ -template -inline void MidiInterface::sendNrpnDecrement(byte inAmount, +template +inline void MidiInterface::sendNrpnDecrement(byte inAmount, Channel inChannel) { sendControlChange(DataDecrement, inAmount, inChannel); @@ -622,8 +622,8 @@ inline void MidiInterface::sendNrpnDecrement(byte i This will send a Null Function to deselect the currently selected NRPN. \param inChannel The channel on which the message will be sent (1 to 16). */ -template -inline void MidiInterface::endNrpn(Channel inChannel) +template +inline void MidiInterface::endNrpn(Channel inChannel) { sendControlChange(NRPNLSB, 0x7f, inChannel); sendControlChange(NRPNMSB, 0x7f, inChannel); @@ -634,8 +634,8 @@ inline void MidiInterface::endNrpn(Channel inChanne // ----------------------------------------------------------------------------- -template -StatusByte MidiInterface::getStatus(MidiType inType, +template +StatusByte MidiInterface::getStatus(MidiType inType, Channel inChannel) const { return StatusByte(((byte)inType | ((inChannel - 1) & 0x0f))); @@ -657,16 +657,16 @@ StatusByte MidiInterface::getStatus(MidiType inType it is sent back on the MIDI output. @see see setInputChannel() */ -template -inline bool MidiInterface::read() +template +inline bool MidiInterface::read() { return read(mInputChannel); } /*! \brief Read messages on a specified channel. */ -template -inline bool MidiInterface::read(Channel inChannel) +template +inline bool MidiInterface::read(Channel inChannel) { // Active Sensing. This message is intended to be sent // repeatedly to tell the receiver that a connection is alive. Use @@ -702,10 +702,10 @@ inline bool MidiInterface::read(Channel inChannel) // ----------------------------------------------------------------------------- // Private method: MIDI parser -template -bool MidiInterface::parse() +template +bool MidiInterface::parse() { - if (mEncoder.available() == 0) + if (mTransport.available() == 0) { // No data available. return false; @@ -720,7 +720,7 @@ bool MidiInterface::parse() // Else, add the extracted byte to the pending message, and check validity. // When the message is done, store it. - const byte extracted = mEncoder.read(); + const byte extracted = mTransport.read(); // Ignore Undefined if (extracted == 0xf9 || extracted == 0xfd) @@ -997,8 +997,8 @@ bool MidiInterface::parse() } // Private method, see midi_Settings.h for documentation -template -inline void MidiInterface::handleNullVelocityNoteOnAsNoteOff() +template +inline void MidiInterface::handleNullVelocityNoteOnAsNoteOff() { if (Settings::HandleNullVelocityNoteOnAsNoteOff && getType() == NoteOn && getData2() == 0) @@ -1008,8 +1008,8 @@ inline void MidiInterface::handleNullVelocityNoteOn } // Private method: check if the received message is on the listened channel -template -inline bool MidiInterface::inputFilter(Channel inChannel) +template +inline bool MidiInterface::inputFilter(Channel inChannel) { // This method handles recognition of channel // (to know if the message is destinated to the Arduino) @@ -1037,8 +1037,8 @@ inline bool MidiInterface::inputFilter(Channel inCh } // Private method: reset input attributes -template -inline void MidiInterface::resetInput() +template +inline void MidiInterface::resetInput() { mPendingMessageIndex = 0; mPendingMessageExpectedLenght = 0; @@ -1051,8 +1051,8 @@ inline void MidiInterface::resetInput() Returns an enumerated type. @see MidiType */ -template -inline MidiType MidiInterface::getType() const +template +inline MidiType MidiInterface::getType() const { return mMessage.type; } @@ -1062,22 +1062,22 @@ inline MidiType MidiInterface::getType() const \return Channel range is 1 to 16. For non-channel messages, this will return 0. */ -template -inline Channel MidiInterface::getChannel() const +template +inline Channel MidiInterface::getChannel() const { return mMessage.channel; } /*! \brief Get the first data byte of the last received message. */ -template -inline DataByte MidiInterface::getData1() const +template +inline DataByte MidiInterface::getData1() const { return mMessage.data1; } /*! \brief Get the second data byte of the last received message. */ -template -inline DataByte MidiInterface::getData2() const +template +inline DataByte MidiInterface::getData2() const { return mMessage.data2; } @@ -1086,8 +1086,8 @@ inline DataByte MidiInterface::getData2() const @see getSysExArrayLength to get the array's length in bytes. */ -template -inline const byte* MidiInterface::getSysExArray() const +template +inline const byte* MidiInterface::getSysExArray() const { return mMessage.sysexArray; } @@ -1097,23 +1097,23 @@ inline const byte* MidiInterface::getSysExArray() c It is coded using data1 as LSB and data2 as MSB. \return The array's length, in bytes. */ -template -inline unsigned MidiInterface::getSysExArrayLength() const +template +inline unsigned MidiInterface::getSysExArrayLength() const { return mMessage.getSysExSize(); } /*! \brief Check if a valid message is stored in the structure. */ -template -inline bool MidiInterface::check() const +template +inline bool MidiInterface::check() const { return mMessage.valid; } // ----------------------------------------------------------------------------- -template -inline Channel MidiInterface::getInputChannel() const +template +inline Channel MidiInterface::getInputChannel() const { return mInputChannel; } @@ -1122,8 +1122,8 @@ inline Channel MidiInterface::getInputChannel() con \param inChannel the 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. */ -template -inline void MidiInterface::setInputChannel(Channel inChannel) +template +inline void MidiInterface::setInputChannel(Channel inChannel) { mInputChannel = inChannel; } @@ -1135,8 +1135,8 @@ inline void MidiInterface::setInputChannel(Channel This is a utility static method, used internally, made public so you can handle MidiTypes more easily. */ -template -MidiType MidiInterface::getTypeFromStatusByte(byte inStatus) +template +MidiType MidiInterface::getTypeFromStatusByte(byte inStatus) { if ((inStatus < 0x80) || (inStatus == 0xf4) || @@ -1154,14 +1154,14 @@ MidiType MidiInterface::getTypeFromStatusByte(byte /*! \brief Returns channel in the range 1-16 */ -template -inline Channel MidiInterface::getChannelFromStatusByte(byte inStatus) +template +inline Channel MidiInterface::getChannelFromStatusByte(byte inStatus) { return Channel((inStatus & 0x0f) + 1); } -template -bool MidiInterface::isChannelMessage(MidiType inType) +template +bool MidiInterface::isChannelMessage(MidiType inType) { return (inType == NoteOff || inType == NoteOn || @@ -1178,24 +1178,24 @@ bool MidiInterface::isChannelMessage(MidiType inTyp @{ */ -template void MidiInterface::setHandleNoteOff(void (*fptr)(byte channel, byte note, byte velocity)) { mNoteOffCallback = fptr; } -template void MidiInterface::setHandleNoteOn(void (*fptr)(byte channel, byte note, byte velocity)) { mNoteOnCallback = fptr; } -template void MidiInterface::setHandleAfterTouchPoly(void (*fptr)(byte channel, byte note, byte pressure)) { mAfterTouchPolyCallback = fptr; } -template void MidiInterface::setHandleControlChange(void (*fptr)(byte channel, byte number, byte value)) { mControlChangeCallback = fptr; } -template void MidiInterface::setHandleProgramChange(void (*fptr)(byte channel, byte number)) { mProgramChangeCallback = fptr; } -template void MidiInterface::setHandleAfterTouchChannel(void (*fptr)(byte channel, byte pressure)) { mAfterTouchChannelCallback = fptr; } -template void MidiInterface::setHandlePitchBend(void (*fptr)(byte channel, int bend)) { mPitchBendCallback = fptr; } -template void MidiInterface::setHandleSystemExclusive(void (*fptr)(byte* array, unsigned size)) { mSystemExclusiveCallback = fptr; } -template void MidiInterface::setHandleTimeCodeQuarterFrame(void (*fptr)(byte data)) { mTimeCodeQuarterFrameCallback = fptr; } -template void MidiInterface::setHandleSongPosition(void (*fptr)(unsigned beats)) { mSongPositionCallback = fptr; } -template void MidiInterface::setHandleSongSelect(void (*fptr)(byte songnumber)) { mSongSelectCallback = fptr; } -template void MidiInterface::setHandleTuneRequest(void (*fptr)(void)) { mTuneRequestCallback = fptr; } -template void MidiInterface::setHandleClock(void (*fptr)(void)) { mClockCallback = fptr; } -template void MidiInterface::setHandleStart(void (*fptr)(void)) { mStartCallback = fptr; } -template void MidiInterface::setHandleContinue(void (*fptr)(void)) { mContinueCallback = fptr; } -template void MidiInterface::setHandleStop(void (*fptr)(void)) { mStopCallback = fptr; } -template void MidiInterface::setHandleActiveSensing(void (*fptr)(void)) { mActiveSensingCallback = fptr; } -template void MidiInterface::setHandleSystemReset(void (*fptr)(void)) { mSystemResetCallback = fptr; } +template void MidiInterface::setHandleNoteOff(void (*fptr)(byte channel, byte note, byte velocity)) { mNoteOffCallback = fptr; } +template void MidiInterface::setHandleNoteOn(void (*fptr)(byte channel, byte note, byte velocity)) { mNoteOnCallback = fptr; } +template void MidiInterface::setHandleAfterTouchPoly(void (*fptr)(byte channel, byte note, byte pressure)) { mAfterTouchPolyCallback = fptr; } +template void MidiInterface::setHandleControlChange(void (*fptr)(byte channel, byte number, byte value)) { mControlChangeCallback = fptr; } +template void MidiInterface::setHandleProgramChange(void (*fptr)(byte channel, byte number)) { mProgramChangeCallback = fptr; } +template void MidiInterface::setHandleAfterTouchChannel(void (*fptr)(byte channel, byte pressure)) { mAfterTouchChannelCallback = fptr; } +template void MidiInterface::setHandlePitchBend(void (*fptr)(byte channel, int bend)) { mPitchBendCallback = fptr; } +template void MidiInterface::setHandleSystemExclusive(void (*fptr)(byte* array, unsigned size)) { mSystemExclusiveCallback = fptr; } +template void MidiInterface::setHandleTimeCodeQuarterFrame(void (*fptr)(byte data)) { mTimeCodeQuarterFrameCallback = fptr; } +template void MidiInterface::setHandleSongPosition(void (*fptr)(unsigned beats)) { mSongPositionCallback = fptr; } +template void MidiInterface::setHandleSongSelect(void (*fptr)(byte songnumber)) { mSongSelectCallback = fptr; } +template void MidiInterface::setHandleTuneRequest(void (*fptr)(void)) { mTuneRequestCallback = fptr; } +template void MidiInterface::setHandleClock(void (*fptr)(void)) { mClockCallback = fptr; } +template void MidiInterface::setHandleStart(void (*fptr)(void)) { mStartCallback = fptr; } +template void MidiInterface::setHandleContinue(void (*fptr)(void)) { mContinueCallback = fptr; } +template void MidiInterface::setHandleStop(void (*fptr)(void)) { mStopCallback = fptr; } +template void MidiInterface::setHandleActiveSensing(void (*fptr)(void)) { mActiveSensingCallback = fptr; } +template void MidiInterface::setHandleSystemReset(void (*fptr)(void)) { mSystemResetCallback = fptr; } /*! \brief Detach an external function from the given type. @@ -1203,8 +1203,8 @@ template void MidiInterface -void MidiInterface::disconnectCallbackFromType(MidiType inType) +template +void MidiInterface::disconnectCallbackFromType(MidiType inType) { switch (inType) { @@ -1234,8 +1234,8 @@ void MidiInterface::disconnectCallbackFromType(Midi /*! @} */ // End of doc group MIDI Callbacks // Private - launch callback function based on received type. -template -void MidiInterface::launchCallback() +template +void MidiInterface::launchCallback() { // The order is mixed to allow frequent messages to trigger their callback faster. switch (mMessage.type) @@ -1289,34 +1289,34 @@ void MidiInterface::launchCallback() @see Thru::Mode */ -template -inline void MidiInterface::setThruFilterMode(Thru::Mode inThruFilterMode) +template +inline void MidiInterface::setThruFilterMode(Thru::Mode inThruFilterMode) { mThruFilterMode = inThruFilterMode; mThruActivated = mThruFilterMode != Thru::Off; } -template -inline Thru::Mode MidiInterface::getFilterMode() const +template +inline Thru::Mode MidiInterface::getFilterMode() const { return mThruFilterMode; } -template -inline bool MidiInterface::getThruState() const +template +inline bool MidiInterface::getThruState() const { return mThruActivated; } -template -inline void MidiInterface::turnThruOn(Thru::Mode inThruFilterMode) +template +inline void MidiInterface::turnThruOn(Thru::Mode inThruFilterMode) { mThruActivated = true; mThruFilterMode = inThruFilterMode; } -template -inline void MidiInterface::turnThruOff() +template +inline void MidiInterface::turnThruOff() { mThruActivated = false; mThruFilterMode = Thru::Off; @@ -1330,8 +1330,8 @@ inline void MidiInterface::turnThruOff() // to output unless filter is set to Off. // - Channel messages are passed to the output whether their channel // is matching the input channel and the filter setting -template -void MidiInterface::thruFilter(Channel inChannel) +template +void MidiInterface::thruFilter(Channel inChannel) { // If the feature is disabled, don't do anything. if (!mThruActivated || (mThruFilterMode == Thru::Off)) diff --git a/src/serialMIDI.h b/src/serialMIDI.h index a28f523..42dece5 100644 --- a/src/serialMIDI.h +++ b/src/serialMIDI.h @@ -18,7 +18,7 @@ public: { } - bool beginTransmission() + bool beginTransmission(MidiType) { return true; };