unsigned int -> unsigned and trimmed whitespace.
This commit is contained in:
		
							parent
							
								
									601ddb3773
								
							
						
					
					
						commit
						c4d5d76f4a
					
				
							
								
								
									
										12
									
								
								src/MIDI.cpp
								
								
								
								
							
							
						
						
									
										12
									
								
								src/MIDI.cpp
								
								
								
								
							|  | @ -3,7 +3,7 @@ | ||||||
|  *  Project     Arduino MIDI Library |  *  Project     Arduino MIDI Library | ||||||
|  *  @brief      MIDI Library for the Arduino |  *  @brief      MIDI Library for the Arduino | ||||||
|  *  @version    4.0 |  *  @version    4.0 | ||||||
|  *  @author     Francois Best  |  *  @author     Francois Best | ||||||
|  *  @date       24/02/11 |  *  @date       24/02/11 | ||||||
|  *  license     GPL Forty Seven Effects - 2011 |  *  license     GPL Forty Seven Effects - 2011 | ||||||
|  */ |  */ | ||||||
|  | @ -37,7 +37,7 @@ BEGIN_MIDI_NAMESPACE | ||||||
| 
 | 
 | ||||||
| /*! \brief Encode System Exclusive messages.
 | /*! \brief Encode System Exclusive messages.
 | ||||||
|  SysEx messages are encoded to guarantee transmission of data bytes higher than |  SysEx messages are encoded to guarantee transmission of data bytes higher than | ||||||
|  127 without breaking the MIDI protocol. Use this static method to convert the   |  127 without breaking the MIDI protocol. Use this static method to convert the | ||||||
|  data you want to send. |  data you want to send. | ||||||
|  \param inData The data to encode. |  \param inData The data to encode. | ||||||
|  \param outSysEx The output buffer where to store the encoded message. |  \param outSysEx The output buffer where to store the encoded message. | ||||||
|  | @ -59,7 +59,7 @@ unsigned encodeSysEx(const byte* inData, byte* outSysEx, unsigned inLength) | ||||||
| 
 | 
 | ||||||
|         outSysEx[0] |= (msb << count); |         outSysEx[0] |= (msb << count); | ||||||
|         outSysEx[1 + count] = body; |         outSysEx[1 + count] = body; | ||||||
|          | 
 | ||||||
|         if (count++ == 6) |         if (count++ == 6) | ||||||
|         { |         { | ||||||
|             outSysEx   += 8; |             outSysEx   += 8; | ||||||
|  | @ -73,7 +73,7 @@ unsigned encodeSysEx(const byte* inData, byte* outSysEx, unsigned inLength) | ||||||
| 
 | 
 | ||||||
| /*! \brief Decode System Exclusive messages.
 | /*! \brief Decode System Exclusive messages.
 | ||||||
|  SysEx messages are encoded to guarantee transmission of data bytes higher than |  SysEx messages are encoded to guarantee transmission of data bytes higher than | ||||||
|  127 without breaking the MIDI protocol. Use this static method to reassemble  |  127 without breaking the MIDI protocol. Use this static method to reassemble | ||||||
|  your received message. |  your received message. | ||||||
|  \param inSysEx The SysEx data received from MIDI in. |  \param inSysEx The SysEx data received from MIDI in. | ||||||
|  \param outData    The output buffer where to store the decrypted message. |  \param outData    The output buffer where to store the decrypted message. | ||||||
|  | @ -85,13 +85,13 @@ unsigned decodeSysEx(const byte* inSysEx, byte* outData, unsigned inLength) | ||||||
| { | { | ||||||
|     unsigned count  = 0; |     unsigned count  = 0; | ||||||
|     byte msbStorage = 0; |     byte msbStorage = 0; | ||||||
|      | 
 | ||||||
|     for (unsigned i = 0; i < inLength; ++i) |     for (unsigned i = 0; i < inLength; ++i) | ||||||
|     { |     { | ||||||
|         if ((i % 8) == 0) |         if ((i % 8) == 0) | ||||||
|         { |         { | ||||||
|             msbStorage = inSysEx[i]; |             msbStorage = inSysEx[i]; | ||||||
|         }  |         } | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|             outData[count++] = inSysEx[i] | ((msbStorage & 1) << 7); |             outData[count++] = inSysEx[i] | ((msbStorage & 1) << 7); | ||||||
|  |  | ||||||
							
								
								
									
										122
									
								
								src/MIDI.h
								
								
								
								
							
							
						
						
									
										122
									
								
								src/MIDI.h
								
								
								
								
							|  | @ -3,7 +3,7 @@ | ||||||
|  *  Project     Arduino MIDI Library |  *  Project     Arduino MIDI Library | ||||||
|  *  @brief      MIDI Library for the Arduino |  *  @brief      MIDI Library for the Arduino | ||||||
|  *  @version    4.0 |  *  @version    4.0 | ||||||
|  *  @author     Francois Best  |  *  @author     Francois Best | ||||||
|  *  @date       24/02/11 |  *  @date       24/02/11 | ||||||
|  *  license     GPL Forty Seven Effects - 2011 |  *  license     GPL Forty Seven Effects - 2011 | ||||||
|  */ |  */ | ||||||
|  | @ -33,113 +33,113 @@ class MidiInterface | ||||||
| public: | public: | ||||||
|     MidiInterface(SerialPort& inSerial); |     MidiInterface(SerialPort& inSerial); | ||||||
|     ~MidiInterface(); |     ~MidiInterface(); | ||||||
|      | 
 | ||||||
| public: | public: | ||||||
|     void begin(Channel inChannel = 1); |     void begin(Channel inChannel = 1); | ||||||
|      | 
 | ||||||
|     // -------------------------------------------------------------------------
 |     // -------------------------------------------------------------------------
 | ||||||
|     // MIDI Output
 |     // MIDI Output
 | ||||||
|      | 
 | ||||||
| #if MIDI_BUILD_OUTPUT | #if MIDI_BUILD_OUTPUT | ||||||
|      | 
 | ||||||
| public: | public: | ||||||
|     inline void sendNoteOn(DataByte inNoteNumber, |     inline void sendNoteOn(DataByte inNoteNumber, | ||||||
|                            DataByte inVelocity, |                            DataByte inVelocity, | ||||||
|                            Channel inChannel); |                            Channel inChannel); | ||||||
|      | 
 | ||||||
|     inline void sendNoteOff(DataByte inNoteNumber, |     inline void sendNoteOff(DataByte inNoteNumber, | ||||||
|                             DataByte inVelocity, |                             DataByte inVelocity, | ||||||
|                             Channel inChannel); |                             Channel inChannel); | ||||||
|      | 
 | ||||||
|     inline void sendProgramChange(DataByte inProgramNumber, |     inline void sendProgramChange(DataByte inProgramNumber, | ||||||
|                                   Channel inChannel); |                                   Channel inChannel); | ||||||
|      | 
 | ||||||
|     inline void sendControlChange(DataByte inControlNumber, |     inline void sendControlChange(DataByte inControlNumber, | ||||||
|                                   DataByte inControlValue,  |                                   DataByte inControlValue, | ||||||
|                                   Channel inChannel); |                                   Channel inChannel); | ||||||
|      | 
 | ||||||
|     inline void sendPitchBend(int inPitchValue,    Channel inChannel); |     inline void sendPitchBend(int inPitchValue,    Channel inChannel); | ||||||
|     inline void sendPitchBend(double inPitchValue, Channel inChannel); |     inline void sendPitchBend(double inPitchValue, Channel inChannel); | ||||||
|      | 
 | ||||||
|     inline void sendPolyPressure(DataByte inNoteNumber, |     inline void sendPolyPressure(DataByte inNoteNumber, | ||||||
|                                  DataByte inPressure, |                                  DataByte inPressure, | ||||||
|                                  Channel inChannel); |                                  Channel inChannel); | ||||||
|      | 
 | ||||||
|     inline void sendAfterTouch(DataByte inPressure, |     inline void sendAfterTouch(DataByte inPressure, | ||||||
|                                Channel inChannel); |                                Channel inChannel); | ||||||
|      | 
 | ||||||
|     inline void sendSysEx(unsigned int inLength,  |     inline void sendSysEx(unsigned inLength, | ||||||
|                           const byte* inArray, |                           const byte* inArray, | ||||||
|                           bool inArrayContainsBoundaries = false);     |                           bool inArrayContainsBoundaries = false); | ||||||
|      | 
 | ||||||
|     inline void sendTimeCodeQuarterFrame(DataByte inTypeNibble,  |     inline void sendTimeCodeQuarterFrame(DataByte inTypeNibble, | ||||||
|                                          DataByte inValuesNibble); |                                          DataByte inValuesNibble); | ||||||
|     inline void sendTimeCodeQuarterFrame(DataByte inData); |     inline void sendTimeCodeQuarterFrame(DataByte inData); | ||||||
|      | 
 | ||||||
|     inline void sendSongPosition(unsigned int inBeats); |     inline void sendSongPosition(unsigned inBeats); | ||||||
|     inline void sendSongSelect(DataByte inSongNumber); |     inline void sendSongSelect(DataByte inSongNumber); | ||||||
|     inline void sendTuneRequest(); |     inline void sendTuneRequest(); | ||||||
|     inline void sendRealTime(MidiType inType); |     inline void sendRealTime(MidiType inType); | ||||||
|      | 
 | ||||||
| public: | public: | ||||||
|     void send(MidiType inType, |     void send(MidiType inType, | ||||||
|               DataByte inData1, |               DataByte inData1, | ||||||
|               DataByte inData2, |               DataByte inData2, | ||||||
|               Channel inChannel); |               Channel inChannel); | ||||||
|     | 
 | ||||||
| private: | private: | ||||||
|     inline StatusByte getStatus(MidiType inType, |     inline StatusByte getStatus(MidiType inType, | ||||||
|                                 Channel inChannel) const; |                                 Channel inChannel) const; | ||||||
|      | 
 | ||||||
| #endif // MIDI_BUILD_OUTPUT
 | #endif // MIDI_BUILD_OUTPUT
 | ||||||
|      | 
 | ||||||
|      | 
 | ||||||
|     // -------------------------------------------------------------------------
 |     // -------------------------------------------------------------------------
 | ||||||
|     // MIDI Input
 |     // MIDI Input
 | ||||||
|      | 
 | ||||||
| #if MIDI_BUILD_INPUT | #if MIDI_BUILD_INPUT | ||||||
|      | 
 | ||||||
| public: | public: | ||||||
|     bool read(); |     bool read(); | ||||||
|     bool read(Channel inChannel); |     bool read(Channel inChannel); | ||||||
|      | 
 | ||||||
| public: | public: | ||||||
|     inline MidiType getType() const; |     inline MidiType getType() const; | ||||||
|     inline Channel  getChannel() const; |     inline Channel  getChannel() const; | ||||||
|     inline DataByte getData1() const; |     inline DataByte getData1() const; | ||||||
|     inline DataByte getData2() const; |     inline DataByte getData2() const; | ||||||
|     inline const byte* getSysExArray() const; |     inline const byte* getSysExArray() const; | ||||||
|     inline unsigned int getSysExArrayLength() const; |     inline unsigned getSysExArrayLength() const; | ||||||
|     inline bool check() const; |     inline bool check() const; | ||||||
|      | 
 | ||||||
| public: | public: | ||||||
|     inline Channel getInputChannel() const; |     inline Channel getInputChannel() const; | ||||||
|     inline void setInputChannel(Channel inChannel); |     inline void setInputChannel(Channel inChannel); | ||||||
|      | 
 | ||||||
| public: | public: | ||||||
|     static inline MidiType getTypeFromStatusByte(byte inStatus); |     static inline MidiType getTypeFromStatusByte(byte inStatus); | ||||||
| 	static inline bool isChannelMessage(MidiType inType); | 	static inline bool isChannelMessage(MidiType inType); | ||||||
|      | 
 | ||||||
| private: | private: | ||||||
|     bool inputFilter(Channel inChannel); |     bool inputFilter(Channel inChannel); | ||||||
|     bool parse(); |     bool parse(); | ||||||
|     void resetInput(); |     void resetInput(); | ||||||
|      | 
 | ||||||
| private: | private: | ||||||
|     StatusByte mRunningStatus_RX; |     StatusByte mRunningStatus_RX; | ||||||
|     Channel    mInputChannel; |     Channel    mInputChannel; | ||||||
|      | 
 | ||||||
|     byte         mPendingMessage[3];             // SysEx are dumped into mMessage directly.
 |     byte         mPendingMessage[3];             // SysEx are dumped into mMessage directly.
 | ||||||
|     unsigned int mPendingMessageExpectedLenght; |     unsigned mPendingMessageExpectedLenght; | ||||||
|     unsigned int mPendingMessageIndex;           // Extended to unsigned int for larger SysEx payloads.
 |     unsigned mPendingMessageIndex;           // Extended to unsigned for larger SysEx payloads.
 | ||||||
|     Message mMessage; |     Message mMessage; | ||||||
|      | 
 | ||||||
|      | 
 | ||||||
|     // -------------------------------------------------------------------------
 |     // -------------------------------------------------------------------------
 | ||||||
|     // Input Callbacks
 |     // Input Callbacks
 | ||||||
|      | 
 | ||||||
| #if MIDI_USE_CALLBACKS | #if MIDI_USE_CALLBACKS | ||||||
|      | 
 | ||||||
| public: | public: | ||||||
|     inline void setHandleNoteOff(void (*fptr)(byte channel, byte note, byte velocity)); |     inline void setHandleNoteOff(void (*fptr)(byte channel, byte note, byte velocity)); | ||||||
|     inline void setHandleNoteOn(void (*fptr)(byte channel, byte note, byte velocity)); |     inline void setHandleNoteOn(void (*fptr)(byte channel, byte note, byte velocity)); | ||||||
|  | @ -150,7 +150,7 @@ public: | ||||||
|     inline void setHandlePitchBend(void (*fptr)(byte channel, int bend)); |     inline void setHandlePitchBend(void (*fptr)(byte channel, int bend)); | ||||||
|     inline void setHandleSystemExclusive(void (*fptr)(byte * array, byte size)); |     inline void setHandleSystemExclusive(void (*fptr)(byte * array, byte size)); | ||||||
|     inline void setHandleTimeCodeQuarterFrame(void (*fptr)(byte data)); |     inline void setHandleTimeCodeQuarterFrame(void (*fptr)(byte data)); | ||||||
|     inline void setHandleSongPosition(void (*fptr)(unsigned int beats)); |     inline void setHandleSongPosition(void (*fptr)(unsigned beats)); | ||||||
|     inline void setHandleSongSelect(void (*fptr)(byte songnumber)); |     inline void setHandleSongSelect(void (*fptr)(byte songnumber)); | ||||||
|     inline void setHandleTuneRequest(void (*fptr)(void)); |     inline void setHandleTuneRequest(void (*fptr)(void)); | ||||||
|     inline void setHandleClock(void (*fptr)(void)); |     inline void setHandleClock(void (*fptr)(void)); | ||||||
|  | @ -159,13 +159,13 @@ public: | ||||||
|     inline void setHandleStop(void (*fptr)(void)); |     inline void setHandleStop(void (*fptr)(void)); | ||||||
|     inline void setHandleActiveSensing(void (*fptr)(void)); |     inline void setHandleActiveSensing(void (*fptr)(void)); | ||||||
|     inline void setHandleSystemReset(void (*fptr)(void)); |     inline void setHandleSystemReset(void (*fptr)(void)); | ||||||
|      | 
 | ||||||
|     inline void disconnectCallbackFromType(MidiType inType); |     inline void disconnectCallbackFromType(MidiType inType); | ||||||
|      | 
 | ||||||
| private: | private: | ||||||
|      | 
 | ||||||
|     void launchCallback(); |     void launchCallback(); | ||||||
|      | 
 | ||||||
|     void (*mNoteOffCallback)(byte channel, byte note, byte velocity); |     void (*mNoteOffCallback)(byte channel, byte note, byte velocity); | ||||||
|     void (*mNoteOnCallback)(byte channel, byte note, byte velocity); |     void (*mNoteOnCallback)(byte channel, byte note, byte velocity); | ||||||
|     void (*mAfterTouchPolyCallback)(byte channel, byte note, byte velocity); |     void (*mAfterTouchPolyCallback)(byte channel, byte note, byte velocity); | ||||||
|  | @ -175,7 +175,7 @@ private: | ||||||
|     void (*mPitchBendCallback)(byte channel, int); |     void (*mPitchBendCallback)(byte channel, int); | ||||||
|     void (*mSystemExclusiveCallback)(byte * array, byte size); |     void (*mSystemExclusiveCallback)(byte * array, byte size); | ||||||
|     void (*mTimeCodeQuarterFrameCallback)(byte data); |     void (*mTimeCodeQuarterFrameCallback)(byte data); | ||||||
|     void (*mSongPositionCallback)(unsigned int beats); |     void (*mSongPositionCallback)(unsigned beats); | ||||||
|     void (*mSongSelectCallback)(byte songnumber); |     void (*mSongSelectCallback)(byte songnumber); | ||||||
|     void (*mTuneRequestCallback)(void); |     void (*mTuneRequestCallback)(void); | ||||||
|     void (*mClockCallback)(void); |     void (*mClockCallback)(void); | ||||||
|  | @ -184,43 +184,43 @@ private: | ||||||
|     void (*mStopCallback)(void); |     void (*mStopCallback)(void); | ||||||
|     void (*mActiveSensingCallback)(void); |     void (*mActiveSensingCallback)(void); | ||||||
|     void (*mSystemResetCallback)(void); |     void (*mSystemResetCallback)(void); | ||||||
|      | 
 | ||||||
| #endif // MIDI_USE_CALLBACKS    
 | #endif // MIDI_USE_CALLBACKS
 | ||||||
|      | 
 | ||||||
| #endif // MIDI_BUILD_INPUT
 | #endif // MIDI_BUILD_INPUT
 | ||||||
|      | 
 | ||||||
|      | 
 | ||||||
|     // -------------------------------------------------------------------------
 |     // -------------------------------------------------------------------------
 | ||||||
|     // MIDI Soft Thru
 |     // MIDI Soft Thru
 | ||||||
|      | 
 | ||||||
| #if MIDI_BUILD_THRU | #if MIDI_BUILD_THRU | ||||||
|      | 
 | ||||||
| public: | public: | ||||||
|     inline MidiFilterMode getFilterMode() const; |     inline MidiFilterMode getFilterMode() const; | ||||||
|     inline bool getThruState() const; |     inline bool getThruState() const; | ||||||
|      | 
 | ||||||
|     inline void turnThruOn(MidiFilterMode inThruFilterMode = Full); |     inline void turnThruOn(MidiFilterMode inThruFilterMode = Full); | ||||||
|     inline void turnThruOff(); |     inline void turnThruOff(); | ||||||
|     inline void setThruFilterMode(MidiFilterMode inThruFilterMode); |     inline void setThruFilterMode(MidiFilterMode inThruFilterMode); | ||||||
|      | 
 | ||||||
|      | 
 | ||||||
| private: | private: | ||||||
|     void thruFilter(byte inChannel); |     void thruFilter(byte inChannel); | ||||||
|      | 
 | ||||||
| private: | private: | ||||||
|     bool            mThruActivated  : 1; |     bool            mThruActivated  : 1; | ||||||
|     MidiFilterMode  mThruFilterMode : 7; |     MidiFilterMode  mThruFilterMode : 7; | ||||||
|      | 
 | ||||||
| #endif // MIDI_BUILD_THRU
 | #endif // MIDI_BUILD_THRU
 | ||||||
|      | 
 | ||||||
| 
 | 
 | ||||||
| #if MIDI_USE_RUNNING_STATUS | #if MIDI_USE_RUNNING_STATUS | ||||||
|      | 
 | ||||||
| private: | private: | ||||||
|     StatusByte mRunningStatus_TX; |     StatusByte mRunningStatus_TX; | ||||||
|      | 
 | ||||||
| #endif // MIDI_USE_RUNNING_STATUS
 | #endif // MIDI_USE_RUNNING_STATUS
 | ||||||
|      | 
 | ||||||
| private: | private: | ||||||
|     SerialPort& mSerial; |     SerialPort& mSerial; | ||||||
| }; | }; | ||||||
|  |  | ||||||
							
								
								
									
										402
									
								
								src/MIDI.hpp
								
								
								
								
							
							
						
						
									
										402
									
								
								src/MIDI.hpp
								
								
								
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Loading…
	
		Reference in New Issue
	
	 Francois Best
						Francois Best