Old 01-31-2019, 10:13 AM   #1
kartalex
Human being with feelings
 
Join Date: Dec 2015
Posts: 35
Default Rename effects selected in the chain with lua script - HOW?

Hi, guys!

I need to rename selected fx (multiple fx) in the chain - is there a way?
I know there is TrackFX_GetFXName. Is there something like - TrackFX_SetFxName?

And how to know if the effect is selected in fx chain?
kartalex is offline   Reply With Quote
Old 02-01-2019, 06:58 AM   #2
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,555
Default

Can you change the name in any way? Using the UI of Reaper?
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 02-01-2019, 02:08 PM   #3
kartalex
Human being with feelings
 
Join Date: Dec 2015
Posts: 35
Default

Quote:
Originally Posted by mespotine View Post
Can you change the name in any way? Using the UI of Reaper?
Yes, I can select the effect in the chain, then hit F2 and rename it (or right click and choose "Rename FX Instance"), or it would be better to say - create an alias

So, the right question is - how to create an alias of the effect in the FX chain?

Last edited by kartalex; 02-01-2019 at 02:51 PM.
kartalex is offline   Reply With Quote
Old 08-21-2019, 07:20 PM   #4
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 733
Default

Ran into this as well. Yet Another Example of weird API asymmetry in Reaper.

TrackFX_SetFXName() would be great.
tack is offline   Reply With Quote
Old 08-21-2019, 10:20 PM   #5
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 2,526
Default

Code:
  function SetFXName(track, fx, new_name)
    if not new_name then return end
    local edited_line,edited_line_id, segm
    -- get ref guid
      if not track or not tonumber(fx) then return end
      local FX_GUID = reaper.TrackFX_GetFXGUID( track, fx )
      if not FX_GUID then return else FX_GUID = FX_GUID:gsub('-',''):sub(2,-2) end
      local plug_type = reaper.TrackFX_GetIOSize( track, fx )
    -- get chunk t
      local retval, chunk = reaper.GetTrackStateChunk( track, '', false )
      local t = {} for line in chunk:gmatch("[^\r\n]+") do t[#t+1] = line end
    -- find edit line
      local search
      for i = #t, 1, -1 do
        local t_check = t[i]:gsub('-','')
        if t_check:find(FX_GUID) then search = true  end
        if t[i]:find('<') and search and not t[i]:find('JS_SER') then
          edited_line = t[i]:sub(2)
          edited_line_id = i
          break
        end
      end
    -- parse line
      if not edited_line then return end
      local t1 = {}
      for word in edited_line:gmatch('[%S]+') do t1[#t1+1] = word end
      local t2 = {}
      for i = 1, #t1 do
        segm = t1[i]
        if not q then t2[#t2+1] = segm else t2[#t2] = t2[#t2]..' '..segm end
        if segm:find('"') and not segm:find('""') then if not q then q = true else q = nil end end
      end
  
      if plug_type == 2 then t2[3] = '"'..new_name..'"' end -- if JS
      if plug_type == 3 then t2[5] = '"'..new_name..'"' end -- if VST
  
      local out_line = table.concat(t2,' ')
      t[edited_line_id] = '<'..out_line
      local out_chunk = table.concat(t,'\n')
      --msg(out_chunk)
      reaper.SetTrackStateChunk( track, out_chunk, false )
  end
Quote:
Originally Posted by kartalex View Post
And how to know if the effect is selected in fx chain?
Code:
reaper.CF_EnumSelectedFX(FxChain hwnd, integer index)
__________________
SoundCloud | MPL Scripts discussion | ReaPack | Donate
mpl 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 10:36 AM.


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