3 Description: Input wave -> interpretation -> output wave
5 Created: 15/05/2013 Modified: 14/08/2013
12 exception Missing_Expression;;
14 let time_maximum = 0xFFF;;
17 let _ = Gc.set { (Gc.get())
18 with Gc.minor_heap_size = 0xFFFFFF } in
19 let _ = Gc.set { (Gc.get())
20 with Gc.major_heap_increment = 0xFFFFFF } in
21 let _ = Gc.set { (Gc.get())
22 with Gc.space_overhead = 100 } in
23 let _ = Gc.set { (Gc.get())
24 with Gc.max_overhead = 0xFFFFF } in
25 let _ = Gc.set { (Gc.get())
26 with Gc.stack_limit = 0xFFFFF } in
27 let _ = Gc.set { (Gc.get())
28 with Gc.allocation_policy = 0 } in
31 let has_dsp = ref false;;
32 let path_dsp = ref "";;
33 let num_inwav = ref 0;;
35 let num_incsv = ref 0;;
37 let outwav = ref false;;
38 let outcsv = ref false;;
40 let option_usage = "usage: " ^ Sys.argv.(0)
41 ^ " [-ow] [-oc] [-d string] [-iw string] [-ic string]";;
44 fun x -> raise (Arg.Bad ("Bad argument : " ^ x))
47 ("-ow", Arg.Unit (fun () -> outwav := true), ": output wave files");
48 ("-oc", Arg.Unit (fun () -> outcsv := true), ": output csv files");
49 ("-d", Arg.String (fun s -> has_dsp := true;
50 path_dsp := s), ": set dsp source file");
51 ("-iw", Arg.String (fun s -> incr num_inwav;
52 inwavs := !inwavs @ [s]), ": set input wave file");
53 ("-ic", Arg.String (fun s -> incr num_incsv;
54 incsvs := !incsvs @ [s]), ": set input csv file");
60 (* ignore system alarm clock *)
61 let _ = Sys.signal Sys.sigalrm Sys.Signal_ignore in
63 let () = Arg.parse speclist option_unknown option_usage in
65 let wave = new waveio in
66 let csv = new csvio in
67 let input_wave = wave#read (Array.of_list !inwavs) in
68 let input_csv = csv#read (Array.of_list !incsvs) in
69 let input = input_wave#append input_csv in
71 let () = print_string(" Faustine -> Preprocessing...") in
72 let tic1 = Sys.time () in
73 let faust_core = Preprocess.preprocess !path_dsp in
74 let toc1 = Sys.time () in
75 let () = print_endline(" Done. (duration: " ^ (string_of_float (toc1 -. tic1)) ^ "s.)") in
78 let () = print_string(" Faustine -> Interpretation...") in
79 let tic2 = Sys.time () in
80 let faust_exp = exp_of_string faust_core in
81 let proc = (new proc_factory)#make faust_exp in
82 let toc2 = Sys.time () in
83 let () = print_endline(" Done. (duration: " ^ (string_of_float (toc2 -. tic2)) ^ "s.)") in
86 let output = proc#eval input in
87 let data = output#output time_maximum in
88 let rates = output#frequency in
90 let output_wave_paths = wave#write rates data in
91 let output_csv_paths = csv#write rates data in
92 let _ = Array.map print_endline
93 (Array.map decorate output_wave_paths) in
94 let _ = Array.map print_endline
95 (Array.map decorate output_csv_paths) in
115 let dsp_file_route_string = (io_macro_to_string Dsp_Route_string) ^ Sys.argv.(3) in
116 let () = print_string(" Faustine -> Preprocessing...") in
117 let tic = Sys.time () in
118 let exp_string = Preprocess.preprocess(dsp_file_route_string) in
119 let toc = Sys.time () in
120 let () = print_endline(" Done. (duration: " ^
121 (string_of_float (toc -. tic)) ^ "s)") in
124 let exp_faust = exp_of_string exp_string in
127 let (output_channel_list, output_rate_list, output_float_array_list) =
128 interpreter exp_faust (input_rate_list, input_float_array_list) in
130 (* make output wave files *)
131 if option_out = "-wav" then
132 write_output_wave output_channel_list output_rate_list output_float_array_list
133 else if option_out = "-csv" then
134 write_output_csv output_channel_list output_float_array_list
135 else raise (Invalid_argument ("Unkown option: " ^ option_out))
138 print_endline("Operation not yet programed..");;