- if _output_filename = "" then (
- if _format = "" then
- raise (Invalid_argument "output format unset.")
- else if _format = "wav" then
- wave#write rates data
- else if _format = "csv" then
- csv#write rates data
- else raise (Invalid_argument "unknown format."))
- else (
- let format = format_of_file _output_filename in
- if format = "wav" then
- wave#write rates data
- else if format = "csv" then
- csv#write rates data
- else raise (Invalid_argument ("unknown format" ^ format)))
+ let n = Array.length rates in
+ if n = 1 then (
+ if _filename <> "" then (
+ let fmt = format_of_file _filename in
+ if fmt = "csv" then csv#write rates data (_filename, "")
+ else if fmt = "wav" then wave#write rates data (_filename, "")
+ else raise (IO_Error "Unknown stdout format."))
+ else if _basename <> "" && _format <> "" then (
+ if _format = "csv" then csv#write rates data ("", _basename)
+ else if _format = "wav" then wave#write rates data ("", _basename)
+ else raise (IO_Error "Unknown --oformat."))
+ else if _filename = "" && _basename = "" && _format = "" then
+ csv#write rates data ("", "")
+ else raise (IO_Error "Please specify both --obasename and --oformat."))
+
+ else if n > 1 then (
+ if _filename <> "" then
+ raise (IO_Error "Stdout doesn't support multi-output process. Please remove '> stdout' and use --obasename --oformat.")
+ else if _basename <> "" && _format <> "" then (
+ if _format = "csv" then csv#write rates data ("", _basename)
+ else if _format = "wav" then wave#write rates data ("", _basename)
+ else raise (IO_Error "Unknown --oformat."))
+ else raise (IO_Error "Please specify both --obasename and --oformat."))
+
+ else
+ [|"no output signal."|]