How fast is the Serial.write() function / Sysex Conversion?

Hey Everyone,

I am making a MIDI to SysEx converter with an arduino board. I am having a bit of trouble with the math of the whole thing. I am convertering CC messages (3 bytes) to a SysEx message (10 bytes).

Now MIDI is 31250 bauds, which is roughly 4kb/second. So how much MIDI CC to SysEx can I convert per second without the Serial output buffer filling up? :confused:

Also since I want to reach the maximum conversion speed available, how long to the Serial.write() functions take? As it stands now my main loop runs at about 20 000 cycles per second, well above the 4000 cycles per second needed for maximum data transfer. However, if I do 10 serial.writes per loop, will it significantly lower the speed of my code?


disclaimer no expert on midi/sysex

a 31250 baud stream generates 3125 bytes per second max. Every 3 bytes is a MIDI msg so in theory you could receive 1042 MIDI msgs/sec. As every MIDI msg generate 1 Sysex msg your output would be 1042x10 bytes is about 10Kbytes/sec so a 115200 baud line should be able to handle it.

does this makes sense ? or even answers your question?

I think that helps. Basically my output can only be a maximum baud of 31250, because I'm making it MIDI compliant. So I just want to know the maximum about of bytes I can send continuously per second without the serial output buffering. Would that be roughly 400 bytes per second maximum?