MIDI note off near MIDI note on causes audible jitter

I’m working on a standalone software. I’ve noticed that when sending MIDI note on/off messages to external devices, there starts to be annoyingly audible jitter in the note triggering frequency, if the note off/note on messages are too close to each other.

I made a simple test:

Send MIDI note on message 64 times / second directly to midibuffer/mididevice which sends the data to external hardware. If the midi note off message is closer than 200 samples to the next note on message, I start hearing annoying jitter in the sound. I.e. the note roll doesn’t sound mechanically accurate anymore. The jitter becomes really audible and bad sounding.

In other words, I send MIDI note on message every 44100/64 = 689 samples.
I send MIDI note off message 200 samples before the next MIDI note on message will be sent.

The above sounds nice, but reduce that 200 samples to 150 or even 0 and the results sound bad.

I would assume that I could send the note off message 0 samples before the next note on and it should still sound fine but this doesn’t seem to be the case.

I tried recreating the same scenario in Ableton Live to see what happens:
I made an equally fast note roll effect with each note end touching the next note start and everything sounded beautiful using the exact same external MIDI hardware. Of course I have no idea if/how much Ableton Live adds margin to the MIDI note off/on messages it creates.

So what’s causing this effect? Is this a feature which existing DAW software takes into account and hides from the user or is this something specific to JUCE or my own software?

since you said external devices, do devices that use Midi-Over-USB have to use the same baud rate that old school midi devices must use?

I’m not familiar how USB MIDI standard handles things. My signal chain is computer → MIDI I/O box → synthesizer. So there is always USB between things somewhere.

Your MIDI bandwidth between the IO box and the synth is 31.25 kpbs… not super fast. that is one midi message (3 bytes) per millisecond. :slight_smile:

Yep, but that doesn’t explain the effect I’m getting. Especially when Ableton Live does perfect job with the same speed MIDI messages using exact same hardware.

According to my calculations, the MIDI bandwidth should be able to handle much faster data transfer speed without problems. So that can’t be the issue here.

During my testing I also noticed another thing about JUCE MIDI implementation (which isn’t the cause of my originally described problem):

getNextAudioBlock() fills midibuffer with data.
End of this midibuffer goes over the X samples in time of what this getNextAudioBlock() is responsible of processing.
The buffer overlaps with the next getNextAudioBlock()'s midbuffer’s start time.
No overlapping MIDI data though, just the buffer’s end and next one’s start times can overlap.
Now I get jitter again.

This is no big issue though, as it can be easily remedied. Just a heads up on what I noticed how things work. I assume the thread responsible for playing out the midibuffers processes one buffer at a time, instead of trying to handle several of them at once per device.