Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Feature Requests

Reply
 
Thread Tools Display Modes
Old 10-14-2021, 09:54 PM   #1
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default API: 'fx_name' available for TrackFX_SetNamedConfigParm

From this post: https://forum.cockos.com/showpost.ph...60&postcount=4

If I want to set FX name programatically, it still require chunking, because
Code:
reaper.TrackFX_SetNamedConfigParm(track, fx-1, 'fx_name', buf)
doesn`t seems to work.

Example below - Remove FX prefixes on focused FX track.lua:

Code:
  function main()
    retval, tracknumber, itemnumber, fxnumber = reaper.GetFocusedFX2()
    if retval == 0 then return end
    if tracknumber < 0 then return end
    if tracknumber == 0 then track = reaper.GetMasterTrack(0) else track = reaper.GetTrack(0,tracknumber-1)end
    if not track then return end
    for fx = 1,  reaper.TrackFX_GetCount( track ) do
      local retval,  buf = reaper.TrackFX_GetNamedConfigParm(track, fx-1, 'fx_name')
      if buf:match('[%d%a]+%:%s.*') then
        buf = buf:match('[%d%a]+%:%s(.*)')
        --reaper.TrackFX_SetNamedConfigParm(track, fx-1, 'fx_name', buf)
        SetFXName(track, fx-1, buf)
      end 
    end
  end
  
  -----------------------------------------------------------------------
  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 
  -----------------------------------------------------------------------  
  main()
mpl is offline   Reply With Quote
Old 10-15-2021, 10:59 AM   #2
Reflected
Human being with feelings
 
Reflected's Avatar
 
Join Date: Jul 2009
Posts: 3,294
Default

+1 very much!

Got to get rid of those prefixes for vst/js/vsti etc... in the fx-window (waiting for it since 2009)
Reflected is offline   Reply With Quote
Old 10-22-2021, 07:45 AM   #3
Buy One
Human being with feelings
 
Buy One's Avatar
 
Join Date: Sep 2019
Posts: 1,134
Default

Both, API and a built-in option to display those data: plugin type and developer name
__________________
https://github.com/Buy-One/REAPER-scripts (175)
REAPER is a DAW whose user guide file is larger than its installation file
Buy One 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 07:01 PM.


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