let signal_delay s1 s2 =
let s1_mem = factory_add_memory (signal_fun s1)
(signal_macro_to_int Delay_Memory_Length_int) in
let new_signal = fun t ->
let delay = (signal_fun s2) t in
match delay with
|N i -> if i < 0 then raise (Signal_operation "Delay time < 0.")
else if (t - i) >= 0 then s1_mem (t - i)
else v_zero (s1_mem 0)
|R f -> let i = int_of_float f in
if i < 0 then raise (Signal_operation "Delay time < 0.")
else if (t - i) >= 0 then s1_mem (t - i)
else v_zero (s1_mem 0)
|Vec (size, vec) -> raise (Signal_operation "Delay time can not be a vector.")
|Zero -> s1_mem t
|W -> raise (Signal_operation "Delay time error.")
in
(frequency s1, new_signal)