3 Description: Input wave -> interpretation -> output wave
5 Created: 15/05/2013 Modified: 14/08/2013
12 exception Missing_Expression;;
14 let version = "Faustine: 0.0.1";;
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 = 0xFFF } 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 = 1 } in
31 let path_dsp = ref "";;
32 let size_input = ref 0;;
34 let time_max = ref 0xFFFF;;
35 let dir_output = ref "";;
36 let format_output = ref "wav";;
37 let basename_output = ref "output";;
39 let option_usage = "usage: " ^ Sys.argv.(0)
40 ^ " [-f dsp_src] [-i input] [-l length] [--odir dir] [--oformat wav/csv] [--obasename name]";;
43 fun x -> raise (Arg.Bad ("Bad argument : " ^ x))
46 ("-f", Arg.String (fun s -> path_dsp := s), ": faust .dsp source file");
47 ("-i", Arg.String (fun s -> incr size_input; inputs := !inputs @ [s]), ": set input wave file");
48 ("-l", Arg.Int (fun i -> time_max := i), ": maximun number of output samples");
49 ("--odir", Arg.String (fun s -> dir_output := s), ": set output directory");
50 ("--oformat", Arg.String (fun s -> format_output := s), ": set output format");
51 ("--obasename", Arg.String (fun s -> basename_output := s), ": set output basename");
57 let () = print_endline (Scanf.Scanning.name_of_input (Scanf.Scanning.stdin)) in
58 let () = print_endline (Unix.readlink "/proc/self/fd/0") in
59 let () = print_endline (Unix.readlink "/proc/self/fd/1") in
60 let () = print_endline (Unix.readlink "/proc/self/fd/2") in
62 let () = Arg.parse speclist option_unknown option_usage in
63 let _ = Sys.signal Sys.sigalrm Sys.Signal_ignore in
65 let io = new iomanager in
66 let () = io#set !dir_output !format_output !basename_output in
69 let () = print_string(" Faustine -> Reading input ...") in
70 let tic0 = Unix.time () in
71 let input = io#read !inputs in
72 let toc0 = Unix.time () in
73 let () = print_endline(" Done. (duration: " ^ (string_of_float (toc0 -. tic0)) ^ "s.)") in
76 let () = print_string(" Faustine -> Preprocessing...") in
77 let tic1 = Unix.time () in
78 let faust_core = Preprocess.preprocess !path_dsp in
79 let toc1 = Unix.time () in
80 let () = print_endline(" Done. (duration: " ^ (string_of_float (toc1 -. tic1)) ^ "s.)") in
83 let () = print_string(" Faustine -> Constructing process...") in
84 let tic2 = Unix.time () in
85 let faust_exp = exp_of_string faust_core in
86 let proc = (new proc_factory)#make faust_exp in
87 let toc2 = Unix.time () in
88 let () = print_endline(" Done. (duration: " ^ (string_of_float (toc2 -. tic2)) ^ "s.)") in
91 let () = print_string(" Faustine -> Constructing signals...") in
92 let tic3 = Unix.time () in
93 let output = proc#eval input in
94 let toc3 = Unix.time () in
95 let () = print_endline(" Done. (duration: " ^ (string_of_float (toc3 -. tic3)) ^ "s.)") in
98 let () = print_string(" Faustine -> Evaluating...") in
99 let tic4 = Unix.time () in
100 let data = output#output !time_max in
101 let rates = output#frequency in
102 let toc4 = Unix.time () in
103 let () = print_endline(" Done. (duration: " ^ (string_of_float (toc4 -. tic4)) ^ "s.)") in
106 let () = print_string(" Faustine -> Writing output...") in
107 let tic5 = Unix.time () in
108 let output_paths = io#write rates data in
109 let toc5 = Unix.time () in
110 let () = print_endline(" Done. (duration: " ^ (string_of_float (toc5 -. tic5)) ^ "s.)") in
112 let _ = Array.map print_endline
113 (Array.map decorate output_paths) in