Skip to content

Commit

Permalink
Release Snapshooter v1.4 (#1467)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tiagolr authored Dec 2, 2024
1 parent e8b4fcc commit cfb453f
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions Envelopes/tilr_Snapshooter.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 = {}
Expand All @@ -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)
Expand Down

0 comments on commit cfb453f

Please sign in to comment.