summaryrefslogtreecommitdiff
path: root/scripts/_varispeed_callback.lua
blob: c61a15d897fcbc71dc030e119d7ea3e311e15ade (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
ardour {
	["type"]    = "EditorHook",
	name        = "Varispeed Test - 100ms Callback",
	author      = "Ardour Lua Task Force",
	description = "An example script that invokes a callback a every 0.1sec and modifies the transport speed",
}

function signals ()
	s = LuaSignal.Set()
	s:add (
		{
			[LuaSignal.LuaTimerDS] = true,
		}
	)
	return s
end

function factory (params)
	-- upindex variables
	local cnt = 0
	local speed = 0
	local delta = 0.01
	return function (signal, ref, ...)
		cnt = (cnt + 1) % 5 -- divide clock: every half a second
		if cnt == 0 then
			if speed < -0.25 then delta = delta * -1 end
			if speed >  0.25 then delta = delta * -1 end
			speed = speed + delta
			Session:request_transport_speed (speed)
		end
	end
end