Added 'make test' in the Makefile.in, upon sin.dsp.
[Faustine.git] / documentation / code_VALMain.write_output_wave.html
1 <html><head>
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>
18 </head>
19 <body>
20 <code class="code"><span class="keyword">let</span>&nbsp;write_output_wave&nbsp;=&nbsp;<span class="keyword">fun</span>&nbsp;channel_int_list&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;rate_int_list&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;data_float_array_list&nbsp;<span class="keywordsign">-&gt;</span><br>
21 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;()&nbsp;=&nbsp;print_endline(<span class="string">"Making&nbsp;output&nbsp;wave&nbsp;files..."</span>)&nbsp;<span class="keyword">in</span><br>
22 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
23 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;make&nbsp;output&nbsp;wave&nbsp;file&nbsp;names&nbsp;:&nbsp;output0,&nbsp;output1,&nbsp;...&nbsp;*)</span><br>
24 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;n_output&nbsp;=&nbsp;<span class="constructor">List</span>.length&nbsp;data_float_array_list&nbsp;<span class="keyword">in</span><br>
25 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;n_array&nbsp;=&nbsp;<span class="constructor">Array</span>.init&nbsp;n_output&nbsp;(<span class="keyword">fun</span>&nbsp;n&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;n)&nbsp;<span class="keyword">in</span><br>
26 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;make_file_name&nbsp;i&nbsp;=&nbsp;<span class="string">"output"</span>&nbsp;^&nbsp;(string_of_int&nbsp;i)&nbsp;^&nbsp;<span class="string">".wav"</span>&nbsp;<span class="keyword">in</span><br>
27 <br>
28 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;make&nbsp;output&nbsp;wave&nbsp;file&nbsp;routes&nbsp;*)</span><br>
29 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;make_chemin&nbsp;s&nbsp;=&nbsp;io_macro_to_string&nbsp;<span class="constructor">Output_Route_string</span>&nbsp;^&nbsp;s&nbsp;<span class="keyword">in</span><br>
30 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;file_name_string_array&nbsp;=&nbsp;<span class="constructor">Array</span>.map&nbsp;make_file_name&nbsp;n_array&nbsp;<span class="keyword">in</span><br>
31 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;file_chemin_string_array&nbsp;=&nbsp;<span class="constructor">Array</span>.map&nbsp;make_chemin&nbsp;file_name_string_array&nbsp;<span class="keyword">in</span><br>
32 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;file_chemin_string_list&nbsp;=&nbsp;<span class="constructor">Array</span>.to_list&nbsp;file_chemin_string_array&nbsp;<span class="keyword">in</span><br>
33 <br>
34 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;open&nbsp;files&nbsp;for&nbsp;writing&nbsp;with&nbsp;respects&nbsp;to&nbsp;channel&nbsp;numbers&nbsp;and&nbsp;sample&nbsp;rates&nbsp;*)</span><br>
35 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;file_format&nbsp;=&nbsp;<span class="constructor">Sndfile</span>.format&nbsp;<span class="constructor">Sndfile</span>.<span class="constructor">MAJOR_WAV</span>&nbsp;<span class="constructor">Sndfile</span>.<span class="constructor">MINOR_PCM_16</span>&nbsp;<span class="keyword">in</span><br>
36 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;openwr&nbsp;=&nbsp;<span class="keyword">fun</span>&nbsp;file_chemin_string&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;channel&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;rate&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<br>
37 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="constructor">Sndfile</span>.openfile&nbsp;~info:(<span class="constructor">Sndfile</span>.<span class="constructor">RDWR</span>,&nbsp;file_format,&nbsp;channel,&nbsp;rate)&nbsp;file_chemin_string&nbsp;<span class="keyword">in</span><br>
38 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;openwr_fun_list&nbsp;=&nbsp;<span class="keyword">fun</span>&nbsp;fl&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;cl&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;rl&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;i&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<br>
39 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;openwr&nbsp;(<span class="constructor">List</span>.nth&nbsp;fl&nbsp;i)&nbsp;(<span class="constructor">List</span>.nth&nbsp;cl&nbsp;i)&nbsp;(<span class="constructor">List</span>.nth&nbsp;rl&nbsp;i)&nbsp;<span class="keyword">in</span><br>
40 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;output_file_list&nbsp;=&nbsp;<span class="constructor">List</span>.map&nbsp;<br>
41 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(openwr_fun_list&nbsp;file_chemin_string_list&nbsp;channel_int_list&nbsp;rate_int_list)&nbsp;<br>
42 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(<span class="constructor">Array</span>.to_list&nbsp;(<span class="constructor">Array</span>.init&nbsp;n_output&nbsp;(<span class="keyword">fun</span>&nbsp;n&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;n)))&nbsp;<span class="keyword">in</span><br>
43 <br>
44 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;write&nbsp;data&nbsp;into&nbsp;files&nbsp;*)</span><br>
45 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;_&nbsp;=&nbsp;<span class="constructor">List</span>.map2&nbsp;<span class="constructor">Sndfile</span>.write&nbsp;output_file_list&nbsp;data_float_array_list&nbsp;<span class="keyword">in</span><br>
46 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;_&nbsp;=&nbsp;<span class="constructor">List</span>.map&nbsp;<span class="constructor">Sndfile</span>.close&nbsp;output_file_list&nbsp;<span class="keyword">in</span><br>
47 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print_endline(<span class="string">"Success."</span>)</code></body></html>