[alsa-devel] Range of pitchbend MIDI events

Maurizio Berti maurizio.berti at gmail.com
Thu Aug 25 01:00:14 CEST 2016


[...]
> In both cases, when vkeybd says it's sending a pitch bend value of 8192,
> the resulting data that is actually output on MIDI is -8192, even though
> aseqdump and other MIDI dump programs I tried (kmidimon for one) displayed
> it as 8192. It is very evident when sending to a real world device,
> because as you bend upwards in vkeybd the pitch rises as expected, then
> suddenly jumps to the minimum value when vkeybd reaches 8192.
>
> Conversely, when a real-world device sends a maximum positive MIDI pitch
> bend value, it is displayed as 8191 in aseqdump as would be expected.
>
> I haven't done any further investigation, but it suggests to me that there
> are a couple of bugs here. First of all, that vkeybd attempts to send a
> pitch bend value that is larger than 8191, and secondly that such a large
> value is actually propagated within ALSA.

I just made a new test, thinking about the status byte, I created a pitch
bend event with value 123456789, which has bit length of 27, hence 4 7-bit
bytes.
If I've understood correctly how MIDI works, that should mean that I've
sent a 5 bytes group, being the first the status byte, the first pair the
first pitch bend, and the last a second pitch bend event without the status
byte. That's not the case, I can actually see a pitch bend value of
123456789 on aseqdump.
According to every program I've seen that relates to ALSA but works with an
"external" environment (as you mentioned, physical devices, but also
a2jmidi and others) just gets the first two bytes of the event value.


> But perhaps larger-than-14-bit MIDI pitch bend messages are in fact
> allowed within ALSA, and only truncated once they're transferred over USB
> or MIDI ??? I would find that very odd, as they obviously never can be
> propagated in the real world, but I can't say I know for sure.

I also thought about ALSA being "permissive" with malformed events, but
then I remembered that that range is clearly specified in the alsaseq
documentation:
http://www.alsa-project.org/alsa-doc/alsa-lib/group___seq_middle.html#ga8da40bfd56e00ebec775e5241d86a3e3
One would expect that out of range values should be at least corrected to a
default (maximum?) value or, eventually, raise an exception or return null.
I might be speaking nonsense here, as far as I know ALSA is written in C
and C doesn't have exceptions. But, still.

Now. I already know that this is actually a trivial issue, and, if it's a
real bug, that trivialness might explain why nobody found out about it in
more than 15 years. ;)
It can be still confusing, though, and I think it should be corrected (or,
at least, explained) eventually.

> (BTW, thanks for mentioning vkeybd, I'd never heard of it before, but I've
> been looking for such a lightweight keyboard application for quick tests.
> Special bonus that you can actually play the computer keyboard to generate
> note messages. A bit odd with the Reverb and Chorus menus sending Roland
> sysex messages though...)

You're welcome :) vkeybd is really a tiny yet very useful piece of
software, I use it indeed everytime I need quick tests.
By the way, its developer is Takashi Iwai, which is active here too, so we
should alert him about this thread and ask him about those sysex messages :)

Maurizio

--
È difficile avere una convinzione precisa quando si parla delle ragioni del
cuore. - "Sostiene Pereira", Antonio Tabucchi
http://www.jidesk.net


More information about the Alsa-devel mailing list