Old Yesterday, 08:45 PM   #1
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,232
Default set position when adding a take fx?

i have this code for adding, in this case, readelay, to an active take:
Code:
function main() -- local (i, j, item, take, track)
    reaper.Undo_BeginBlock() -- Begining of the undo block. Leave it at the top of your main function.
        local NameFX  = "ReaDelay (Cockos)"
        local ItemSel = reaper.CountSelectedMediaItems( 0 )  -- set variable for number of selected items in current project ( 0 )
        if not ItemSel then no_undo() return end             -- exit if no items selected

        for i = 0, ItemSel - 1 do                            -- loop through selected items
          ItemCurr     = reaper.GetSelectedMediaItem( 0, i ) -- set variable for current item
          TakeCurr     = reaper.GetActiveTake( ItemCurr )    -- set variable for active take
          local fxID   = reaper.TakeFX_AddByName( TakeCurr, NameFX, 0 )
          if fxID <0 then
            fxID       = reaper.TakeFX_AddByName( TakeCurr, NameFX, 1 )
            reaper.TakeFX_Show( TakeCurr, 0, 0 )             -- keeps the fx window hidden
          end
        end
        reaper.Undo_EndBlock("Add ReaDelay by name to selected items", -1) -- End of the undo block. Leave it at the bottom of your main function.
end

reaper.PreventUIRefresh(1)                                  -- Prevent UI refreshing. Uncomment it only if the script works.
main()                                                      -- Execute your main function
reaper.UpdateArrange()                                      -- Update the arrangement
reaper.PreventUIRefresh(-1)                                 -- Restore UI Refresh. Uncomment it only if the script works.
i have copies of this script for several often used reafx. if i run them in succession, each new fx is added to the end of the chain. i believe there's a way with track fx to assign whether the fx is added at the start or end of the chain. how would this code be modded to make, in this case readelay, insert at the start of the chain?

thanks,
babag
babag is offline   Reply With Quote
Old Yesterday, 09:50 PM   #2
carrus2049
Human being with feelings
 
carrus2049's Avatar
 
Join Date: Mar 2023
Location: China
Posts: 22
Default

Hi, you can modify the third arguement for TakeFX_AddByName to add the fx to certain position in the chain, if adding to start of the chain it goes like:
Code:
fxID = reaper.TakeFX_AddByName( TakeCurr, NameFX, -1000 )
For the second or third position it would be -1001 or -1002 and so on.

It's not well-addressed in the API doc, I get it from one post in the forum IIRC though can't find that post right now. Hope someone could hit me with the original post
carrus2049 is offline   Reply With Quote
Old Yesterday, 10:53 PM   #3
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,232
Default

thanks so much carrus2049! both interesting and helpful. never would have figured that out on my own.

thanks again,
babag
babag is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:06 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.