For programmers: MIDIoUSB problem solved
Posted: 08 Jan 2017, 15:28
This is to report a solution (and a very relieved programmer). It may not be relevant for most readers, but anyway here goes:
I develop my own MIDI software, until recently I only used native MIDI via adaptors, but I’m moving to MIDI over USB. The chat groups are full of posts about problems with MoUSB, particularly when a USB hub is involved, and I encountered one as well. Sometimes I have to send a string of messages to a single device, including Sysex/es, an example is:
Sysex to change the mode of a sound generator
Bank change / program change
Sysex to set a parameter in a sound generator part.
What I found was that some of these message bundles behaved strangely. Sometimes some actions were completely ignored, or actions produced incorrect results. When I switched back to straight MIDI, the problems disappeared.
The nice thing about MIDI is that it’s easy to view the actual packets using a package such as MidiOx. It’s harder with USB, you need specialised software that I don’t have the energy to find, install and learn (although I probably have to make the effort). Anyway, the only easy thing I could think of doing was to add small delays between the message sends using the Win32 Sleep function, so the above example would become:
Sysex to change the mode of a sound generator
Sleep (20) // 20millisecond delay
Bank change / program change
Sleep (20) // 20millisecond delay
Sysex to set a parameter in a sound generator part.
In my case I can do this without latency problems, because there is always a reasonable time between these message bundles, and a delay of a few 10s of milliseconds is of no consequence. They are only used for patch changes and similar events.
Anyway, it worked, the resultant program seems as solid as the native MIDI equivalent. Given the timing around USB, I expect that the Sleep times could probably be reduced significantly.
In the several weeks I’ve been working with USB, this bundled message problem is the only one I’ve come across. The critical real time stuff, ND, NUs and streams of pitch bend messages & the like, seem to work without fail.
I develop my own MIDI software, until recently I only used native MIDI via adaptors, but I’m moving to MIDI over USB. The chat groups are full of posts about problems with MoUSB, particularly when a USB hub is involved, and I encountered one as well. Sometimes I have to send a string of messages to a single device, including Sysex/es, an example is:
Sysex to change the mode of a sound generator
Bank change / program change
Sysex to set a parameter in a sound generator part.
What I found was that some of these message bundles behaved strangely. Sometimes some actions were completely ignored, or actions produced incorrect results. When I switched back to straight MIDI, the problems disappeared.
The nice thing about MIDI is that it’s easy to view the actual packets using a package such as MidiOx. It’s harder with USB, you need specialised software that I don’t have the energy to find, install and learn (although I probably have to make the effort). Anyway, the only easy thing I could think of doing was to add small delays between the message sends using the Win32 Sleep function, so the above example would become:
Sysex to change the mode of a sound generator
Sleep (20) // 20millisecond delay
Bank change / program change
Sleep (20) // 20millisecond delay
Sysex to set a parameter in a sound generator part.
In my case I can do this without latency problems, because there is always a reasonable time between these message bundles, and a delay of a few 10s of milliseconds is of no consequence. They are only used for patch changes and similar events.
Anyway, it worked, the resultant program seems as solid as the native MIDI equivalent. Given the timing around USB, I expect that the Sleep times could probably be reduced significantly.
In the several weeks I’ve been working with USB, this bundled message problem is the only one I’ve come across. The critical real time stuff, ND, NUs and streams of pitch bend messages & the like, seem to work without fail.