arpruss / USBComposite_stm32f1

USB Composite library for STM32F1 (HID, Serial, MIDI and XBox360 controller)
Other
382 stars 76 forks source link

SYSEX support #68

Closed semicontinuity closed 4 years ago

semicontinuity commented 4 years ago

This patch add lightweight support for sending and receiving SYSEX messages.

It does not do any sysex buffering, and simply forwards the message byte-by-byte to the application code: every byte is passed with handleSysExData(b) call, and the end of message is signalled with handleSysExEnd(). The user code is responsible for any processing - it may or may not buffer data, parse the message on the fly, etc.

To send sysex, there are options: either to send individual sysex packets, or to use sendSysexPayload() to transmit data from user-supplied buffer, and frame it with F0/F7 bytes.

arpruss commented 4 years ago

What shoes it so to memory usage when it's not invoked, but other midi functions are used?

semicontinuity commented 4 years ago

No extra RAM is needed for this SYSEX support. If MIDI stream contains sysex packets, corresponding empty callbacks will be called.

arpruss commented 4 years ago

Something's wrong. I tested with my midiserial sketch and got;

C:\Users\USER\AppData\Local\Temp\arduino_build_520897\libraries\usbhid\USBMIDI.cpp.o:(.rodata._ZTV7USBMIDI+0x48): warning: undefined reference to `USBMIDI::handleSysExData(unsigned char)'

C:\Users\USER\AppData\Local\Temp\arduino_build_520897\libraries\usbhid\USBMIDI.cpp.o:(.rodata._ZTV7USBMIDI+0x4c): warning: undefined reference to `USBMIDI::handleSysExEnd()'
semicontinuity commented 4 years ago

Sorry, forgot to add empty handlers (my sketch has sysex handlers, but yours does not - that's why). Fixed.

arpruss commented 4 years ago

Memory test: