2 <link rel=
"stylesheet" href=
"style.css" type=
"text/css">
3 <meta content=
"text/html; charset=iso-8859-1" http-equiv=
"Content-Type">
4 <link rel=
"Start" href=
"index.html">
5 <link title=
"Index of types" rel=Appendix
href=
"index_types.html">
6 <link title=
"Index of exceptions" rel=Appendix
href=
"index_exceptions.html">
7 <link title=
"Index of values" rel=Appendix
href=
"index_values.html">
8 <link title=
"Index of modules" rel=Appendix
href=
"index_modules.html">
9 <link title=
"Types" rel=
"Chapter" href=
"Types.html">
10 <link title=
"Parser" rel=
"Chapter" href=
"Parser.html">
11 <link title=
"Lexer" rel=
"Chapter" href=
"Lexer.html">
12 <link title=
"Value" rel=
"Chapter" href=
"Value.html">
13 <link title=
"Signal" rel=
"Chapter" href=
"Signal.html">
14 <link title=
"Faustexp" rel=
"Chapter" href=
"Faustexp.html">
15 <link title=
"Interpreter" rel=
"Chapter" href=
"Interpreter.html">
16 <link title=
"Preprocess" rel=
"Chapter" href=
"Preprocess.html">
17 <link title=
"Main" rel=
"Chapter" href=
"Main.html"><title>Main.write_output_txt
</title>
20 <code class=
"code"><span class=
"keyword">let
</span> write_output_txt
=
<span class=
"keyword">fun
</span> channel_int_list
<span class=
"keywordsign">-
></span> <span class=
"keyword">fun
</span> data_float_array_list
<span class=
"keywordsign">-
></span><br>
21 <span class=
"keyword">let
</span> ()
=
print_endline(
<span class=
"string">"Making output txt files..."</span>)
<span class=
"keyword">in
</span><br>
23 <span class=
"comment">(*
make
output
txt
file
names
:
output0,
output1,
...
*)
</span><br>
24 <span class=
"keyword">let
</span> n_output
=
<span class=
"constructor">List
</span>.length
data_float_array_list
<span class=
"keyword">in
</span><br>
25 <span class=
"keyword">let
</span> n_array
=
<span class=
"constructor">Array
</span>.init
n_output
(
<span class=
"keyword">fun
</span> n
<span class=
"keywordsign">-
></span> n)
<span class=
"keyword">in
</span><br>
26 <span class=
"keyword">let
</span> make_file_name
i
=
<span class=
"string">"output"</span> ^
(string_of_int
i)
^
<span class=
"string">".csv"</span> <span class=
"keyword">in
</span><br>
28 <span class=
"comment">(*
make
output
wave
file
routes
*)
</span><br>
29 <span class=
"keyword">let
</span> make_chemin
s
=
io_macro_to_string
<span class=
"constructor">Output_Route_string
</span> ^
s
<span class=
"keyword">in
</span><br>
30 <span class=
"keyword">let
</span> file_name_string_array
=
<span class=
"constructor">Array
</span>.map
make_file_name
n_array
<span class=
"keyword">in
</span><br>
31 <span class=
"keyword">let
</span> file_chemin_string_array
=
<span class=
"constructor">Array
</span>.map
make_chemin
file_name_string_array
<span class=
"keyword">in
</span><br>
32 <span class=
"keyword">let
</span> file_chemin_string_list
=
<span class=
"constructor">Array
</span>.to_list
file_chemin_string_array
<span class=
"keyword">in
</span><br>
34 <span class=
"comment">(*
open
output
channels
*)
</span><br>
35 <span class=
"keyword">let
</span> file_list
=
<span class=
"constructor">List
</span>.map
open_out
file_chemin_string_list
<span class=
"keyword">in
</span><br>
36 <span class=
"keyword">let
</span> array_to_string
=
<span class=
"keyword">fun
</span> data_float_array
<span class=
"keywordsign">-
></span> <span class=
"keyword">fun
</span> channel_int
<span class=
"keywordsign">-
></span><br>
37 <span class=
"keyword">let
</span> data_length
=
<span class=
"constructor">Array
</span>.length
data_float_array
<span class=
"keyword">in
</span><br>
38 <span class=
"keyword">let
</span> <span class=
"keyword">rec
</span> to_string_rec
=
<br>
39 <span class=
"keyword">fun
</span> data
<span class=
"keywordsign">-
></span> <span class=
"keyword">fun
</span> channel
<span class=
"keywordsign">-
></span> <span class=
"keyword">fun
</span> n
<span class=
"keywordsign">-
></span> <span class=
"keyword">fun
</span> i
<span class=
"keywordsign">-
></span> <span class=
"keyword">fun
</span> column
<span class=
"keywordsign">-
></span><br>
40 <span class=
"keyword">if
</span> i
< n
<span class=
"keyword">then
</span> <br>
41 (
<br>
42 <span class=
"keyword">let
</span> element
=
string_of_float
(data.(i))
<span class=
"keyword">in
</span><br>
43 <span class=
"keyword">if
</span> column
< (channel
-
1)
<span class=
"keyword">then
</span> <br>
44 element
^
<span class=
"string">","</span> ^
(to_string_rec
data
channel
n
(i
+
1)
(column
+
1))
<br>
45 <span class=
"keyword">else
</span> <span class=
"keyword">if
</span> column
=
(channel
-
1)
<span class=
"keyword">then
</span><br>
46 element
^
<span class=
"string">"\n"</span> ^
(to_string_rec
data
channel
n
(i
+
1)
0)
<br>
47 <span class=
"keyword">else
</span> raise
(
<span class=
"constructor">Invalid_argument
</span> <span class=
"string">"write_output_txt."</span>)
<br>
48 )
<br>
49 <span class=
"keyword">else
</span> <span class=
"string">""</span> <span class=
"keyword">in
</span><br>
50 to_string_rec
data_float_array
channel_int
data_length
0 0 <span class=
"keyword">in
</span><br>
52 <span class=
"keyword">let
</span> data_string_list
=
<span class=
"constructor">List
</span>.map2
array_to_string
data_float_array_list
channel_int_list
<span class=
"keyword">in
</span><br>
53 <span class=
"keyword">let
</span> _
=
<span class=
"constructor">List
</span>.map2
output_string
file_list
data_string_list
<span class=
"keyword">in
</span><br>
54 <span class=
"keyword">let
</span> _
=
<span class=
"constructor">List
</span>.map
close_out
file_list
<span class=
"keyword">in
</span><br>
55 print_endline(
<span class=
"string">"Success"</span>)
</code></body></html>