CreateNewMIDIItemInProj's docs state that the last parameter
qnIn indicates whether parameters
start and
end are in seconds (qnIn=false) or beats (qnIn=true).
In fact it behaves in a strange manner. The code that follows is supposed to create two items on different tracks:
Code:
reaper.InsertTrackAtIndex(0, false)
reaper.InsertTrackAtIndex(1, false)
t1 = reaper.GetTrack(0, 0)
t2 = reaper.GetTrack(0, 1)
reaper.CreateNewMIDIItemInProj(t1, 0, 7, false)
reaper.CreateNewMIDIItemInProj(t2, 3, 7, true)
The first tracks's item should start at second 3, and end at second 7 beind 4 seconds long.
The second track's item should start at beat 3, and end at beat 7 being 4 beats long.
What actually does this script do? The first item is ok.
The second tracks's item starts at second 3, ends at second 7, beind 4 seconds long!
The difference is that the second item's loop is just 4 beats long!
It is even better visible if we start off second 0, and try to insert 8 beats:
Code:
reaper.CreateNewMIDIItemInProj(t1, 0, 8, false)
reaper.CreateNewMIDIItemInProj(t2, 0, 8, true)
Second item's length is 8 seconds, but the loop mark is right at beat 8.
P.S. The Python version behaves the same way (actually, I run into the bug playing exactly with Python API).
P.P.S. The setting
Loop source for new MIDI items in
REAPER Preferences -> Project -> Media Item Defaults does not affect MIDI items created via Reascript (( They're always looped.
P.P.P.S. REAPER 5.978 on Mac OS Sierra 10.12.6 (16G2016).