Created
October 28, 2017 16:17
-
-
Save x42/5099bbd0a104b4ccc265301bad280172 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ardour { | |
["type"] = "EditorHook", | |
name = "OSC Marker Msg", | |
author = "Ardour Lua Task Force", | |
description = "Send a OSC message when playing through a marker", | |
} | |
function action_params () | |
return | |
{ | |
["uri"] = { title = "OSC URI ", default = "osc.udp://localhost:7890"}, | |
} | |
end | |
function signals () | |
s = LuaSignal.Set() | |
s:add ({ [LuaSignal.LuaTimerDS] = true }) | |
return s | |
end | |
function factory (params) | |
local _posc_last_transport = -1 | |
-- this function is evaluated every 100ms | |
return function (signal, ref, ...) | |
if not Session:transport_rolling() then | |
_posc_last_transport = -1; | |
return | |
end | |
-- helper function to send OSC. | |
function tx_osc (...) | |
local uri = params["unique"] or "osc.udp://localhost:7890" | |
local tx = ARDOUR.LuaOSC.Address (uri) | |
tx:send (...) | |
end | |
local pos = Session:transport_frame () -- current playhead position | |
if (_posc_last_transport < 0) then | |
_posc_last_transport = pos; | |
return | |
end | |
local loc = Session:locations () -- all marker locations | |
local m = loc:first_mark_after (_posc_last_transport, false) | |
if (m == -1) then | |
_posc_last_transport = pos; | |
-- no marker was found | |
return | |
end | |
if m <= pos then | |
--print ("Mark", loc:first_mark_at (m, 0):name ()) | |
tx_osc ('/mark', 'is', m, loc:first_mark_at (m, 0):name ()) | |
_posc_last_transport = m; | |
else | |
_posc_last_transport = pos; | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment