Hi,
I have been using the USB MIDI library, with some success. Recently, however, I have been trying to add support for midi clock and transport messages, like this: -
// create messages
/** Create a Clock message
* @returns A MIDIMessage
*/
static MIDIMessage Clock() {
MIDIMessage msg;
msg.data[0] = 0xF8;
return msg;
}
/** Create a Clock message
* @returns A MIDIMessage
*/
static MIDIMessage Start() {
MIDIMessage msg;
msg.data[0] = 0xFA;
return msg;
}
/** Create a Clock message
* @returns A MIDIMessage
*/
static MIDIMessage Continue() {
MIDIMessage msg;
msg.data[0] = 0xFB;
return msg;
}
/** Create a Clock message
* @returns A MIDIMessage
*/
static MIDIMessage Stop() {
MIDIMessage msg;
msg.data[0] = 0xFC;
return msg;
}
and: -
/** MIDI Message Types */
enum MIDIMessageType {
ErrorType,
NoteOffType,
NoteOnType,
PolyphonicAftertouchType,
ControlChangeType,
ProgramChangeType,
ChannelAftertouchType,
PitchWheelType,
AllNotesOffType,
ClockType,
StartType,
ContinueType,
StopType
};
/** Read the message type
* @returns MIDIMessageType
*/
MIDIMessageType type() {
switch (data[1]) {
case 0xF8:
return ClockType;
case 0xFA:
return StartType;
case 0xFB:
return ContinueType;
case 0xFC:
return StopType;
default:
switch((data[1] >> 4) & 0xF) {
case 0x8:
return NoteOffType;
case 0x9:
return NoteOnType;
case 0xA:
return PolyphonicAftertouchType;
case 0xB:
if(controller() < 120) { // standard controllers
return ControlChangeType;
} else if(controller() == 123) {
return AllNotesOffType;
} else {
return ErrorType; // unsupported atm
}
case 0xC:
return ProgramChangeType;
case 0xD:
return ChannelAftertouchType;
case 0xE:
return PitchWheelType;
default:
return ErrorType;
}
}
}
The above code, added to the MIDIMessage.h file does not work as I expected and I wondered if someone might be able to shed some light on the problem.
Many Thanks,
James Spadavecchia
Hi, I have been using the USB MIDI library, with some success. Recently, however, I have been trying to add support for midi clock and transport messages, like this: -
// create messages /** Create a Clock message * @returns A MIDIMessage */ static MIDIMessage Clock() { MIDIMessage msg; msg.data[0] = 0xF8; return msg; } /** Create a Clock message * @returns A MIDIMessage */ static MIDIMessage Start() { MIDIMessage msg; msg.data[0] = 0xFA; return msg; } /** Create a Clock message * @returns A MIDIMessage */ static MIDIMessage Continue() { MIDIMessage msg; msg.data[0] = 0xFB; return msg; } /** Create a Clock message * @returns A MIDIMessage */ static MIDIMessage Stop() { MIDIMessage msg; msg.data[0] = 0xFC; return msg; }and: -
/** MIDI Message Types */ enum MIDIMessageType { ErrorType, NoteOffType, NoteOnType, PolyphonicAftertouchType, ControlChangeType, ProgramChangeType, ChannelAftertouchType, PitchWheelType, AllNotesOffType, ClockType, StartType, ContinueType, StopType }; /** Read the message type * @returns MIDIMessageType */ MIDIMessageType type() { switch (data[1]) { case 0xF8: return ClockType; case 0xFA: return StartType; case 0xFB: return ContinueType; case 0xFC: return StopType; default: switch((data[1] >> 4) & 0xF) { case 0x8: return NoteOffType; case 0x9: return NoteOnType; case 0xA: return PolyphonicAftertouchType; case 0xB: if(controller() < 120) { // standard controllers return ControlChangeType; } else if(controller() == 123) { return AllNotesOffType; } else { return ErrorType; // unsupported atm } case 0xC: return ProgramChangeType; case 0xD: return ChannelAftertouchType; case 0xE: return PitchWheelType; default: return ErrorType; } } }The above code, added to the MIDIMessage.h file does not work as I expected and I wondered if someone might be able to shed some light on the problem.
Many Thanks, James Spadavecchia