Coding style cleanup.

This commit is contained in:
Francois Best 2014-03-06 09:57:19 +01:00
parent 8bd43f496b
commit 8f4d5e85c7
1 changed files with 60 additions and 52 deletions

View File

@ -142,8 +142,8 @@ void MidiInterface<SerialPort>::send(MidiType inType,
if (inType <= PitchBend) // Channel messages
{
// Protection: remove MSBs on data
inData1 &= 0x7F;
inData2 &= 0x7F;
inData1 &= 0x7f;
inData2 &= 0x7f;
const StatusByte status = getStatus(inType, inChannel);
@ -269,7 +269,7 @@ void MidiInterface<SerialPort>::sendPitchBend(int inPitchValue,
Channel inChannel)
{
const unsigned bend = inPitchValue - MIDI_PITCHBEND_MIN;
send(PitchBend, (bend & 0x7F), (bend >> 7) & 0x7F, inChannel);
send(PitchBend, (bend & 0x7f), (bend >> 7) & 0x7f, inChannel);
}
@ -290,7 +290,7 @@ void MidiInterface<SerialPort>::sendPitchBend(double inPitchValue,
/*! \brief Generate and send a System Exclusive frame.
\param inLength The size of the array to send
\param inArray The byte array containing the data to send
\param inArrayContainsBoundaries When set to 'true', 0xF0 & 0xF7 bytes
\param inArrayContainsBoundaries When set to 'true', 0xf0 & 0xf7 bytes
(start & stop SysEx) will NOT be sent
(and therefore must be included in the array).
default value for ArrayContainsBoundaries is set to 'false' for compatibility
@ -303,12 +303,12 @@ void MidiInterface<SerialPort>::sendSysEx(unsigned inLength,
{
if (inArrayContainsBoundaries == false)
{
mSerial.write(0xF0);
mSerial.write(0xf0);
for (unsigned i = 0; i < inLength; ++i)
mSerial.write(inArray[i]);
mSerial.write(0xF7);
mSerial.write(0xf7);
}
else
{
@ -342,7 +342,7 @@ template<class SerialPort>
void MidiInterface<SerialPort>::sendTimeCodeQuarterFrame(DataByte inTypeNibble,
DataByte inValuesNibble)
{
const byte data = ( ((inTypeNibble & 0x07) << 4) | (inValuesNibble & 0x0F) );
const byte data = (((inTypeNibble & 0x07) << 4) | (inValuesNibble & 0x0f));
sendTimeCodeQuarterFrame(data);
}
@ -370,8 +370,8 @@ template<class SerialPort>
void MidiInterface<SerialPort>::sendSongPosition(unsigned inBeats)
{
mSerial.write((byte)SongPosition);
mSerial.write(inBeats & 0x7F);
mSerial.write((inBeats >> 7) & 0x7F);
mSerial.write(inBeats & 0x7f);
mSerial.write((inBeats >> 7) & 0x7f);
#if MIDI_USE_RUNNING_STATUS
mRunningStatus_TX = InvalidType;
@ -383,7 +383,7 @@ template<class SerialPort>
void MidiInterface<SerialPort>::sendSongSelect(DataByte inSongNumber)
{
mSerial.write((byte)SongSelect);
mSerial.write(inSongNumber & 0x7F);
mSerial.write(inSongNumber & 0x7f);
#if MIDI_USE_RUNNING_STATUS
mRunningStatus_TX = InvalidType;
@ -432,7 +432,7 @@ template<class SerialPort>
StatusByte MidiInterface<SerialPort>::getStatus(MidiType inType,
Channel inChannel) const
{
return ((byte)inType | ((inChannel - 1) & 0x0F));
return ((byte)inType | ((inChannel - 1) & 0x0f));
}
#endif // MIDI_BUILD_OUTPUT
@ -537,7 +537,7 @@ bool MidiInterface<SerialPort>::parse()
if (mPendingMessageIndex >= (mPendingMessageExpectedLenght - 1))
{
mMessage.type = getTypeFromStatusByte(mPendingMessage[0]);
mMessage.channel = (mPendingMessage[0] & 0x0F)+1;
mMessage.channel = (mPendingMessage[0] & 0x0f) + 1;
mMessage.data1 = mPendingMessage[1];
// Save data2 only if applicable
@ -661,16 +661,15 @@ bool MidiInterface<SerialPort>::parse()
break;
// End of Exclusive
case 0xF7:
case 0xf7:
if (mMessage.sysexArray[0] == SystemExclusive)
{
// Store the last byte (EOX)
mMessage.sysexArray[mPendingMessageIndex++] = 0xF7;
mMessage.sysexArray[mPendingMessageIndex++] = 0xf7;
mMessage.type = SystemExclusive;
// Get length
mMessage.data1 = mPendingMessageIndex & 0xFF;
mMessage.data1 = mPendingMessageIndex & 0xff;
mMessage.data2 = mPendingMessageIndex >> 8;
mMessage.channel = 0;
mMessage.valid = true;
@ -712,7 +711,7 @@ bool MidiInterface<SerialPort>::parse()
mMessage.type = getTypeFromStatusByte(mPendingMessage[0]);
if (isChannelMessage(mMessage.type))
mMessage.channel = (mPendingMessage[0] & 0x0F)+1;
mMessage.channel = (mPendingMessage[0] & 0x0f) + 1;
else
mMessage.channel = 0;
@ -907,12 +906,21 @@ template<class SerialPort>
MidiType MidiInterface<SerialPort>::getTypeFromStatusByte(byte inStatus)
{
if ((inStatus < 0x80) ||
(inStatus == 0xF4) ||
(inStatus == 0xF5) ||
(inStatus == 0xF9) ||
(inStatus == 0xFD)) return InvalidType; // data bytes and undefined.
if (inStatus < 0xF0) return (MidiType)(inStatus & 0xF0); // Channel message, remove channel nibble.
else return (MidiType)inStatus;
(inStatus == 0xf4) ||
(inStatus == 0xf5) ||
(inStatus == 0xf9) ||
(inStatus == 0xfD))
{
// Data bytes and undefined.
return InvalidType;
}
if (inStatus < 0xf0)
{
// Channel message, remove channel nibble.
return (MidiType)(inStatus & 0xf0);
}
return (MidiType)inStatus;
}
template<class SerialPort>
@ -1010,7 +1018,7 @@ void MidiInterface<SerialPort>::launchCallback()
// Continuous controllers
case ControlChange: if (mControlChangeCallback != 0) mControlChangeCallback(mMessage.channel, mMessage.data1, mMessage.data2); break;
case PitchBend: if (mPitchBendCallback != 0) mPitchBendCallback(mMessage.channel,(int)((mMessage.data1 & 0x7F) | ((mMessage.data2 & 0x7F)<< 7)) + MIDI_PITCHBEND_MIN); break; // TODO: check this
case PitchBend: if (mPitchBendCallback != 0) mPitchBendCallback(mMessage.channel, (int)((mMessage.data1 & 0x7f) | ((mMessage.data2 & 0x7f) << 7)) + MIDI_PITCHBEND_MIN); break; // TODO: check this
case AfterTouchPoly: if (mAfterTouchPolyCallback != 0) mAfterTouchPolyCallback(mMessage.channel, mMessage.data1, mMessage.data2); break;
case AfterTouchChannel: if (mAfterTouchChannelCallback != 0) mAfterTouchChannelCallback(mMessage.channel, mMessage.data1); break;
@ -1019,7 +1027,7 @@ void MidiInterface<SerialPort>::launchCallback()
// Occasional messages
case TimeCodeQuarterFrame: if (mTimeCodeQuarterFrameCallback != 0) mTimeCodeQuarterFrameCallback(mMessage.data1); break;
case SongPosition: if (mSongPositionCallback != 0) mSongPositionCallback((mMessage.data1 & 0x7F) | ((mMessage.data2 & 0x7F)<< 7)); break;
case SongPosition: if (mSongPositionCallback != 0) mSongPositionCallback((mMessage.data1 & 0x7f) | ((mMessage.data2 & 0x7f) << 7)); break;
case SongSelect: if (mSongSelectCallback != 0) mSongSelectCallback(mMessage.data1); break;
case TuneRequest: if (mTuneRequestCallback != 0) mTuneRequestCallback(); break;
@ -1166,7 +1174,7 @@ void MidiInterface<SerialPort>::thruFilter(Channel inChannel)
break;
case SystemExclusive:
// Send SysEx (0xF0 and 0xF7 are included in the buffer)
// Send SysEx (0xf0 and 0xf7 are included in the buffer)
sendSysEx(getSysExArrayLength(), getSysExArray(), true);
break;