class virtual io =
object
method virtual read : string array -> beam
- method virtual write : int array -> value_type array array -> string array
- method private to_float : value_type array array -> float array array =
- fun (origin : value_type array array) ->
- let data =
- let value2float = fun (v : value_type) -> v#to_float_array in
- Array.map (Array.map value2float) origin in
- Array.map Array.concat (Array.map Array.to_list data)
+ method virtual write : int array -> float array array array -> string array
+ method private concat : float array array array -> float array array =
+ fun (origin : float array array array) ->
+ Array.map Array.concat (Array.map Array.to_list origin)
end;;
class waveio : io_type =
array_map2 (new signal) rates (Array.map stream2func containers) in
new beam signals
- method write : int array -> value_type array array -> string array =
+ method write : int array -> float array array array -> string array =
fun (rates : int array) ->
- fun (output : value_type array array) ->
+ fun (output : float array array array) ->
let () = print_string(" Faustine -> Writing wave files...") in
let tic = Sys.time () in
let channels =
let get_channel = fun s ->
let l = Array.length s in
- match s.(l - 1)#get with
- | Vec vec -> vec#size
- | _ -> 1 in
+ Array.length s.(l - 1) 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, file_format, channel, rate) path in
array_map3 openwr paths channels rates in
+
let () =
- let data = self#to_float output in
+ let data = self#concat output in
let _ = array_map2 Sndfile.write files data in
let _ = Array.map Sndfile.close files in
let toc = Sys.time () in