exception Beam_matching of string;;
+open Types;;
open Signal;;
class beam : signal_type array -> beam_type =
- fun (sa_init : signal_type array) ->
+ fun (signals_init : signal_type array) ->
object (self)
- val sa = sa_init
- val l = Array.length sa
+ val signals = signals_init
- method get = sa
-
- method length = l
+ method get = signals
+ method length = Array.length signals
method sub : int -> int -> beam_type =
fun start ->
new beam (Array.sub self#get start len)
method append : beam_type -> beam_type =
- fun b ->
- new beam (Array.append self#get b)
+ fun (b : beam_type) ->
+ new beam (Array.append self#get b#get)
+
+ method private add_memory : int -> unit =
+ fun (window : int) ->
+ let signal_add_memory : int -> signal_type -> unit =
+ fun (l : int) ->
+ fun (s : signal) ->
+ s#add_memory l in
+ let _ = Array.map (signal_add_memory window) self#get in ()
- method matching : int -> beam_type
+ method matching : int -> beam_type =
fun size ->
- if size = self#length then self
- else if size > self#length && size mod self#length = 0 then
-
- else if size < self#length && self#length mod size = 0 then
-
+ if size = self#length then new beam self#get
+
+ else if (size > self#length) && (size mod self#length = 0) then
+ let () = self#add_memory 1 in
+ let split_signals =
+ Array.concat (Array.to_list
+ (Array.make (size/self#length) self#get)) in
+ new beam split_signals
+
+ else if (size < self#length) && (self#length mod size = 0) then
+ let rec merge_rec =
+ fun (sa : signal_type array) ->
+ fun (l : int) ->
+ fun (i : int) ->
+ if i + l < Array.length sa then
+ (sa.(i))#add (merge_rec sa l (i + l))
+ else sa.(i) in
+ let merge_signals = Array.init size (merge_rec self#get size) in
+ new beam merge_signals
+
else raise (Beam_matching "matching size error")
+ method time : time -> value_type array =
+ fun t ->
+ let signal_at = fun (t : time) -> fun (s : signal_type) -> s#at t in
+ Array.map (signal_at t) self#get
+ method output : int -> (int list) * (float array list) =
+
end
// Karim Barkati: printing globals value
//list<string> faustGlobals = {
- cout << "gFaustSuperSuperDirectory = " << gFaustSuperSuperDirectory << endl;
- cout << "gFaustSuperDirectory = " << gFaustSuperDirectory << endl;
- cout << "gFaustDirectory = " << gFaustDirectory << endl;
- cout << "gMasterDocument = " << gMasterDocument << endl;
- cout << "gMasterDirectory = " << gMasterDirectory << endl;
- cout << "gMasterName = " << gMasterName << endl;
+ //cout << "gFaustSuperSuperDirectory = " << gFaustSuperSuperDirectory << endl;
+ //cout << "gFaustSuperDirectory = " << gFaustSuperDirectory << endl;
+ //cout << "gFaustDirectory = " << gFaustDirectory << endl;
+ //cout << "gMasterDocument = " << gMasterDocument << endl;
+ //cout << "gMasterDirectory = " << gMasterDirectory << endl;
+ //cout << "gMasterName = " << gMasterName << endl;
return result_char;
}
(** val interpreter_macro_to_value : returns the value associated with the macro.*)
let interpreter_macro_to_value m = match m with
- | Number_samples_int -> 0xFF
+ | Number_samples_int -> 0xFFFFF
| Max_Eval_Time_int -> 0xFFFFFFFF;;
<- (Array.map convert_back_R (f (!index)));
incr index;
done;
- let () = print_string ("Done.") in
!container_float_array_array_array
with x ->
|Beam_Matching_Error s -> "Beam_Matching_Error: " ^ s
|Evaluation_Error s -> "Evaluation_Error: " ^ s
|NotYetDone -> "NotYetDone"
- |_ -> "Done."
+ |_ -> "Compute finished."
in
- let () = print_string error_message in
+ let () = print_endline error_message in
Array.sub (!container_float_array_array_array) 0 !index;;
input: a list of signal functions
output: channel number list, data list.*)
let compute fun_list =
- let () = print_string(" Faustine -> Signals computing... ") in
- let tic = Sys.time () in
+ let () = print_endline("Computing output signals...") in
(* arrange input information *)
let length = interpreter_macro_to_value Number_samples_int in
let channel_array = channels output_float_array_array_array width in
let channel_list = Array.to_list channel_array in
let output_float_array_list = arrange output_float_array_array_array width in
- let toc = Sys.time () in
- let () = print_endline(" (duration: " ^ (string_of_float (toc -. tic)) ^ "s)") in
(channel_list, output_float_array_list);;
|Sin -> if n = 1 then [signal_sin (List.nth input_beam 0)]
else raise (Evaluation_Error "Ident sin")
- |Cos -> if n = 1 then [signal_cos (List.nth input_beam 0)]
- else raise (Evaluation_Error "Ident cos")
-
- |Atan -> if n = 1 then [signal_atan (List.nth input_beam 0)]
- else raise (Evaluation_Error "Ident atan")
-
- |Atantwo -> if n = 2 then [signal_atantwo (List.nth input_beam 0) (List.nth input_beam 1)]
- else raise (Evaluation_Error "Ident atantwo")
-
- |Sqrt -> if n = 1 then [signal_sqrt (List.nth input_beam 0)]
- else raise (Evaluation_Error "Ident sqrt")
-
|Rdtable -> if n = 3 then [signal_rdtable (List.nth input_beam 0)
(List.nth input_beam 1) (List.nth input_beam 2)]
else raise (Evaluation_Error "Ident rdtable")
input: faust expression, sample rate list * input data list
output: channel list * sample rate list * output data list.*)
let interpreter exp_faust input =
- let () = print_string(" Faustine -> Interpretation...") in
- let tic = Sys.time () in
+ let () = print_endline("Interpretation...") in
(* make input beam *)
let input_beam = make_beam input in
(* interprete output beam *)
let output_beam = eval exp_faust dimension_tree input_beam in
- let toc = Sys.time () in
- let () = print_endline(" Done. (duration: " ^ (string_of_float (toc -. tic)) ^ "s)") in
(* get rate list from output beam *)
let rate_list = extract_rate output_beam in
type token =
| CONST of (string)
- | IDENT of (string)
+ | IDENT of (Types.symbol)
| LPAR
| RPAR
| SEQ
# 189 "parser.ml"
: 'faust_exp))
; (fun __caml_parser_env ->
- let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in
+ let _1 = (Parsing.peek_val __caml_parser_env 0 : Types.symbol) in
Obj.repr(
# 20 "parser.mly"
- ( Ident(symbol_of_string _1) )
+ ( Ident(_1) )
# 196 "parser.ml"
: 'faust_exp))
; (fun __caml_parser_env ->
%}
%token <string> CONST
-%token <string> IDENT
+%token <Types.symbol> IDENT
%token LPAR RPAR SEQ SPLIT MERGE PAR REC EOF POINT
%right SPLIT MERGE
%right SEQ
faust_exp: CONST { Const(N (int_of_string $1)) }
| CONST POINT { Const(R (float_of_string $1)) }
| CONST POINT CONST { Const(R (float_of_string ($1 ^ "." ^ $3))) }
- | IDENT { Ident(symbol_of_string $1) }
+ | IDENT { Ident($1) }
| LPAR faust_exp RPAR { $2 }
| faust_exp PAR faust_exp { Par($1,$3) }
| faust_exp SPLIT faust_exp { Split($1,$3) }
else raise (Signal_operation "frequency not matched.") in
List.fold_left check self#frequency sl
- method private add_memory : int -> unit =
+ method add_memory : int -> unit =
fun (length : int) ->
assert (length >= 0);
if memory_length >= length then ()
object
method frequency : int
method at : time -> value_type
+ method add_memory : int -> unit
method add : signal_type -> signal_type
method neg : signal_type
method sub : signal_type -> signal_type
class type beam_type =
object
+ method get : signal_type array
method length : int
- method sub : start: int -> length: int -> beam_type
+ method sub : int -> int -> beam_type
method append : beam_type -> beam_type
- method matching : size: int -> beam_type
- method time : time -> basic list
- method output : length: int -> (int list) * (float array list)
+ method matching : int -> beam_type
+ method time : time -> value_type array
+ method output : int -> (int list) * (float array list)
end;;