Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function SetFXName(track, fx, new_name)
- -- get re
- if not track or not tonumber(fx) then return end
- reaper.ShowConsoleMsg("\n\nplugin "..fx.."\n")
- reaper.ShowConsoleMsg("new "..new_name.."\n")
- local FX_GUID = reaper.TrackFX_GetFXGUID( track, tonumber(fx) )
- if not FX_GUID then return else FX_GUID = FX_GUID:gsub('-',''):sub(2,-2) end
- reaper.ShowConsoleMsg("FX_GUID "..FX_GUID.."\n")
- 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
- reaper.ShowConsoleMsg("RESULT "..line.."\n")
- 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
- -- if search then reaper.ShowConsoleMsg("found\n") end
- 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
- -- reaper.ShowConsoleMsg("edited_line_id "..edited_line.."\n")
- 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,' ')
- reaper.ShowConsoleMsg(out_line.."\n")
- t[edited_line_id] = '<'..out_line
- reaper.SetTrackStateChunk( track, table.concat(t,'\n'), false )
- reaper.UpdateArrange()
- end
- function cleanup(name)
- newname = name:gsub("_", " ")
- return newname
- end
- function sleep(n)
- if n > 0 then os.execute("ping -n " .. tonumber(n+1) .. " localhost > NUL") end
- end
- reaper.ClearConsole()
- for i = 1,reaper.CountTracks(0),1
- do
- track = reaper.GetTrack(0,i-1)
- for plugin_index = 1,reaper.TrackFX_GetCount(track),1
- do
- retval, fxname = reaper.TrackFX_GetFXName(track, (plugin_index-1), "")
- cleanname = (string.match(cleanup(fxname), ': (.-)%s%('))
- if cleanname or not cleanname == '' then
- SetFXName(track, plugin_index-1, cleanname)
- end
- reaper.ShowConsoleMsg("\n")
- end
- end
- reaper.ShowConsoleMsg("Finished")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement