diff --git a/Envelopes/tilr_Snapshooter.lua b/Envelopes/tilr_Snapshooter.lua index 6c4b8877a..0219d3c1d 100644 --- a/Envelopes/tilr_Snapshooter.lua +++ b/Envelopes/tilr_Snapshooter.lua @@ -1,12 +1,10 @@ -- @description Snapshooter -- @author tilr --- @version 1.3 +-- @version 1.4 -- @changelog --- Increate number of snapshots to 120 --- Add snapshot pagination --- Fix initial vol/pan/mute write if envelopes have not been created yet --- Write all parameters function --- Last applied snapshot indicator +-- Fix nasty bug where snapshots tracks were identified by userdata. +-- This caused failure to find the tracks on reaper restart. +-- Fixed by using tracks GUID instead. -- @provides -- tilr_Snapshooter/rtk.lua -- [main] tilr_Snapshooter/tilr_Snapshooter apply snap 1.lua @@ -117,11 +115,12 @@ function makesnap() for i = 0, numtracks - 1 do -- vol,send,mute local tr = reaper.GetTrack(0, i) + local guid = reaper.GetTrackGUID(tr) local ret, vol, pan = reaper.GetTrackUIVolPan(tr) local ret, mute = reaper.GetTrackUIMute(tr) - table.insert(entries, { tr, 'Volume', vol }) - table.insert(entries, { tr, 'Pan', pan }) - table.insert(entries, { tr, 'Mute', mute and 1 or 0 }) + table.insert(entries, { guid, 'Volume', vol }) + table.insert(entries, { guid, 'Pan', pan }) + table.insert(entries, { guid, 'Mute', mute and 1 or 0 }) -- sends local sendcount = {} -- aux send counter for send = 0, reaper.GetTrackNumSends(tr, 0) do @@ -131,7 +130,7 @@ function makesnap() local ret, smute = reaper.GetTrackSendUIMute(tr, send) key = tostring(src)..tostring(dst) count = sendcount[key] and sendcount[key] + 1 or 1 - table.insert(entries, { tr, 'Send', count, key, svol, span, smute and 1 or 0 }) + table.insert(entries, { guid, 'Send', count, key, svol, span, smute and 1 or 0 }) sendcount[key] = count end -- fx params @@ -141,7 +140,7 @@ function makesnap() paramcount = reaper.TrackFX_GetNumParams(tr, j) for k = 0, paramcount - 1 do param = reaper.TrackFX_GetParam(tr, j, k) - table.insert(entries, { tr, fxid , k, param }) + table.insert(entries, { guid, fxid , k, param }) end end end @@ -238,7 +237,7 @@ function applydiff(diff, write, tween) -- tracks hashmap local tracks = {} for i = 0, numtracks - 1 do - tracks[tostring(reaper.GetTrack(0, i))] = i + tracks[reaper.GetTrackGUID(reaper.GetTrack(0, i))] = i end -- fxs hashmap local fxs = {} @@ -266,7 +265,7 @@ function applydiff(diff, write, tween) -- apply diff lines for i,line in ipairs(diff) do - tr = tracks[tostring(line[1])] + tr = tracks[line[1]] if tr ~= nil then local track = reaper.GetTrack(0, tr) if not globals.ui_checkbox_seltracks or reaper.IsTrackSelected(track) then @@ -394,7 +393,7 @@ function clearEnvelopesAndAddStartingPoint(diff, starttime, endtime) local tracks = {} local numtracks = reaper.GetNumTracks() for i = 0, numtracks - 1 do - tracks[tostring(reaper.GetTrack(0, i))] = i + tracks[reaper.GetTrackGUID(reaper.GetTrack(0, i))] = i end -- fxs hashmap local fxs = {} @@ -407,7 +406,7 @@ function clearEnvelopesAndAddStartingPoint(diff, starttime, endtime) end for i,line in ipairs(diff) do - local track = tracks[tostring(line[1])] + local track = tracks[line[1]] if track ~= null then track = reaper.GetTrack(0, track) local env_count = reaper.CountTrackEnvelopes(track)