Skip to content

Commit 865118c

Browse files
committed
Initial work begun
1 parent d77c7b1 commit 865118c

2 files changed

Lines changed: 135 additions & 0 deletions

File tree

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
--[[
2+
@description Get name of cue from QLab
3+
@author Ben Smith
4+
@link
5+
Author https://www.bensmithsound.uk
6+
Repository https://github.com/bsmith96/Reaper-Scripts
7+
@version 1.0
8+
@changelog
9+
+ Initial version
10+
@metapackage
11+
@provides
12+
[main] . > bsmith96_{filename}.lua
13+
@about
14+
# Get cue name from QLab
15+
Written by Ben Smith - May 2025
16+
17+
### Info
18+
* Using a custom OSC config, this allows you to get the name of the playhead in QLab.
19+
* This will actually be one cue out and really annoying, but should be a proof of concept.
20+
21+
### Usage
22+
*
23+
24+
### User customisation
25+
*
26+
]]
27+
28+
29+
-- =========================================================
30+
-- =============== USER CUSTOMISATION AREA ===============
31+
-- =========================================================
32+
33+
--------- End of user customisation area --
34+
35+
36+
-- =========================================================
37+
-- ================= GLOBAL VARIABLES ====================
38+
-- =========================================================
39+
40+
local r = reaper
41+
42+
-- get the script's name and directory
43+
local scriptName = ({r.get_action_context()})[2]:match("([^/\\_]+)%.lua$")
44+
local scriptDirectory = ({r.get_action_context()})[2]:sub(1, ({r.get_action_context()})[2]:find("\\[^\\]*$"))
45+
local scriptFolder = scriptDirectory:gsub(scriptName..".lua", "")
46+
47+
48+
package.path = scriptFolder .. '?.lua'
49+
50+
-- Require the osc module
51+
local osc = require('osc')
52+
53+
-- debug
54+
--local msg = osc.get()
55+
--if msg then
56+
-- reaper.ShowMessageBox("OSC address: " .. msg.address .. ", argument: " .. (msg.arg and msg.arg or "(nil)"), "Info", 0)
57+
--else
58+
-- reaper.ShowMessageBox("Invalid or no OSC message", "Error", 0)
59+
--end
60+
61+
62+
-- =========================================================
63+
-- ====================== FUNCTIONS ======================
64+
-- =========================================================
65+
66+
-- =========================================================
67+
-- ====================== UTILITIES ======================
68+
-- =========================================================
69+
70+
-- Deliver messages and add new line in console
71+
function dbg(dbg)
72+
r.ShowConsoleMsg(tostring(dbg) .. "\n")
73+
end
74+
75+
-- Deliver messages using message box
76+
function msg(msg, title)
77+
local title = title or scriptName
78+
r.MB(tostring(msg), title, 0)
79+
end
80+
81+
82+
-- =========================================================
83+
-- =================== MAIN ROUTINE ======================
84+
-- =========================================================
85+
86+
r.Undo_BeginBlock()
87+
88+
-- get OSC message
89+
local msg = osc.get()
90+
91+
-- Create a marker at the current position, with the args of OSC message as the marker name
92+
r.AddProjectMarker(0,0,r.GetPlayPosition(),0,msg.arg,-1)
93+
94+
-- Send OSC message to QLab to request the cue name from cue ID
95+
96+
97+
r.Undo_EndBlock(scriptName, -1)

Miscellaneous/osc.lua

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
-- osc.lua
2+
3+
-- Utility functions to get and parse OSC message and argument from REAPER action context
4+
5+
local osc = {}
6+
7+
function osc.parse(context)
8+
local msg = {}
9+
10+
-- Extract the message
11+
msg.address = context:match("^osc:/([^:[]+)")
12+
13+
if msg.address == nil then
14+
return nil
15+
end
16+
17+
-- Extract float or string value
18+
local value_type, value = context:match(":([fs])=([^%]]+)")
19+
20+
if value_type == "f" then
21+
msg.arg = tonumber(value)
22+
elseif value_type == "s" then
23+
msg.arg = value
24+
end
25+
26+
return msg
27+
end
28+
29+
function osc.get()
30+
local is_new, name, sec, cmd, rel, res, val, ctx = reaper.get_action_context()
31+
if ctx == nil or ctx == '' then
32+
return nil
33+
end
34+
35+
return osc.parse(ctx)
36+
end
37+
38+
return osc

0 commit comments

Comments
 (0)