lathoub / Arduino-AppleMIDI-Library

Send and receive MIDI messages over Ethernet (rtpMIDI or AppleMIDI)
Other
309 stars 66 forks source link

Pitch Bend Reception/Decoding #55

Closed massimofasciano closed 6 years ago

massimofasciano commented 6 years ago

Hi,

It looks like there are 2 issues with the decoding of incoming pitch bend events.

In packet-rtp-midi.h, the following line int pitch = ( octet1 << 7 ) | octet2; should be replaced with int pitch = (( octet2 << 7 ) | octet1) - 8192;

This should correct both issues: 1) the 2 octets (high and low) were reversed (low appears first in the midi stream) 2) the 8192 negative offset was not applied to get a signed int (midi encodes from 0 to 16383 but we expect -8192 to 8191)

With this short fix, it works as expected. Sending pitch bend was already working using a signed int.

Regards, Massimo

lathoub commented 6 years ago

Hi Massimo

Thank you for spotting the pitch bend byte order and offset. Would you mind creating a Pull request, so that the fix is attributed to you (make sure to add your name at the top of the file)

Thanks!

massimofasciano commented 6 years ago

Ok thanks. Will prepare a pull request later today.

massimofasciano commented 6 years ago

Pull request sent... thanks.