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;