View Single Post
Old 06-22-2017, 05:28 AM   #1
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,108
Default MIDI editor: Recent versions get unnecessarily bogged down if multiple takes visible

REAPER is renowned for its highly efficient and optimized audio engine. I hope that the same skills will be applied to the MIDI editor.

REAPER gets *unnecessarily* bogged down when multiple takes are visible or editable in the MIDI editor, and it seems to be getting worse and worse in recent versions.

I compared the speeds of versions 5.00 to 5.40, using the following simple script:
Code:
local take = reaper.MIDIEditor_GetTake(reaper.MIDIEditor_GetActive())
local prevTime, currentTime = 0, reaper.time_precise()
local n = 0 -- Count number of cycles
tCycleTimes = {} -- Table to store the time taken for each cycle

local maxCycles = 10

function testDeferSpeed()
    prevTime = currentTime
    currentTime = reaper.time_precise()
    n = n + 1
    tCycleTimes[n] = currentTime - prevTime
    reaper.MIDI_InsertCC(take, true, false, n, 0xB0, 0, 1, 100)
    if n >= maxCycles then
        return 
    else
        reaper.defer(testDeferSpeed)
    end
end

reaper.defer(testDeferSpeed)
The script makes a small MIDI edit to the active take in each defer cycle, and then measures the time between each defer cycle.

Results:

If I only have the active track visible/editable in the MIDI editor, and I run the test script, each defer cycle only takes a few hundredths of a second, as expected.

However, if I make several large takes visible in a single MIDI editor (for example, 15min orchestral tracks with lots of CCs), each defer cycle takes almost 1.5 seconds!

Strangely, this even happens when none of these large takes have any visible MIDI in either the editor or the arrange view. For example, if these takes only start at measure 10, and both the MIDI editor and the arrange view are zoomed in to measures 1-5 (i.e. only the active take overlaps the zoom areas), the defer cycles are still as slow!

The MIDI editor should be optimized so that
* Takes that haven't been changed, should not be re-analyzed, and only mimimal re-drawing of the MIDI data should performed, if any MIDI data is visible in the editor.
* Takes that have no MIDI data visible in the MIDI editor, should not have any effect on the MIDI editor's responsiveness.

And it gets even stranger... Older versions of REAPER are much, much faster: When I tested the same project in versions 5.00 to 5.40, I got the following average times:
v5.00: 0.42s per defer cycle
v5.10: 0.44s
v5.20: 0.61s
v5.30: 0.98s
v5.40: 1.43s

v5.40 is more than three times slower than v5.00!

Last edited by juliansader; 07-23-2017 at 03:44 AM.
juliansader is offline   Reply With Quote