X-Git-Url: https://svn.cri.ensmp.fr/git/Faustine.git/blobdiff_plain/a891a827a9bad83d44164ffdd7b28f070c439e46..d8214dc258396483f72533504515a4e1d1b3deef:/interpretor/faustio.ml?ds=sidebyside 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)");; +*)