So, I'm running this script that I made "it is part of another script that I'm making" but it is slow to select the MIDI track that it is under the time selection
It is supposed to :
1) Create a MIDI in selected track in Time selection
2) Select the MIDI in time selection ( I made a loop to achieve that, maybe a better way?)
Code:
function CreateMIDIandSelect()
time_sel_start, time_sel_end = reaper.GetSet_LoopTimeRange2( 0, false, false, 0, 0, false ) --get info about time sel
if time_sel_start ~= time_sel_end then --if there is time sel do
sel_track = reaper.GetSelectedTrack( 0, 0 ) -- get selected track
reaper.CreateNewMIDIItemInProj( sel_track, time_sel_start, time_sel_end, false ) -- create a MIDI item
reaper.Main_OnCommandEx(40289, 0 , 0)
itemnumbers= reaper.CountTrackMediaItems( sel_track ) -- LOOP throught ITems in selected track BE CAREFULL TO NOT HAVE OTHER ITEM IN THE SAME POSITION AS THE CREATED MIDI
for i=0,itemnumbers-1 do
item=reaper.GetTrackMediaItem(sel_track,i)
item_pos=reaper.GetMediaItemInfo_Value(item, "D_POSITION")
item_length=reaper.GetMediaItemInfo_Value(item, "D_LENGTH")
if item_pos==time_sel_start and item_pos+item_length==time_sel_end then
reaper.SetMediaItemSelected(item,1)
end
end
end
end
PS: Solved missing UpdateArrange() srry the noob question