From: WANG Date: Mon, 19 Aug 2013 14:54:36 +0000 (+0200) Subject: New Faustine tested by sin.dsp and fft.dsp. X-Git-Url: https://scm.cri.ensmp.fr/git/Faustine.git/commitdiff_plain/d8214dc258396483f72533504515a4e1d1b3deef?hp=a891a827a9bad83d44164ffdd7b28f070c439e46 New Faustine tested by sin.dsp and fft.dsp. --- diff --git a/dsp_files/fft-svg/process.svg b/dsp_files/fft-svg/process.svg index 30a9ebd..1e37bdf 100644 --- a/dsp_files/fft-svg/process.svg +++ b/dsp_files/fft-svg/process.svg @@ -1,72 +1,1347 @@ - - - + + + - - -8 - - - -vectorize - - - - - - - - + + +128 + + + +vectorize + + + + + + + + - -eo(8) + +fft(128) - - - - - - + + + + + + - -output + +pcplx_moduls(128) - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +nconcat(128) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + process - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dsp_files/fft.dsp b/dsp_files/fft.dsp index 34a795e..1415252 100644 --- a/dsp_files/fft.dsp +++ b/dsp_files/fft.dsp @@ -8,7 +8,7 @@ import ( "mrfaustlib/complex.lib" ) ; fft_test(n,m) = vectorize(n) : fft(n) : pcplx_moduls(n) : nconcat(n); //process = +, _ : + : fft_test(128); -process = fft_test(128,128); +process = fft_test(128,128) : serialize; //process = (0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7) <: shuffle(8); diff --git a/dsp_files/sin.dsp b/dsp_files/sin.dsp index 16982a6..b1650f2 100644 --- a/dsp_files/sin.dsp +++ b/dsp_files/sin.dsp @@ -15,4 +15,5 @@ osc(freq) = phase(freq) : rdtable(tablesize, sinwavform); vol = 1; freq = 1000; -process = osc(freq) * vol; \ No newline at end of file +process = osc(freq) * vol; +//process = freq / samplingfreq : @(1): ( + : decimal) ~ _ : * (tablesize) : int ; diff --git a/interpretor/Makefile b/interpretor/Makefile index 23b74e4..39ec26e 100644 --- a/interpretor/Makefile +++ b/interpretor/Makefile @@ -146,6 +146,12 @@ preprocess.cmx: preprocess.ml preprocess_stubs.o: preprocess_stubs.cpp $(CC) $(CC_OPTIONS) $< +faustio.cmo: faustio.ml + $(CAMLC) $(INCLUDE) $(LIBS) -c $< + +faustio.cmx: faustio.ml + $(CAMLOPT) $(INCLUDE) $(LIBS:.cma=.cmxa) -c $< + .SUFFIXES: .ml .mli .cmo .cmi .cmx .mll .mly .ml.cmo: diff --git a/interpretor/aux.ml b/interpretor/aux.ml index 3bc11a6..fccb904 100644 --- a/interpretor/aux.ml +++ b/interpretor/aux.ml @@ -18,4 +18,4 @@ let array_map3 = fun f -> fun a -> fun b -> fun c -> let n2 = Array.length b in let n3 = Array.length c in if n1 = n2 && n1 = n3 then Array.init n1 (fun i -> f a.(i) b.(i) c.(i)) - else raise (Invalid_argument "Array.map2 size not matched.");; + else raise (Invalid_argument "Array.map3 size not matched.");; diff --git a/interpretor/beam.ml b/interpretor/beam.ml index 7726e95..c4c3b9e 100644 --- a/interpretor/beam.ml +++ b/interpretor/beam.ml @@ -103,7 +103,11 @@ class beam : signal_type array -> beam_type = method frequency : int array = let each_rate : signal -> int = - fun (s : signal) -> s#frequency in + fun (s : signal) -> + let rate = s#frequency in + if rate > 0 then rate + else if rate = 0 then 44100 + else raise (Beam_matching "frequency error.") in Array.map each_rate self#get end diff --git a/interpretor/faustine b/interpretor/faustine index c53ab87..c76b5ba 100755 Binary files a/interpretor/faustine and b/interpretor/faustine differ diff --git a/interpretor/faustio.ml b/interpretor/faustio.ml index b05f18d..25a2868 100644 --- a/interpretor/faustio.ml +++ b/interpretor/faustio.ml @@ -6,6 +6,9 @@ *) open Types;; +open Basic;; +open Value;; +open Signal;; open Beam;; open Aux;; @@ -34,13 +37,16 @@ class waveio : io_type = else let signals = let files = Array.map Sndfile.openfile paths in - let frames = Array.map Int64.to_int (Array.map Sndfile.frames files) in + let frames = Array.map Int64.to_int + (Array.map Sndfile.frames files) in let rates = Array.map Sndfile.samplerate files in let create_container = fun l -> Array.create l 1. in let containers = Array.map create_container frames in let _ = array_map2 Sndfile.read files containers in let _ = Array.map Sndfile.close files in - array_map2 (new signal) rates containers in + let stream2func = + fun stream -> fun t -> new value (R stream.(t)) in + array_map2 (new signal) rates (Array.map stream2func containers) in new beam signals method write : int array -> value_type array array -> string array = @@ -51,31 +57,33 @@ class waveio : io_type = let n = Array.length output in let paths = Array.init n (fun i -> - default_output_path ^ "output" ^ (string_of_int i) ^ ".wav") in + default_output_path ^ "output" ^ (string_of_int (i + 1)) ^ ".wav") in let files = let channels = - let get_channel = fun l -> fun s -> + let get_channel = fun s -> + let l = Array.length s in match s.(l - 1)#get with | Vec vec -> vec#size | _ -> 1 in - Array.map (get_channel n) output in - let format = Sndfile.format Sndfile.MAJOR_WAV Sndfile.MINOR_PCM_16 in + Array.map get_channel output in + let file_format = Sndfile.format + Sndfile.MAJOR_WAV Sndfile.MINOR_PCM_16 in let openwr = fun path -> fun channel -> fun rate -> - Sndfile.openfile ~info:(Sndfile.RDWR, format, channel, rate) path in - array_map3 openwr paths channels rates in - + Sndfile.openfile ~info:(Sndfile.RDWR, file_format, channel, rate) path in + array_map3 openwr paths channels rates in let () = let data = self#to_float output in let _ = array_map2 Sndfile.write files data in let _ = Array.map Sndfile.close files in let toc = Sys.time () in let duration = toc -. tic in - Print_endline + print_endline (" Done. (duration: " ^ (string_of_float duration) ^ "s)") in paths end;; + (* class csvio : io_type = object (self) @@ -89,6 +97,8 @@ class csvio : io_type = end;; *) + +(* let csvread = fun (ic : in_channel) -> let string_list = ref [] in try @@ -103,7 +113,7 @@ let csvread = fun (ic : in_channel) -> let read_input_csv = fun argv -> let n_input = (Array.length argv) - 4 in if n_input < 0 then - raise Missing_Expression + raise (Invalid_argument "xxx") else if n_input = 0 then ([], []) else @@ -161,3 +171,4 @@ let write_output_csv = fun channel_int_list -> fun data_float_array_list -> let toc = Sys.time () in print_endline(" Done. (duration: " ^ (string_of_float (toc -. tic)) ^ "s)");; +*) diff --git a/interpretor/gmon.out b/interpretor/gmon.out index 3f89290..0161dc6 100644 Binary files a/interpretor/gmon.out and b/interpretor/gmon.out differ diff --git a/interpretor/main.ml b/interpretor/main.ml index 54b7265..9f3e796 100644 --- a/interpretor/main.ml +++ b/interpretor/main.ml @@ -2,216 +2,79 @@ Module: Interpreter Description: Input wave -> interpretation -> output wave @author WANG Haisheng - Created: 15/05/2013 Modified: 04/06/2013 + Created: 15/05/2013 Modified: 14/08/2013 *) -open Faustexp;; -open Interpreter;; +open Process;; +open Faustio;; -(* EXCEPTIONS *) - -(** Exception raised when no string expression of faust process is typed in console.*) exception Missing_Expression;; +let time_maximum = 0xFFF;; - -(* MACRO *) - -(** Macro constants of input/output route.*) -type io_macro = - | Input_Route_string - | Output_Route_string - | Dsp_Route_string;; - -(** val io_macro_to_string : io_macro -> string.*) -let io_macro_to_string m = match m with - | Input_Route_string -> "" - | Output_Route_string -> "../output_sounds/" - | Dsp_Route_string -> "";; - - -(** val set_GC : unit -> unit *) let set_GC () = - let _ = Gc.set { (Gc.get()) with Gc.minor_heap_size = 0xFFFFFF } in - let _ = Gc.set { (Gc.get()) with Gc.major_heap_increment = 0xFFFFFF } in - let _ = Gc.set { (Gc.get()) with Gc.space_overhead = 100 } in - let _ = Gc.set { (Gc.get()) with Gc.max_overhead = 0xFFFFF } in - let _ = Gc.set { (Gc.get()) with Gc.stack_limit = 0xFFFFF } in - let _ = Gc.set { (Gc.get()) with Gc.allocation_policy = 0 } in + let _ = Gc.set { (Gc.get()) + with Gc.minor_heap_size = 0xFFFFFF } in + let _ = Gc.set { (Gc.get()) + with Gc.major_heap_increment = 0xFFFFFF } in + let _ = Gc.set { (Gc.get()) + with Gc.space_overhead = 100 } in + let _ = Gc.set { (Gc.get()) + with Gc.max_overhead = 0xFFFFF } in + let _ = Gc.set { (Gc.get()) + with Gc.stack_limit = 0xFFFFF } in + let _ = Gc.set { (Gc.get()) + with Gc.allocation_policy = 0 } in () ;; -(* INPUT && OUTPUT*) - -(** val read_input_wave : string array -> int list * float array list - [read_input_wave argv] gets information from command line, - returns sample rate list and data (in form of float array) list. -*) -let read_input_wave = fun argv -> - let n_input = (Array.length argv) - 4 in - if n_input < 0 then - raise Missing_Expression - else if n_input = 0 then - ([], []) - else - (* open wave file *) - let file_string_array = Array.sub argv 4 n_input in - let make_chemin s = io_macro_to_string Input_Route_string ^ s in - let file_chemin_string_array = Array.map make_chemin file_string_array in - let file_array = Array.map Sndfile.openfile file_chemin_string_array in - let file_list = Array.to_list file_array in - - (* prepare data container *) - let frames_array = Array.map Int64.to_int (Array.map Sndfile.frames file_array) in - let create_data_array num = Array.create num 1. in - let data_float_array_array = Array.map create_data_array frames_array in - let data_float_array_list = Array.to_list data_float_array_array in - - (* read sample rates and data *) - let rate_list = List.map Sndfile.samplerate file_list in - let _ = List.map2 Sndfile.read file_list data_float_array_list in - let _ = List.map Sndfile.close file_list in - (rate_list, data_float_array_list);; - - -(** val write_output_wave : int list -> int list -> float_array_list -> unit. - [write_output_wave channel_numbers sample_rates data] -*) -let write_output_wave = fun channel_int_list -> fun rate_int_list -> fun data_float_array_list -> - let () = print_string(" Faustine -> Writing wave files...") in - let tic = Sys.time () in - - (* make output wave file names : output0, output1, ... *) - let n_output = List.length data_float_array_list in - let n_array = Array.init n_output (fun n -> n) in - let make_file_name i = "output" ^ (string_of_int i) ^ ".wav" in - - (* make output wave file routes *) - let make_chemin s = io_macro_to_string Output_Route_string ^ s in - let file_name_string_array = Array.map make_file_name n_array in - let file_chemin_string_array = Array.map make_chemin file_name_string_array in - let file_chemin_string_list = Array.to_list file_chemin_string_array in - - (* open files for writing with respects to channel numbers and sample rates *) - let file_format = Sndfile.format Sndfile.MAJOR_WAV Sndfile.MINOR_PCM_16 in - let openwr = fun file_chemin_string -> fun channel -> fun rate -> - Sndfile.openfile ~info:(Sndfile.RDWR, file_format, channel, rate) file_chemin_string in - let openwr_fun_list = fun fl -> fun cl -> fun rl -> fun i -> - openwr (List.nth fl i) (List.nth cl i) (List.nth rl i) in - let output_file_list = List.map - (openwr_fun_list file_chemin_string_list channel_int_list rate_int_list) - (Array.to_list (Array.init n_output (fun n -> n))) in - - (* write data into files *) - let _ = List.map2 Sndfile.write output_file_list data_float_array_list in - let _ = List.map Sndfile.close output_file_list in - let toc = Sys.time () in - print_endline(" Done. (duration: " ^ (string_of_float (toc -. tic)) ^ "s)");; - - -let csvread = fun (ic : in_channel) -> - let string_list = ref [] in - try - while true do - string_list := !string_list @ [(input_line ic)] - done; - [||] - with End_of_file -> - (*let () = print_endline(List.nth !string_list 0) in*) - Array.of_list (List.map float_of_string !string_list);; - -let read_input_csv = fun argv -> - let n_input = (Array.length argv) - 4 in - if n_input < 0 then - raise Missing_Expression - else if n_input = 0 then - ([], []) - else - (* open csv file *) - let file_string_array = Array.sub argv 4 n_input in - let make_chemin s = io_macro_to_string Input_Route_string ^ s in - let file_chemin_string_array = Array.map make_chemin file_string_array in - let file_array = Array.map open_in file_chemin_string_array in - let file_list = Array.to_list file_array in - - (* read sample rates and data *) - let rate_list = Array.to_list (Array.create n_input 0) in - let data_float_array_list = List.map csvread file_list in - let _ = List.map close_in file_list in - (rate_list, data_float_array_list);; - - -let write_output_csv = fun channel_int_list -> fun data_float_array_list -> - let () = print_string(" Faustine -> Writing csv files...") in - let tic = Sys.time () in - - (* make output txt file names : output0, output1, ... *) - let n_output = List.length data_float_array_list in - let n_array = Array.init n_output (fun n -> n) in - let make_file_name i = "output" ^ (string_of_int i) ^ ".csv" in - - (* make output wave file routes *) - let make_chemin s = io_macro_to_string Output_Route_string ^ s in - let file_name_string_array = Array.map make_file_name n_array in - let file_chemin_string_array = Array.map make_chemin file_name_string_array in - let file_chemin_string_list = Array.to_list file_chemin_string_array in - - (* open output channels *) - let file_list = List.map open_out file_chemin_string_list in - let data_string_array_list = List.map (Array.map string_of_float) data_float_array_list in - let array_to_string = fun data_string_array -> fun channel_int -> - let data_length = Array.length data_string_array in - let rec to_string_rec = - fun data -> fun channel -> fun n -> fun i -> fun column -> - if i < n then - ( - let element = data.(i) in - if column < (channel - 1) then - element ^ "," ^ (to_string_rec data channel n (i + 1) (column + 1)) - else if column = (channel - 1) then - element ^ "\n" ^ (to_string_rec data channel n (i + 1) 0) - else raise (Invalid_argument "write_output_txt.") - ) - else "" in - to_string_rec data_string_array channel_int data_length 0 0 in - - let data_string_list = List.map2 array_to_string data_string_array_list channel_int_list in - let _ = List.map2 output_string file_list data_string_list in - let _ = List.map close_out file_list in - let toc = Sys.time () in - print_endline(" Done. (duration: " ^ (string_of_float (toc -. tic)) ^ "s)");; - - -let read_input = fun option_in -> fun argv -> - if option_in = "-wav" then - read_input_wave argv - else if option_in = "-csv" then - read_input_csv argv - else raise (Invalid_argument ("Unkown option: " ^ option_in));; - - -(* MAIN *) - -(** val main : unit -> unit -main function reads console input strings (Sys.argv) with -input: string of faust process, input waves in default directory 'input_sounds/' -output: output waves in default directory 'output_sounds/'.*) +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 option_usage = "usage: " ^ Sys.argv.(0) + ^ " [-ow] [-oc] [-d string] [-iw string] [-ic string]";; + +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"); + ];; + let main () = (* ignore system alarm clock *) let _ = Sys.signal Sys.sigalrm Sys.Signal_ignore in - - (* set garbage collector *) let _ = set_GC () in - - (* select output type *) - let option_in = Sys.argv.(1) in - let option_out = Sys.argv.(2) in - - (* read input wave files *) - - let (input_rate_list, input_float_array_list) = read_input option_in Sys.argv in - + let () = Arg.parse speclist option_unknown option_usage in + + let wave = new waveio 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_paths = wave#write rates data in + let _ = Array.map print_string output_paths in + ();; + +(* try (* preprocess *) let dsp_file_route_string = (io_macro_to_string Dsp_Route_string) ^ Sys.argv.(3) in @@ -239,5 +102,7 @@ let main () = with NotYetDone -> print_endline("Operation not yet programed..");; +*) + main();; diff --git a/interpretor/parser.ml b/interpretor/parser.ml deleted file mode 100644 index 1d2850c..0000000 --- a/interpretor/parser.ml +++ /dev/null @@ -1,265 +0,0 @@ -type token = - | CONST of (string) - | IDENT of (Types.symbol) - | LPAR - | RPAR - | SEQ - | SPLIT - | MERGE - | PAR - | REC - | EOF - | POINT - -open Parsing;; -# 1 "parser.mly" - - open Types -# 19 "parser.ml" -let yytransl_const = [| - 259 (* LPAR *); - 260 (* RPAR *); - 261 (* SEQ *); - 262 (* SPLIT *); - 263 (* MERGE *); - 264 (* PAR *); - 265 (* REC *); - 0 (* EOF *); - 266 (* POINT *); - 0|] - -let yytransl_block = [| - 257 (* CONST *); - 258 (* IDENT *); - 0|] - -let yylhs = "\255\255\ -\001\000\002\000\002\000\002\000\002\000\002\000\002\000\002\000\ -\002\000\002\000\002\000\000\000" - -let yylen = "\002\000\ -\002\000\001\000\002\000\003\000\001\000\003\000\003\000\003\000\ -\003\000\003\000\003\000\002\000" - -let yydefred = "\000\000\ -\000\000\000\000\000\000\005\000\000\000\012\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\001\000\004\000\ -\006\000\000\000\000\000\000\000\000\000\011\000" - -let yydgoto = "\002\000\ -\006\000\007\000" - -let yysindex = "\255\255\ -\008\255\000\000\024\255\000\000\008\255\000\000\012\000\032\255\ -\023\255\008\255\008\255\008\255\008\255\008\255\000\000\000\000\ -\000\000\016\255\253\254\253\254\011\255\000\000" - -let yyrindex = "\000\000\ -\000\000\000\000\001\000\000\000\000\000\000\000\000\000\007\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\022\000\023\000\026\000\018\000\000\000" - -let yygindex = "\000\000\ -\000\000\003\000" - -let yytablesize = 286 -let yytable = "\001\000\ -\002\000\010\000\011\000\012\000\013\000\014\000\003\000\009\000\ -\003\000\004\000\005\000\015\000\018\000\019\000\020\000\021\000\ -\022\000\007\000\013\000\014\000\010\000\010\000\008\000\013\000\ -\014\000\009\000\017\000\010\000\011\000\012\000\013\000\014\000\ -\016\000\008\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\002\000\002\000\002\000\002\000\ -\002\000\002\000\003\000\003\000\003\000\003\000\003\000\003\000\ -\010\000\011\000\012\000\013\000\014\000\007\000\007\000\007\000\ -\007\000\010\000\008\000\010\000\010\000\009\000" - -let yycheck = "\001\000\ -\000\000\005\001\006\001\007\001\008\001\009\001\000\000\005\000\ -\001\001\002\001\003\001\000\000\010\000\011\000\012\000\013\000\ -\014\000\000\000\008\001\009\001\005\001\000\000\000\000\008\001\ -\009\001\000\000\004\001\005\001\006\001\007\001\008\001\009\001\ -\001\001\010\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\004\001\005\001\006\001\007\001\ -\008\001\009\001\004\001\005\001\006\001\007\001\008\001\009\001\ -\005\001\006\001\007\001\008\001\009\001\004\001\005\001\006\001\ -\007\001\004\001\004\001\006\001\007\001\004\001" - -let yynames_const = "\ - LPAR\000\ - RPAR\000\ - SEQ\000\ - SPLIT\000\ - MERGE\000\ - PAR\000\ - REC\000\ - EOF\000\ - POINT\000\ - " - -let yynames_block = "\ - CONST\000\ - IDENT\000\ - " - -let yyact = [| - (fun _ -> failwith "parser") -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'faust_exp) in - Obj.repr( -# 16 "parser.mly" - ( _1 ) -# 167 "parser.ml" - : Types.faust_exp)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 17 "parser.mly" - ( Const(N (int_of_string _1)) ) -# 174 "parser.ml" - : 'faust_exp)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in - Obj.repr( -# 18 "parser.mly" - ( Const(R (float_of_string _1)) ) -# 181 "parser.ml" - : 'faust_exp)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : string) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 19 "parser.mly" - ( Const(R (float_of_string (_1 ^ "." ^ _3))) ) -# 189 "parser.ml" - : 'faust_exp)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : Types.symbol) in - Obj.repr( -# 20 "parser.mly" - ( Ident(_1) ) -# 196 "parser.ml" - : 'faust_exp)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'faust_exp) in - Obj.repr( -# 21 "parser.mly" - ( _2 ) -# 203 "parser.ml" - : 'faust_exp)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'faust_exp) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'faust_exp) in - Obj.repr( -# 22 "parser.mly" - ( Par(_1,_3) ) -# 211 "parser.ml" - : 'faust_exp)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'faust_exp) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'faust_exp) in - Obj.repr( -# 23 "parser.mly" - ( Split(_1,_3) ) -# 219 "parser.ml" - : 'faust_exp)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'faust_exp) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'faust_exp) in - Obj.repr( -# 24 "parser.mly" - ( Merge(_1,_3) ) -# 227 "parser.ml" - : 'faust_exp)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'faust_exp) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'faust_exp) in - Obj.repr( -# 25 "parser.mly" - ( Seq(_1,_3) ) -# 235 "parser.ml" - : 'faust_exp)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'faust_exp) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'faust_exp) in - Obj.repr( -# 26 "parser.mly" - ( Rec(_1,_3) ) -# 243 "parser.ml" - : 'faust_exp)) -(* Entry main *) -; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) -|] -let yytables = - { Parsing.actions=yyact; - Parsing.transl_const=yytransl_const; - Parsing.transl_block=yytransl_block; - Parsing.lhs=yylhs; - Parsing.len=yylen; - Parsing.defred=yydefred; - Parsing.dgoto=yydgoto; - Parsing.sindex=yysindex; - Parsing.rindex=yyrindex; - Parsing.gindex=yygindex; - Parsing.tablesize=yytablesize; - Parsing.table=yytable; - Parsing.check=yycheck; - Parsing.error_function=parse_error; - Parsing.names_const=yynames_const; - Parsing.names_block=yynames_block } -let main (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = - (Parsing.yyparse yytables 1 lexfun lexbuf : Types.faust_exp) diff --git a/interpretor/signal.ml b/interpretor/signal.ml index ae312b0..2dd9f73 100644 --- a/interpretor/signal.ml +++ b/interpretor/signal.ml @@ -98,13 +98,13 @@ class signal : int -> (time -> value_type) -> signal_type = let func : time -> value_type = fun (t : time) -> let i = (s#at t)#to_int in - self#delay_by t i in + self#delay_by i t in new signal freq func method mem : signal_type = let freq = self#frequency in let () = self#add_memory 1 in - let func = fun (t : time) -> self#delay_by t 1 in + let func = fun (t : time) -> self#delay_by 1 t in new signal freq func method rdtable : signal_type -> signal_type -> signal_type = diff --git a/interpretor/types.ml b/interpretor/types.ml index 3d14095..89f1e5f 100644 --- a/interpretor/types.ml +++ b/interpretor/types.ml @@ -153,5 +153,5 @@ class type process_type = class type io_type = object method read : string array -> beam_type - method write : value_type array array -> string array + method write : int array -> value_type array array -> string array end;; diff --git a/output_sounds/output0.csv b/output_sounds/output0.csv deleted file mode 100644 index 2b76430..0000000 --- a/output_sounds/output0.csv +++ /dev/null @@ -1 +0,0 @@ -11.7147434919,14.7244318637,21.8646614527,13.0995405061,4.81455509541,1.81200558906,0.985314140699,0.657336220842,0.480263717254,0.369198828126,0.293610919264,0.239431890082,0.199096695505,0.168215674241,0.14396373467,0.124547035321,0.108830638738,0.0958529856501,0.0849893365752,0.0758324610431,0.0680867661039,0.0612975764474,0.0556597101255,0.0505611872284,0.0462751307322,0.042379194851,0.038564116328,0.0358757660985,0.0327819409999,0.0303545995073,0.0283130511756,0.0260217011052,0.0244516499572,0.0227531029172,0.0210358278932,0.0196693939287,0.0183035214354,0.0171118352455,0.0160864158164,0.0150388854444,0.0140544948901,0.0131173447842,0.0122472575581,0.0119764568614,0.0102131753247,0.00947366553556,0.0103306471841,0.00909380608468,0.00845798636029,0.0068121972559,0.00595819695743,0.00663240250984,0.00724001738186,0.00644375114071,0.00498097616174,0.006585079271,0.00499721534749,0.00292955159168,0.00409498970219,0.00445818375496,0.0023379079251,0.00453618881051,0.00440644607224,0.003663670503,0.00161748100223,0.003663670503,0.00440644607225,0.00453618881051,0.0023379079251,0.00445818375496,0.00409498970219,0.00292955159168,0.00499721534749,0.006585079271,0.00498097616174,0.00644375114071,0.00724001738186,0.00663240250984,0.00595819695743,0.0068121972559,0.00845798636029,0.00909380608468,0.0103306471841,0.00947366553556,0.0102131753247,0.0119764568614,0.0122472575581,0.0131173447842,0.0140544948901,0.0150388854444,0.0160864158164,0.0171118352455,0.0183035214354,0.0196693939287,0.0210358278932,0.0227531029172,0.0244516499572,0.0260217011052,0.0283130511756,0.0303545995073,0.0327819409999,0.0358757660985,0.038564116328,0.042379194851,0.0462751307322,0.0505611872284,0.0556597101255,0.0612975764474,0.0680867661039,0.0758324610431,0.0849893365752,0.0958529856501,0.108830638738,0.124547035321,0.14396373467,0.168215674241,0.199096695505,0.239431890082,0.293610919264,0.369198828126,0.480263717254,0.657336220842,0.985314140699,1.81200558906,4.81455509541,13.0995405061,21.8646614527,14.7244318637