X-Git-Url: https://svn.cri.ensmp.fr/git/Faustine.git/blobdiff_plain/66f23d4fabf89ad09adbd4dfc15ac6b5b2b7da83..refs/heads/master:/interpreter/signal.ml diff --git a/interpreter/signal.ml b/interpreter/signal.ml index 66089e9..0701ffc 100644 --- a/interpreter/signal.ml +++ b/interpreter/signal.ml @@ -20,19 +20,14 @@ class rate : int -> int -> rate_type = fun i1 -> fun i2 -> let r = i1 mod i2 in if r = 0 then i2 else pgcd i2 r in - let num_positive = - if num_init >= 0 then num_init - else (-num_init) in - let denom_positive = - if denom_init > 0 then denom_init - else if denom_init < 0 then -denom_init - else raise (Signal_operation "sample rate denominater = 0.") in - let factor = pgcd num_positive denom_positive in - let num_corrected = num_init / factor in - let denom_corrected = denom_init / factor in + let factor = + if denom_init = 0 then + raise (Signal_operation "sample rate denominater = 0.") + else + pgcd (abs num_init) (abs denom_init) in object (self) - val _num = num_corrected - val _denom = denom_corrected + val _num = num_init / factor + val _denom = denom_init / factor method num = _num method denom = _denom method to_int = @@ -243,7 +238,6 @@ class signal : rate_type -> (time -> value_type) -> signal_type = new value (Vec (new vector size vec)) in new signal freq func - method serialize : signal_type = let size = match (self#at 0)#get with