Hi Paul! I've been putting together an audio project and have incorporated your USB MIDI host, it's working (nearly) perfectly!
I bought a Pyle PMIDIKPD50 which has keys, pads, and encoders. I'm using a "stacked" (4+4=7) hub and am able to receive messages without problem.
I did see one issue though... When multiple MIDI commands are strung together in the same transfer, the 2nd/3rd commands "repeat" in all following single command transfers. Investigating further, I believe this is already on your TODO list...
In midi.cpp, MIDIDevice::rx_data apparently doesn't know the receive length and processes the whole thing. When single commands are sent the remnant of the previous 2nd/3rd processes again. I see the TODO is "use actual received length", which of course id the correct fix. I looked at transfer->length, but it was always 64 (if it were that easy, you would have implemented it) so I hacked in something to zero it out after adding the message to the receive queue...
Code:
void MIDIDevice::rx_data(const Transfer_t *transfer)
{
println("MIDIDevice Receive");
print(" MIDI Data: ");
print_hexbytes(transfer->buffer, rx_size);
uint32_t head = rx_head;
uint32_t tail = rx_tail;
uint32_t len = rx_size >> 2; // TODO: use actual received length
for (uint32_t i=0; i < len; i++) {
uint32_t msg = rx_buffer[i];
if (msg) {
if (++head >= RX_QUEUE_SIZE) head = 0;
rx_queue[head] = msg;
rx_buffer[i]=0; // <----- unknown length work-around 12/3/17 TJS
}
}
<snip>
This fixes the problem with this version, sorry I wasn't able to dive deep enough to implement the correct length TODO.
I have USBHOST_PRINT_DEBUG enabled captures if you like, but I'm sure you get the idea.
Everything else seems to working perfectly, thank you for all your hard work Paul!