|
|
|
01-24-2017, 10:13 AM
|
#1
|
Human being with feelings
Join Date: Mar 2013
Posts: 217
|
Rename FX instance ?
Hi scripting Gurus !
Does anybody know if there is a way to rename an FX instance with a script ?
Thanks
|
|
|
01-24-2017, 10:16 AM
|
#2
|
Human being with feelings
Join Date: Nov 2014
Posts: 1,900
|
Just right click the fx and choose rename
|
|
|
01-24-2017, 10:40 AM
|
#3
|
Human being with feelings
Join Date: Mar 2013
Posts: 217
|
Thanks, but I already knew about that
I was talking about renaming an FX instance with a script cause I'm building a script that needs to be able to do so
|
|
|
01-24-2017, 10:49 AM
|
#4
|
Human being with feelings
Join Date: Nov 2014
Posts: 1,900
|
ahh makes sense haha. Sometimes the answer is simple. Not this Time!
|
|
|
01-24-2017, 01:13 PM
|
#5
|
Human being with feelings
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
|
Parsing/editing track state chunk.
|
|
|
01-24-2017, 01:31 PM
|
#6
|
Human being with feelings
Join Date: Mar 2013
Posts: 217
|
Thanks mpl, I'm gonna take a look at this, but I'm afraid it's way out of my league
Right now, I'm using a trick : BetterTouchTool takes care of the "renaming" part of the job and the script I'm working on takes it from there. It works like a charm ! But I'd like to share my script with everyone so I must find a work around which uses "script only"...
So now that I've got the right direction, let's get to work
|
|
|
01-24-2017, 11:19 PM
|
#7
|
Human being with feelings
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
|
I`m not good at string parsing but this should works (still very dangerous though)
Code:
function SetFXName(track, fx, new_name)
-- 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
plug_type = reaper.TrackFX_GetIOSize( track, fx )
-- get chunk t
local _, chunk = reaper.GetTrackStateChunk( track, '', false )
local t = {} for line in chunk:gmatch("[^\r\n]+") do t[#t+1] = line end
-- find edit line
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
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
reaper.SetTrackStateChunk( track, table.concat(t,'\n'), false )
reaper.UpdateArrange()
end
-----------------------------------------------------------------------
track = reaper.GetTrack(0,0)
fx_id = 2 -- fx is 0-based
SetFXName(track, fx_id, 'randomFX')
|
|
|
01-25-2017, 03:59 AM
|
#8
|
Human being with feelings
Join Date: Mar 2013
Posts: 217
|
Wah !! Thank you so much mpl, you're the Man !
Gonna try this asap and I'll let you know if it works. Anyway, it's a huge step forward and even if it doesn't work, it will certainly put me in the right direction ! Because I have to admit that my last night experiences were'nt so successful
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 09:02 AM.
|