Skip to content

Instantly share code, notes, and snippets.

@garethnunns
Last active February 27, 2026 23:08
Show Gist options
  • Select an option

  • Save garethnunns/fc8d55c5feaaa66f61cab590e95073db to your computer and use it in GitHub Desktop.

Select an option

Save garethnunns/fc8d55c5feaaa66f61cab590e95073db to your computer and use it in GitHub Desktop.
-- Create Disguise Cue Tables from Reaper v02 [updated 27/02/2026]
-- Once exported they will need renaming to TIMELINENAME_cue_table.txt
-- Options
-- =======
-- whether to create section breaks for each marker:
opt_sections = "1"
-- "0" - does not create section breaks
-- "1" - creates section breaks
-- whether to round the sections to the nearest frame
-- based on the project's frame rate
-- (handy if you want the sections in Disguise to land on whole frames)
opt_round_to_frames = true
-- true - rounds
-- false - doesn't
-- whether it should export with the timecode tag for the first marker
-- based off the Project Start Time
opt_tc_tag = true
-- true - makes the tag
-- false - doesn't
-- Get the current project name
function get_project_name()
local project_path = reaper.GetProjectName(0)
local project_name = project_path:match("(.+)%.RPP$")
return project_name or "UntitledProject"
end
-- Return path to user's Desktop (when file is unsaved)
local function get_desktop_path()
local path = ""
local separator = "/"
-- Check if we are on Windows by looking for the USERPROFILE environment variable
local user_profile = os.getenv("USERPROFILE")
if user_profile then
-- Windows system
separator = "\\"
path = user_profile .. separator .. "Desktop".. separator
else
-- macOS or Linux system
local home = os.getenv("HOME")
if home then
path = home .. separator .. "Desktop".. separator
else
-- Fallback if environment variables are somehow missing
return nil, "Could not determine user home directory."
end
end
return path
end
-- Get the folder path for where the project is stored
function get_project_path()
local proj, project_path = reaper.EnumProjects(-1)
local folder_dir = get_desktop_path()
-- Check if the project has an actual path (it won't if it's unsaved)
if project_path ~= "" then
folder_dir = project_path:match("(.*[/\\])")
end
return folder_dir
end
-- Open the folder based on the OS
local function open_folder(path)
local os_name = reaper.GetOS()
local command = ""
-- Check which OS is running
if os_name:match("Win") then
-- Windows uses 'explorer'
command = 'explorer "' .. path .. '"'
elseif os_name:match("OSX") or os_name:match("macOS") then
-- macOS uses 'open'
command = 'open "' .. path .. '"'
else
-- Linux (REAPER returns "Other") uses 'xdg-open'
command = 'xdg-open "' .. path .. '"'
end
-- Execute the command in the system shell
os.execute(command)
end
-- Export markers to a cue table
function export_markers_to_cue_table()
local project_name = get_project_name()
local date_time_stamp = os.date("%Y%m%d_%H%M%S")
local file_name = project_name .. "_v" .. date_time_stamp .. "_cue_table.txt"
-- where the outputted txt will go, you could replace
local folder_dir = get_project_path()
local file_path = folder_dir .. file_name
-- Open file for writing
local file = io.open(file_path, "w")
if not file then
reaper.ShowConsoleMsg("Could not save to file path: " .. file_path)
return
end
file:write("Cue table for " .. project_name .. " from Reaper on " .. date_time_stamp .. "\n")
file:write("Beat\tTag\tNote\tTrack_Time\tTC_Time\tSection_Break\n")
-- Fetch the frame rate and drop-frame status
local frameRate, dropFrame = reaper.TimeMap_curFrameRate(0)
local num_markers = reaper.CountProjectMarkers(0)
for i = 0, num_markers - 1 do
local retval, is_region, position, _, name, mrknum = reaper.EnumProjectMarkers3(0, i)
if not is_region then
-- beat is just the time in seconds as a decimal
local beat = string.format("%.4f", position)
if opt_round_to_frames then
-- round the beat to whole frames
beat = math.floor((beat * frameRate) + 0.5) / frameRate
end
-- track time
local track_time = reaper.format_timestr_len(position, "", 0.0,5) -- TIMEFMT_HMS format
-- time relative to TC
local tc_time = reaper.format_timestr_pos(position, "", 5) -- TIMEFMT_HMS format
-- sets the first marker as the TC offset
local tag = "\t"
if (i == 0 and position == 0.0 and opt_tc_tag) then
tag = "TC " .. tc_time .. "\t"
end
name = string.format("%02d",mrknum) .. " " .. name
file:write(beat .. "\t" .. tag .. name .. "\t" .. track_time .. " \t " .. tc_time .. "\t" .. opt_sections .. "\n")
end
end
file:close()
reaper.ShowConsoleMsg("Markers exported to " .. file_path .. "\n")
open_folder(folder_dir)
end
-- Export the markers
export_markers_to_cue_table()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment