Improve MIDI regions drawing performance

I noticed that MIDI tracks takes way much longer to render than audio tracks, as scrolling tracks in the editor is significantly slower when a MIDI track gets displayed.

I my case I have only one MIDI track for drums, everything else is audio so it’s not too bad in the end but I guess people using more MIDI tacks are getting even bigger slowdowns.

If I had to guess, I’d say that each time the editor has to be redrawn, all MIDI notes get redrawn individually. If that’s the case, wouldn’t it be possible to save the rendered track as a texture and reuse that texture as long as the track is not modified and that the zoom factor doesn’t change?

It’s an approach I have thought about. The problem is that each individual MIDI note is editable (along with a potentially huge number of associated CC events), and combining editability with this sort of faster rendering is non-trivial.

Could you switch between the current “full” drawing mode and and pre-rendered one depending on whether the mouse cursor is inside a given MIDI region or not? I don’t do a lot of MIDI editing so I don’t know if there are others ways to edit the notes without having the mouse inside the region.