blob: def9a81eaf16018c0072c6e3145871ae7a73f32d (
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
|
type t = Brr.G.timer_id ref * unit Note.E.send
let create
: unit -> (t * unit Note.E.t)
= fun () ->
let event, send = Note.E.create () in
(ref (-1), send), event
let stop
: t -> unit
= fun (id, _) ->
Brr.G.stop_timer !id
let start
: t -> float -> unit
= fun (id, send) d ->
Brr.G.stop_timer !id;
let timer_id = Brr.G.set_interval
~ms:(int_of_float @@ d *. 1000.)
(fun () -> send ()) in
ignore @@ Brr.G.set_timeout ~ms:0 send;
id:= timer_id;
|