From: WANG Date: Fri, 6 Sep 2013 16:20:53 +0000 (+0200) Subject: Add abstrat type matrix and data. X-Git-Url: https://scm.cri.mines-paristech.fr/git/Faustine.git/commitdiff_plain/ad5ee319810eae50990c0995176cf48b651b89ee?ds=inline;hp=-c Add abstrat type matrix and data. --- ad5ee319810eae50990c0995176cf48b651b89ee diff --git a/interpretor/beam.ml b/interpretor/beam.ml index 6e56170..bec7ed0 100644 --- a/interpretor/beam.ml +++ b/interpretor/beam.ml @@ -70,7 +70,7 @@ class beam : signal_type array -> beam_type = let signal_at = fun (t : time) -> fun (s : signal_type) -> s#at t in Array.map (signal_at t) self#get - method output : int -> float array array array = + method output : int -> data = fun (length_max : int) -> let transpose : 'a array array -> 'a array array = fun matrix -> diff --git a/interpretor/faustio.ml b/interpretor/faustio.ml index 8518b5b..7df74a6 100644 --- a/interpretor/faustio.ml +++ b/interpretor/faustio.ml @@ -24,13 +24,13 @@ class virtual io = _basename <- basename; _dir <- dir method virtual read : string array -> beam - method virtual write : rate array -> float array array array -> string array + method virtual write : rate array -> data -> string array - method private concat : float array array array -> float array array = - fun (origin : float array array array) -> + method private concat : data -> matrix = + fun (origin : data) -> Array.map Array.concat (Array.map Array.to_list origin) - method private channels : float array array array -> int array = + method private channels : data -> int array = fun data -> let get_channel = fun s -> let l = Array.length s in @@ -66,9 +66,9 @@ class waveio : io_type = array_map2 (new signal) rates (Array.map stream2func containers) in new beam signals - method write : rate array -> float array array array -> string array = + method write : rate array -> data -> string array = fun (rates : rate array) -> - fun (output : float array array array) -> + fun (output : data) -> let n = Array.length output in let paths = Array.init n (fun i -> _dir ^ _basename ^ (string_of_int (i + 1)) ^ ".wav") in @@ -121,9 +121,9 @@ class csvio : io_type = let signals = Array.map self#csvread files in new beam signals - method write : rate array -> float array array array -> string array = + method write : rate array -> data -> string array = fun (rates : rate array) -> - fun (data : float array array array) -> + fun (data : data) -> let paths = let n = Array.length data in let path_pattern = fun i -> @@ -185,9 +185,9 @@ class iomanager = wave#set _dir _basename; csv#set _dir _basename - method write : rate array -> float array array array -> string array = + method write : rate array -> data -> string array = fun (rates : rate array) -> - fun (data : float array array array) -> + fun (data : data) -> if _format = "" then raise (Invalid_argument "output format unset.") else if _format = "wav" then diff --git a/interpretor/types.ml b/interpretor/types.ml index 620cde5..0b7cfde 100644 --- a/interpretor/types.ml +++ b/interpretor/types.ml @@ -133,6 +133,9 @@ class type signal_type = method prefix : signal_type -> signal_type end;; +type matrix = float array array;; + +type data = float array array array;; class type beam_type = object @@ -143,7 +146,7 @@ class type beam_type = method append : beam_type -> beam_type method matching : int -> beam_type method at : time -> value_type array - method output : int -> float array array array + method output : int -> data method frequency : rate_type array end;; @@ -173,5 +176,5 @@ class type io_type = object method set : string -> string -> unit method read : string array -> beam_type - method write : rate_type array -> float array array array -> string array + method write : rate_type array -> data -> string array end;;