lathoub / Arduino-USBMIDI

Allows a microcontroller, with native USB capabilities, to appear as a MIDI device over USB to a connected computer
MIT License
148 stars 11 forks source link

Is it possible to change the maximum sysex message length? #9

Open levicole opened 3 years ago

levicole commented 3 years ago

I 've been experimenting with this library along with the FortySevenEffects library. I was attempting to use an Arduino as a USB -> DIN midi interface so I could send DX7 patches from Dexed to a VolcaFM. It seems as if the SysexMaxSize is not customizable in the same way that it is for say serial midi (snippet below).

I'm OK with C, but when it comes to C++ templates and macros, I get completely lost. It seems like it might be possible and my limited knowledge might be keeping me from seeing it.

Custom settings subclass and instantiation for serial midi:

struct MySettings : public midi::DefaultSerialSettings
{
   static const unsigned SysExMaxSize = 1024; // Accept SysEx messages up to 1024 bytes long.
};

MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial1, MIDI_S, MySettings);
levicole commented 3 years ago

I think I might have a solution and will submit a pull request :)

lathoub commented 3 years ago

Check out https://github.com/FortySevenEffects/arduino_midi_library/wiki/Using-custom-Settings for custom settings (This USB transport layer does not touch the SysEx length, this is set in the underlying lib)

levicole commented 3 years ago

Thanks for the response. I think it just wasn't immediately obvious to me how to handle it (due to my lack of understanding of C++ templates). I actually created a macro that is similar to the MIDI_CREATE_CUSTOM_INSTANCE macro that you linked to. I'll submit a PR for it, it won't hurt my feelings if it's not something you'd like to add, but it was definitely helpful for me. :)

lathoub commented 3 years ago

Hi @levicole - thanks, looks good. Would you mind adding an example using the custom settings based on the SysExReceive example?

levicole commented 3 years ago

@lathoub yes! I should have some time to do this today. Work was fairly busy this week!