View Single Post
Old 03-26-2021, 03:27 PM   #7
rdhoore108
Human being with feelings
 
rdhoore108's Avatar
 
Join Date: Mar 2018
Location: Belgium
Posts: 43
Default

Quote:
Originally Posted by mschnell View Post
It will not help when two instances are on the same track.
IMHO the better way is to just count the instances in a gmem varible,
I do this in several projects.
-Michael
Michael, how do you make sure that the first track will write into gmem first, the second as second, etc? I found I cannot count on that to happen, the moment I hit play, I lose all control over what gets processed in what order or timing... Even when initially loading the project from disk, I can't be sure that all tracks and FX's will get initialized in a certain order.

My FX needs the exact track number (not just a unique id) to match with the send that a lua script will have created for each track. But now I just found out that in the same lua script, I can actually set the track number correctly! I'm so pleased. I could even make the slider invisible if I wanted, but I prefer to see it. If one also needs the chain index, one would just need to set fxid + 1 into a slider in the same way.

Code:
local num_tracks = reaper.CountTracks(0)
local i = 0
while (i < num_tracks) do
    local trackid = reaper.GetTrack(0,i)
    local fxid = reaper.TrackFX_AddByName(trackid, "My FX's name", false, 0) -- 0 means only query, never add
    if fxid >= 0 then
        reaper.TrackFX_SetParam(trackid, fxid, 0, i+1) -- 0 means slider1
    end
    i = i + 1
end
rdhoore108 is offline   Reply With Quote