Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. -- Get Project Data (v0.04)
  2. -- Edgemeal - Sept, 20, 2019
  3. -- Donate: paypal.me/Edgemeal
  4.  
  5. function GetLastWord(line)
  6. local lastpos = (line:reverse()):find(' ')
  7. return (line:sub(-lastpos+1))
  8. end
  9.  
  10. local function RemoveFileExt(file)
  11. local index = (file:reverse()):find("%.")
  12. if index > 0 then
  13. return string.sub(file, 1, #file-index)
  14. else
  15. return file
  16. end
  17. end
  18.  
  19. function AddFX(track,fx_count)
  20. for fx = 0, fx_count-1 do
  21. local _, fx_name = reaper.TrackFX_GetFXName(track, fx, "")
  22. local _, presetname = reaper.TrackFX_GetPreset(track, fx, "")
  23. local enabled = reaper.TrackFX_GetEnabled(track, fx) -- enabled
  24. if presetname ~= "" then -- add track fx name and preset name
  25. t[#t+1] = (enabled and "" or "* ") .. fx_name .. " Preset: " .. presetname
  26. else
  27. t[#t+1] = (enabled and "" or "* ") .. fx_name
  28. end
  29. end
  30. end
  31.  
  32. function get_line(filename, line_number)
  33. local i = 0
  34. for line in io.lines(filename) do
  35. i = i + 1
  36. if i == line_number then
  37. return line
  38. end
  39. end
  40. return nil -- line not found
  41. end
  42.  
  43. function Main()
  44. local proj, projfn = reaper.EnumProjects(-1, "")
  45. if projfn ~= "" then
  46. t[#t+1]="Project: "..reaper.GetProjectName(proj, "")
  47. t[#t+1]="Path: "..reaper.GetProjectPath("")
  48. local line = get_line(projfn, 1)-- project time stamp, Unix format, last word in 1st line of project file.
  49. local unixTS = (GetLastWord(line))
  50. t[#t+1]='Date: ' ..(os.date("%B %d, %Y %X", tonumber(unixTS))) -- convert to "month day, year time"
  51. else
  52. t[#t+1]="Unknown project (not saved)"
  53. end
  54. t[#t+1]= "" -- empty line
  55.  
  56. -- Master Track
  57. local track = reaper.GetMasterTrack(0)
  58. local fx_count = reaper.TrackFX_GetCount(track)
  59. if fx_count > 0 then
  60. local tn ="Master Track\n" -- add track name
  61. t[#t+1]=tn..string.rep('-', #tn-1)
  62. AddFX(track,fx_count)
  63. t[#t+1]= "" -- empty line
  64. end
  65.  
  66. -- Regular Tracks
  67. local track_count = reaper.CountTracks(0)
  68. for i = 0, track_count-1 do
  69. local track = reaper.GetTrack(0, i)
  70. local _, track_name = reaper.GetTrackName(track)
  71. local tn ='Track '..tostring(i+1)..': '..track_name..'\n' -- add track name
  72. t[#t+1]=tn..string.rep('-', #tn-1)
  73. AddFX(track,reaper.TrackFX_GetCount(track))
  74. t[#t+1]= "" -- empty line
  75. end
  76.  
  77. -- save project data to text file in project folder
  78. if projfn ~= "" then
  79. file = io.open(RemoveFileExt(projfn).." - Project Plugins.txt", "w")
  80. file:write(table.concat(t,"\n"))
  81. file:close()
  82. else
  83. reaper.ShowConsoleMsg(table.concat(t,"\n"))
  84. end
  85. end
  86.  
  87. t = {} -- store proj data
  88. Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement