- 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.")
-
+ 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)))