X-Git-Url: https://scm.cri.mines-paristech.fr/git/Faustine.git/blobdiff_plain/a6be79ccb7456a5181561f094c1f2a4f90aadb02..8e216a8d5f6b094308594009342e53ef122b8062:/interpretor/main.ml diff --git a/interpretor/main.ml b/interpretor/main.ml index 5e074a2..21c2a8e 100644 --- a/interpretor/main.ml +++ b/interpretor/main.ml @@ -5,12 +5,13 @@ Created: 15/05/2013 Modified: 14/08/2013 *) +open Aux;; open Process;; open Faustio;; exception Missing_Expression;; -let time_maximum = 0xFFF;; +let version = "Faustine: 0.0.1";; let set_GC () = let _ = Gc.set { (Gc.get()) @@ -20,105 +21,92 @@ let set_GC () = let _ = Gc.set { (Gc.get()) with Gc.space_overhead = 100 } in let _ = Gc.set { (Gc.get()) - with Gc.max_overhead = 0xFFFFF } in + with Gc.max_overhead = 0xFFF } in let _ = Gc.set { (Gc.get()) with Gc.stack_limit = 0xFFFFF } in let _ = Gc.set { (Gc.get()) - with Gc.allocation_policy = 0 } in + with Gc.allocation_policy = 1 } in () ;; -let has_dsp = ref false;; let path_dsp = ref "";; -let num_inwav = ref 0;; -let inwavs = ref [];; -let num_incsv = ref 0;; -let incsvs = ref [];; -let outwav = ref false;; -let outcsv = ref false;; - +let size_input = ref 0;; +let inputs = ref [];; +let time_max = ref 0xFFFF;; +let dir_output = ref "";; +let format_output = ref "wav";; +let basename_output = ref "output";; + let option_usage = "usage: " ^ Sys.argv.(0) - ^ " [-ow] [-oc] [-d string] [-iw string] [-ic string]";; + ^ " [-d dsp_src] [-i input] [-t time] [--odir dir] [--oformat wav/csv] [--obasename name]";; let option_unknown = fun x -> raise (Arg.Bad ("Bad argument : " ^ x)) let speclist = [ - ("-ow", Arg.Unit (fun () -> outwav := true), ": output wave files"); - ("-oc", Arg.Unit (fun () -> outcsv := true), ": output csv files"); - ("-d", Arg.String (fun s -> has_dsp := true; - path_dsp := s), ": set dsp source file"); - ("-iw", Arg.String (fun s -> incr num_inwav; - inwavs := !inwavs @ [s]), ": set input wave file"); - ("-ic", Arg.String (fun s -> incr num_incsv; - incsvs := !incsvs @ [s]), ": set input csv file"); + ("-d", Arg.String (fun s -> path_dsp := s), ": set dsp source file"); + ("-i", Arg.String (fun s -> incr size_input; inputs := !inputs @ [s]), ": set input wave file"); + ("-t", Arg.Int (fun i -> time_max := i), ": set max output length"); + ("--odir", Arg.String (fun s -> dir_output := s), ": set output directory"); + ("--oformat", Arg.String (fun s -> format_output := s), ": set output format"); + ("--obasename", Arg.String (fun s -> basename_output := s), ": set output basename"); ];; let main () = - (* ignore system alarm clock *) + let () = Arg.parse speclist option_unknown option_usage in let _ = Sys.signal Sys.sigalrm Sys.Signal_ignore in let _ = set_GC () in - let () = Arg.parse speclist option_unknown option_usage in - - let wave = new waveio in - let csv = new csvio in - let input = wave#read (Array.of_list !inwavs) in - let faust_core = Preprocess.preprocess !path_dsp in - let faust_exp = exp_of_string faust_core in - let proc = (new proc_factory)#make faust_exp in - let output = proc#eval input in - let data = output#output time_maximum in - let rates = output#frequency in - - let output_wave_paths = wave#write rates data in - let _ = csv#write rates data in - let _ = Array.map print_endline output_wave_paths in - ();; - - - - - - - + let io = new iomanager in + let () = io#set !dir_output !format_output !basename_output in + let () = print_string(" Faustine -> Reading input ...") in + let tic0 = Sys.time () in + let input = io#read !inputs in + let toc0 = Sys.time () in + let () = print_endline(" Done. (duration: " ^ (string_of_float (toc0 -. tic0)) ^ "s.)") in + let () = print_string(" Faustine -> Preprocessing...") in + let tic1 = Sys.time () in + let faust_core = Preprocess.preprocess !path_dsp in + let toc1 = Sys.time () in + let () = print_endline(" Done. (duration: " ^ (string_of_float (toc1 -. tic1)) ^ "s.)") in + let () = print_string(" Faustine -> Constructing process...") in + let tic2 = Sys.time () in + let faust_exp = exp_of_string faust_core in + let proc = (new proc_factory)#make faust_exp in + let toc2 = Sys.time () in + let () = print_endline(" Done. (duration: " ^ (string_of_float (toc2 -. tic2)) ^ "s.)") in -(* - try - (* preprocess *) - let dsp_file_route_string = (io_macro_to_string Dsp_Route_string) ^ Sys.argv.(3) in - let () = print_string(" Faustine -> Preprocessing...") in - let tic = Sys.time () in - let exp_string = Preprocess.preprocess(dsp_file_route_string) in - let toc = Sys.time () in - let () = print_endline(" Done. (duration: " ^ - (string_of_float (toc -. tic)) ^ "s)") in + let () = print_string(" Faustine -> Evaluating...") in + let tic3 = Sys.time () in + let output = proc#eval input in + let toc3 = Sys.time () in + let () = print_endline(" Done. (duration: " ^ (string_of_float (toc3 -. tic3)) ^ "s.)") in - (* parsing *) - let exp_faust = exp_of_string exp_string in - (* interpretation *) - let (output_channel_list, output_rate_list, output_float_array_list) = - interpreter exp_faust (input_rate_list, input_float_array_list) in + let () = print_string(" Faustine -> Calculating...") in + let tic4 = Sys.time () in + let data = output#output !time_max in + let rates = output#frequency in + let toc4 = Sys.time () in + let () = print_endline(" Done. (duration: " ^ (string_of_float (toc4 -. tic4)) ^ "s.)") in - (* make output wave files *) - if option_out = "-wav" then - write_output_wave output_channel_list output_rate_list output_float_array_list - else if option_out = "-csv" then - write_output_csv output_channel_list output_float_array_list - else raise (Invalid_argument ("Unkown option: " ^ option_out)) - with NotYetDone -> - print_endline("Operation not yet programed..");; + let () = print_string(" Faustine -> Writing output...") in + let tic5 = Sys.time () in + let output_paths = io#write rates data in + let toc5 = Sys.time () in + let () = print_endline(" Done. (duration: " ^ (string_of_float (toc5 -. tic5)) ^ "s.)") in -*) + let _ = Array.map print_endline + (Array.map decorate output_paths) in + ();; main();;