X-Git-Url: https://svn.cri.ensmp.fr/git/Faustine.git/blobdiff_plain/d204fe8a60e0556b0294e17c5c6948cb6cee7d91..dbded051d69cc5ba556884eb285feba032e09d29:/interpretor/signal.ml?ds=inline diff --git a/interpretor/signal.ml b/interpretor/signal.ml index 00a1709..66089e9 100644 --- a/interpretor/signal.ml +++ b/interpretor/signal.ml @@ -113,22 +113,44 @@ class signal : rate_type -> (time -> value_type) -> signal_type = method neg = self#prim1 (fun t -> (self#at t)#neg) method floor = self#prim1 (fun t -> (self#at t)#floor) + method ceil = self#prim1 (fun t -> (self#at t)#ceil) + method rint = self#prim1 (fun t -> (self#at t)#rint) method sin = self#prim1 (fun t -> (self#at t)#sin) + method asin = self#prim1 (fun t -> (self#at t)#asin) method cos = self#prim1 (fun t -> (self#at t)#cos) + method acos = self#prim1 (fun t -> (self#at t)#acos) + method tan = self#prim1 (fun t -> (self#at t)#tan) method atan = self#prim1 (fun t -> (self#at t)#atan) + method exp = self#prim1 (fun t -> (self#at t)#exp) method sqrt = self#prim1 (fun t -> (self#at t)#sqrt) + method ln = self#prim1 (fun t -> (self#at t)#ln) + method lg = self#prim1 (fun t -> (self#at t)#lg) method int = self#prim1 (fun t -> (self#at t)#int) + method float = self#prim1 (fun t -> (self#at t)#float) + method abs = self#prim1 (fun t -> (self#at t)#abs) method add = self#prim2 (fun t -> (self#at t)#add) method sub = self#prim2 (fun t -> (self#at t)#sub) method mul = self#prim2 (fun t -> (self#at t)#mul) method div = self#prim2 (fun t -> (self#at t)#div) + method power = self#prim2 (fun t -> (self#at t)#power) + method _and = self#prim2 (fun t -> (self#at t)#_and) + method _or = self#prim2 (fun t -> (self#at t)#_or) + method _xor = self#prim2 (fun t -> (self#at t)#_xor) method atan2 = self#prim2 (fun t -> (self#at t)#atan2) method _mod = self#prim2 (fun t -> (self#at t)#_mod) - method larger = self#prim2 (fun t -> (self#at t)#larger) - method smaller = self#prim2 (fun t -> (self#at t)#smaller) + method fmod = self#prim2 (fun t -> (self#at t)#fmod) + method remainder = self#prim2 (fun t -> (self#at t)#remainder) + method gt = self#prim2 (fun t -> (self#at t)#gt) + method lt = self#prim2 (fun t -> (self#at t)#lt) + method geq = self#prim2 (fun t -> (self#at t)#geq) + method leq = self#prim2 (fun t -> (self#at t)#leq) + method eq = self#prim2 (fun t -> (self#at t)#eq) + method neq = self#prim2 (fun t -> (self#at t)#neq) method max = self#prim2 (fun t -> (self#at t)#max) method min = self#prim2 (fun t -> (self#at t)#min) + method shl = self#prim2 (fun t -> (self#at t)#shl) + method shr = self#prim2 (fun t -> (self#at t)#shr) method delay : signal_type -> signal_type = fun (s : signal_type) -> @@ -155,6 +177,25 @@ class signal : rate_type -> (time -> value_type) -> signal_type = self#at ((s_index#at t)#to_int) in new signal freq func + method rwtable : signal_type -> signal_type -> + signal_type -> signal_type -> signal_type = + fun init -> fun wstream -> fun windex -> fun rindex -> + let freq = self#check_freq [init; wstream; windex; rindex] in + let () = init#add_memory ((self#at 0)#to_int) in + let () = wstream#add_memory ((self#at 0)#to_int) in + let func : time -> value_type = fun (ti : time) -> + let rec table : time -> index -> value_type = + fun t -> fun i -> + if t > 0 then + (if i = (windex#at t)#to_int then (wstream#at t) + else table (t - 1) i) + else if t = 0 then + (if i = (windex#at 0)#to_int then (wstream#at 0) + else init#at i) + else raise (Signal_operation "signal time should be > 0") in + table ti ((rindex#at ti)#to_int) in + new signal freq func + method select2 : signal_type -> signal_type -> signal_type = fun s_first -> fun s_second ->