wait there are few more functions, and this is only for ITEM only. Yeah thats the pickle
Code:
function getTrackItems(track)
local items={}
local num_items = reaper.CountTrackMediaItems(track)
for i=1, num_items, 1 do
local item = reaper.GetTrackMediaItem(track, i-1)
local _, it_chunk = reaper.GetItemStateChunk(item, '')
items[#items+1]=it_chunk
end
if #items == 0 then items[1]=EMPTY_TABLE end -- pickle doesn't like empty tables
return setmetatable(items, tcmt)
end
When you call this function it will get you all the all ITEM chunks on track
Code:
items = getTrackItems(track)
Code:
function restoreTrackItems(guid, track_items_table)
local track = reaper.BR_GetMediaTrackByGUID(0,guid)
local num_items = reaper.CountTrackMediaItems(track)
for i = 1, num_items, 1 do
reaper.DeleteTrackMediaItem(track, reaper.GetTrackMediaItem(track,0))
end
for i = 1, #track_items_table, 1 do
local item = reaper.AddMediaItemToTrack(track)
reaper.SetItemStateChunk(item, track_items_table[i], false)
end
reaper.UpdateArrange()
end
This one sets items on your track,you need to specify guid of the track and table where you stored the items