
Originally Posted by
oddson
usbMIDI'S midi-type internal values need to change to the bit-shifted version used in MIDI (with a conditional that shifts user supplied values below 0x80 up to the expected range? )
Ok, this is going to be the painful change. Currently usbMIDI.getType() is documented as returning these (which were the numbers from MIDI 3.2):
Code:
The types are:
0 = Note Off,
1 = Note On,
2 = Velocity Change,
3 = Control Change,
4 = Program Change,
5 = After Touch,
6 = Pitch Bend,
7 = System Exclusive
Looking at MIDI 4.3.1 (the latest version), I see Francois Best now defines these:
Code:
InvalidType = 0x00, ///< For notifying errors
NoteOff = 0x80, ///< Note Off
NoteOn = 0x90, ///< Note On
AfterTouchPoly = 0xA0, ///< Polyphonic AfterTouch
ControlChange = 0xB0, ///< Control Change / Channel Mode
ProgramChange = 0xC0, ///< Program Change
AfterTouchChannel = 0xD0, ///< Channel (monophonic) AfterTouch
PitchBend = 0xE0, ///< Pitch Bend
SystemExclusive = 0xF0, ///< System Exclusive
TimeCodeQuarterFrame = 0xF1, ///< System Common - MIDI Time Code Quarter Frame
SongPosition = 0xF2, ///< System Common - Song Position Pointer
SongSelect = 0xF3, ///< System Common - Song Select
TuneRequest = 0xF6, ///< System Common - Tune Request
Clock = 0xF8, ///< System Real Time - Timing Clock
Start = 0xFA, ///< System Real Time - Start
Continue = 0xFB, ///< System Real Time - Continue
Stop = 0xFC, ///< System Real Time - Stop
ActiveSensing = 0xFE, ///< System Real Time - Active Sensing
SystemReset = 0xFF, ///< System Real Time - System Reset
As far as I can tell, usbMIDI doesn't have any place for users to input these numbers for sending. They're only used for receiving, and only if using the non-callback read approach.
I see MIDI 4.3.1 now has this public function, which does take those codes as its first input.
Code:
void send(MidiType inType,
DataByte inData1,
DataByte inData2,
Channel inChannel);
We need a generic usbMIDI.send() to simplify non functional programming (i.e. passing arbitrary MIDI messages without care of type for functions like MIDI thru).
Will implementing that 4-input send() function meet this need?
There may still be issues with sysex message lengths and support in host
Yes, sysex on USBHost_t36 is pretty much untested. I haven't used it. As far as I know, nobody has (yet). I'd be surprised if it actually works.
usbMIDI isn't handling sysex at all with the read/getType interface, and for the callback it's making callbacks for each tiny chunk.
MIDI 4.3.1 appears to have a 128 byte size limit, but gives a way to create class instances with whatever buffer size you like.
Perhaps what's really needed is to step back to let MIDI handle MIDI as the new library has tried to abstract the midi support from the transport layer. Then the usbMIDI library would (in theory) just need to handle the USB side and pass the midi on as data to the main library.
I'm looking at midi_UsbTransport.h and midi_UsbTransport.hpp. It seems to be designed to use midiEventPacket_t from this MIDIUSB lib. Maybe I should try to implement that API as well?
I have been hoping to take a more active role in development or at least in understanding the libraries suffiencently that I could comment more knowledgeably but life keeps intruding on my hobby time. So far I haven't even loaded the current beta.
Yeah, I certainly know about the lack of time. That's pretty much why Teensyduino had the old MIDI 3.2 for so long, and why I've not managed to update usbMIDI.
I'd really like to update Teensyduino's MIDI support. The main problem is I'm not a musician and I have only a small amount of MIDI gear that I barely know how to use. I'm really depending on feedback from people who actually know and use MIDI.