3 Description: Input wave -> interpretation -> output wave
5 Created: 15/05/2013 Modified: 14/08/2013
11 exception Missing_Expression;;
13 let time_maximum = 0xFFF;;
16 let _ = Gc.set { (Gc.get())
17 with Gc.minor_heap_size = 0xFFFFFF } in
18 let _ = Gc.set { (Gc.get())
19 with Gc.major_heap_increment = 0xFFFFFF } in
20 let _ = Gc.set { (Gc.get())
21 with Gc.space_overhead = 100 } in
22 let _ = Gc.set { (Gc.get())
23 with Gc.max_overhead = 0xFFFFF } in
24 let _ = Gc.set { (Gc.get())
25 with Gc.stack_limit = 0xFFFFF } in
26 let _ = Gc.set { (Gc.get())
27 with Gc.allocation_policy = 0 } in
30 let has_dsp = ref false;;
31 let path_dsp = ref "";;
32 let num_inwav = ref 0;;
34 let num_incsv = ref 0;;
36 let outwav = ref false;;
37 let outcsv = ref false;;
39 let option_usage = "usage: " ^ Sys.argv.(0)
40 ^ " [-ow] [-oc] [-d string] [-iw string] [-ic string]";;
43 fun x -> raise (Arg.Bad ("Bad argument : " ^ x))
46 ("-ow", Arg.Unit (fun () -> outwav := true), ": output wave files");
47 ("-oc", Arg.Unit (fun () -> outcsv := true), ": output csv files");
48 ("-d", Arg.String (fun s -> has_dsp := true;
49 path_dsp := s), ": set dsp source file");
50 ("-iw", Arg.String (fun s -> incr num_inwav;
51 inwavs := !inwavs @ [s]), ": set input wave file");
52 ("-ic", Arg.String (fun s -> incr num_incsv;
53 incsvs := !incsvs @ [s]), ": set input csv file");
59 (* ignore system alarm clock *)
60 let _ = Sys.signal Sys.sigalrm Sys.Signal_ignore in
62 let () = Arg.parse speclist option_unknown option_usage in
64 let wave = new waveio in
65 let input = wave#read (Array.of_list !inwavs) in
66 let faust_core = Preprocess.preprocess !path_dsp in
67 let faust_exp = exp_of_string faust_core in
68 let proc = (new proc_factory)#make faust_exp in
69 let output = proc#eval input in
70 let data = output#output time_maximum in
71 let rates = output#frequency in
73 let output_paths = wave#write rates data in
74 let _ = Array.map print_string output_paths in
80 let dsp_file_route_string = (io_macro_to_string Dsp_Route_string) ^ Sys.argv.(3) in
81 let () = print_string(" Faustine -> Preprocessing...") in
82 let tic = Sys.time () in
83 let exp_string = Preprocess.preprocess(dsp_file_route_string) in
84 let toc = Sys.time () in
85 let () = print_endline(" Done. (duration: " ^
86 (string_of_float (toc -. tic)) ^ "s)") in
89 let exp_faust = exp_of_string exp_string in
92 let (output_channel_list, output_rate_list, output_float_array_list) =
93 interpreter exp_faust (input_rate_list, input_float_array_list) in
95 (* make output wave files *)
96 if option_out = "-wav" then
97 write_output_wave output_channel_list output_rate_list output_float_array_list
98 else if option_out = "-csv" then
99 write_output_csv output_channel_list output_float_array_list
100 else raise (Invalid_argument ("Unkown option: " ^ option_out))
103 print_endline("Operation not yet programed..");;