Fix the Unicode workaround in wscript
[ardour.git] / scripts / _varispeed_callback.lua
1 ardour {
2         ["type"]    = "EditorHook",
3         name        = "Varispeed Test - 100ms Callback",
4         author      = "Ardour Lua Task Force",
5         description = "An example script that invokes a callback a every 0.1sec and modifies the transport speed",
6 }
7
8 function signals ()
9         s = LuaSignal.Set()
10         s:add (
11                 {
12                         [LuaSignal.LuaTimerDS] = true,
13                 }
14         )
15         return s
16 end
17
18 function factory (params)
19         -- upindex variables
20         local cnt = 0
21         local speed = 0
22         local delta = 0.01
23         return function (signal, ref, ...)
24                 cnt = (cnt + 1) % 5 -- divide clock: every half a second
25                 if cnt == 0 then
26                         if speed < -0.25 then delta = delta * -1 end
27                         if speed >  0.25 then delta = delta * -1 end
28                         speed = speed + delta
29                         Session:request_transport_speed (speed)
30                 end
31         end
32 end