0f92cb3332ff8773f1583a95d2d12fdb67da46a2
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_wave
</title>
20 <code class=
"code"><span class=
"keyword">let
</span> write_output_wave
=
<span class=
"keyword">fun
</span> channel_int_list
<span class=
"keywordsign">-
></span> <span class=
"keyword">fun
</span> rate_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 wave files..."</span>)
<span class=
"keyword">in
</span><br>
22 <br>
23 <span class=
"comment">(*
make
output
wave
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">".wav"</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
files
for
writing
with
respects
to
channel
numbers
and
sample
rates
*)
</span><br>
35 <span class=
"keyword">let
</span> file_format
=
<span class=
"constructor">Sndfile
</span>.format
<span class=
"constructor">Sndfile
</span>.
<span class=
"constructor">MAJOR_WAV
</span> <span class=
"constructor">Sndfile
</span>.
<span class=
"constructor">MINOR_PCM_16
</span> <span class=
"keyword">in
</span><br>
36 <span class=
"keyword">let
</span> openwr
=
<span class=
"keyword">fun
</span> file_chemin_string
<span class=
"keywordsign">-
></span> <span class=
"keyword">fun
</span> channel
<span class=
"keywordsign">-
></span> <span class=
"keyword">fun
</span> rate
<span class=
"keywordsign">-
></span> <br>
37 <span class=
"constructor">Sndfile
</span>.openfile
~info:(
<span class=
"constructor">Sndfile
</span>.
<span class=
"constructor">RDWR
</span>,
file_format,
channel,
rate)
file_chemin_string
<span class=
"keyword">in
</span><br>
38 <span class=
"keyword">let
</span> openwr_fun_list
=
<span class=
"keyword">fun
</span> fl
<span class=
"keywordsign">-
></span> <span class=
"keyword">fun
</span> cl
<span class=
"keywordsign">-
></span> <span class=
"keyword">fun
</span> rl
<span class=
"keywordsign">-
></span> <span class=
"keyword">fun
</span> i
<span class=
"keywordsign">-
></span> <br>
39 openwr
(
<span class=
"constructor">List
</span>.nth
fl
i)
(
<span class=
"constructor">List
</span>.nth
cl
i)
(
<span class=
"constructor">List
</span>.nth
rl
i)
<span class=
"keyword">in
</span><br>
40 <span class=
"keyword">let
</span> output_file_list
=
<span class=
"constructor">List
</span>.map
<br>
41 (openwr_fun_list
file_chemin_string_list
channel_int_list
rate_int_list)
<br>
42 (
<span class=
"constructor">Array
</span>.to_list
(
<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>
44 <span class=
"comment">(*
write
data
into
files
*)
</span><br>
45 <span class=
"keyword">let
</span> _
=
<span class=
"constructor">List
</span>.map2
<span class=
"constructor">Sndfile
</span>.write
output_file_list
data_float_array_list
<span class=
"keyword">in
</span><br>
46 <span class=
"keyword">let
</span> _
=
<span class=
"constructor">List
</span>.map
<span class=
"constructor">Sndfile
</span>.close
output_file_list
<span class=
"keyword">in
</span><br>
47 print_endline(
<span class=
"string">"Success."</span>)
</code></body></html>