<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>fout</title> <link rel="stylesheet" type="text/css" href="csound.css" /> <meta name="generator" content="DocBook XSL Stylesheets V1.76.1" /> <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" /> <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" /> <link rel="prev" href="foscili.html" title="foscili" /> <link rel="next" href="fouti.html" title="fouti" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">fout</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="foscili.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="fouti.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry" title="fout"> <a id="fout"></a> <div class="titlepage"></div> <a id="IndexFout" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">fout</span> </h2> <p>fout — Outputs a-rate signals to an arbitrary number of channels. </p> </div> <div class="refsect1" title="Description"> <a id="idp24140808"></a> <h2>Description</h2> <p> <span class="emphasis"><em>fout</em></span> outputs <span class="emphasis"><em>N</em></span> a-rate signals to a specified file of <span class="emphasis"><em>N</em></span> channels. </p> </div> <div class="refsect1" title="Syntax"> <a id="idp24151512"></a> <h2>Syntax</h2> <pre class="synopsis"><span class="command"><strong>fout</strong></span> ifilename, iformat, aout1 [, aout2, aout3,...,aoutN]</pre> </div> <div class="refsect1" title="Initialization"> <a id="idp24152592"></a> <h2>Initialization</h2> <p> <span class="emphasis"><em>ifilename</em></span> -- the output file's name (in double-quotes). </p> <p> <span class="emphasis"><em>iformat</em></span> -- a flag to choose output file format (note: Csound versions older than 5.0 may only support formats 0, 1, and 2): </p> <div class="itemizedlist"> <ul class="itemizedlist" type="disc"> <li class="listitem"> <p>0 - 32-bit floating point samples without header (binary PCM multichannel file)</p> </li> <li class="listitem"> <p>1 - 16-bit integers without header (binary PCM multichannel file)</p> </li> <li class="listitem"> <p>2 - 16-bit integers with a header. The header type depends on the render (-o) format. For example, if the user chooses the AIFF format (using the <a class="link" href="CommandFlags.html#FlagsMinusUpperA"><em class="citetitle">-A flag</em></a>), the header format will be AIFF type.</p> </li> <li class="listitem"> <p>3 - u-law samples with a header (see iformat=2).</p> </li> <li class="listitem"> <p>4 - 16-bit integers with a header (see iformat=2).</p> </li> <li class="listitem"> <p>5 - 32-bit integers with a header (see iformat=2).</p> </li> <li class="listitem"> <p>6 - 32-bit floats with a header (see iformat=2).</p> </li> <li class="listitem"> <p>7 - 8-bit unsigned integers with a header (see iformat=2).</p> </li> <li class="listitem"> <p>8 - 24-bit integers with a header (see iformat=2).</p> </li> <li class="listitem"> <p>9 - 64-bit floats with a header (see iformat=2).</p> </li> </ul> </div> <p> In addition, Csound versions 5.0 and later allow for explicitly selecting a particular header type by specifying the format as 10 * fileType + sampleFormat, where fileType may be 1 for WAV, 2 for AIFF, 3 for raw (headerless) files, and 4 for IRCAM; sampleFormat is one of the above values in the range 0 to 9, except sample format 0 is taken from the command line (-o), format 1 is 8-bit signed integers, and format 2 is a-law. So, for example, iformat=25 means 32-bit integers with AIFF header. </p> </div> <div class="refsect1" title="Performance"> <a id="idp24197232"></a> <h2>Performance</h2> <p> <span class="emphasis"><em>aout1,... aoutN</em></span> -- signals to be written to the file. In the case of raw files, the expected range of audio signals is determined by the selected sample format; for sound files with a header like WAV and AIFF, the audio signals should be in the range -0dbfs to 0dbfs. </p> <p> <span class="emphasis"><em>fout</em></span> (file output) writes samples of audio signals to a file with any number of channels. Channel number depends by the number of <span class="emphasis"><em>aoutN</em></span> variables (i.e. a mono signal with only an a-rate argument, a stereo signal with two a-rate arguments etc.) Maximum number of channels is fixed to 64. Multiple <span class="emphasis"><em>fout</em></span> opcodes can be present in the same instrument, referring to different files. </p> <p> Notice that, unlike <a class="link" href="out.html" title="out"><em class="citetitle">out</em></a>, <a class="link" href="outs.html" title="outs"><em class="citetitle">outs</em></a> and <a class="link" href="outq.html" title="outq"><em class="citetitle">outq</em></a>, <span class="emphasis"><em>fout</em></span> does not zero the audio variable so you must zero it after calling it. If polyphony is to be used, you can use <a class="link" href="vincr.html" title="vincr"><em class="citetitle">vincr</em></a> and <a class="link" href="clear.html" title="clear"><em class="citetitle">clear</em></a> opcodes for this task. </p> <p> Notice that <span class="emphasis"><em>fout</em></span> and <a class="link" href="foutk.html" title="foutk"><em class="citetitle">foutk</em></a> can use either a string containing a file pathname, or a handle-number generated by <a class="link" href="fiopen.html" title="fiopen"><em class="citetitle">fiopen</em></a>. Whereas, with <a class="link" href="fouti.html" title="fouti"><em class="citetitle">fouti</em></a> and <a class="link" href="foutir.html" title="foutir"><em class="citetitle">foutir</em></a>, the target file can be only specified by means of a handle-number. </p> <div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"> <table border="0" summary="Note"> <tr> <td rowspan="2" align="center" valign="top" width="25"> <img alt="[Note]" src="images/note.png" /> </td> <th align="left">Note</th> </tr> <tr> <td align="left" valign="top"> <p>If you are using <span class="emphasis"><em>fout</em></span> to generate an audio file for the global output of csound, you might want to use the <a class="link" href="monitor.html" title="monitor"><em class="citetitle">monitor</em></a> opcode, which can tap the output buffer, to avoid having to route </p> </td> </tr> </table> </div> </div> <div class="refsect1" title="Examples"> <a id="idp24206112"></a> <h2>Examples</h2> <p> Here is a simple example of the fout opcode. It uses the file <a class="ulink" href="examples/fout.csd" target="_top"><em class="citetitle">fout.csd</em></a>. </p> <div class="example"> <a id="idp24207088"></a> <p class="title"> <strong>Example 290. Example of the fout opcode.</strong> </p> <div class="example-contents"> <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p> <pre class="programlisting"> <span class="csdtag"><CsoundSynthesizer></span> <span class="csdtag"><CsOptions></span> <span class="comment">; Select audio/midi flags here according to platform</span> -odac <span class="comment">;;;realtime audio out</span> <span class="comment">;-iadc ;;;uncomment -iadc if realtime audio input is needed too</span> <span class="comment">; For Non-realtime ouput leave only the line below:</span> <span class="comment">; -o fout.wav -W ;;; for file output any platform</span> <span class="csdtag"></CsOptions></span> <span class="csdtag"><CsInstruments></span> <span class="ohdr">sr</span> <span class="op">=</span> 44100 <span class="ohdr">ksmps</span> <span class="op">=</span> 32 <span class="ohdr">nchnls</span> <span class="op">=</span> 2 <span class="ohdr">0dbfs</span> <span class="op">=</span> 1 giSine <span class="ohdr">ftgen</span> 0, 0, 2^10, 10, 1 <span class="oblock">instr</span> 1 asig <span class="opc">poscil3</span> .5, 880, giSine <span class="comment">;write a raw file: 32 bits with header</span> <span class="opc">fout</span> "fout_880.wav", 15, asig <span class="opc">outs</span> asig, asig <span class="oblock">endin</span> <span class="oblock">instr</span> 2 klfo <span class="opc">lfo</span> 1, 2, 0 asig <span class="opc">poscil3</span> .5<span class="op">*</span>klfo, 220, giSine <span class="comment">;write an aiff file: 32 bits with header</span> <span class="opc">fout</span> "fout_aif.aiff", 25, asig <span class="comment">; fout "fout_all3.wav", 14, asig</span> <span class="opc">outs</span> asig, asig <span class="oblock">endin</span> <span class="oblock">instr</span> 99 <span class="comment">;read the stereo csound output buffer</span> allL, allR <span class="opc">monitor</span> <span class="comment">;write the output of csound to an audio file</span> <span class="comment">;to a wav file: 16 bits with header</span> <span class="opc">fout</span> "fout_all.wav", 14, allL, allR <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="stamnt">i</span> 1 0 2 <span class="stamnt">i</span> 2 0 3 <span class="stamnt">i</span> 99 0 3 <span class="stamnt">e</span> <span class="csdtag"></CsScore></span> <span class="csdtag"></CsoundSynthesizer></span> </pre> </div> </div> <p><br class="example-break" /> </p> <p> Here is another example of <span class="emphasis"><em>fout</em></span>, using it to save the contents of a table to an audio file. It uses the file <a class="ulink" href="examples/fout_ftable.csd" target="_top"><em class="citetitle">fout_ftable.csd</em></a> and <a class="ulink" href="examples/beats.wav" target="_top"><em class="citetitle">beats.wav</em></a>. </p> <div class="example"> <a id="idp24210592"></a> <p class="title"> <strong>Example 291. Example of the fout opcode to save the contents of an f-table.</strong> </p> <div class="example-contents"> <pre class="programlisting"> <span class="csdtag"><CsoundSynthesizer></span> <span class="csdtag"><CsOptions></span> <span class="comment">; Select audio/midi flags here according to platform</span> <span class="comment">; Audio out Audio in No messages</span> -odac -iadc -d <span class="comment">;;;RT audio I/O</span> <span class="comment">; For Non-realtime ouput leave only the line below:</span> <span class="comment">; -o fout_ftable.wav -W ;;; for file output any platform</span> <span class="csdtag"></CsOptions></span> <span class="csdtag"><CsInstruments></span> <span class="comment">; By: Jonathan Murphy 2007</span> gilen <span class="op">=</span> 131072 gicps <span class="op">=</span> <span class="ohdr">sr</span><span class="op">/</span>gilen gitab <span class="ohdr">ftgen</span> 1, 0, gilen, 10, 1 <span class="oblock">instr</span> 1 <span class="op">/</span><span class="op">*</span><span class="op">*</span><span class="op">*</span><span class="op">*</span><span class="op">*</span><span class="op">*</span><span class="op">*</span><span class="op">*</span> write file to <span class="opc">table</span> <span class="op">*</span><span class="op">*</span><span class="op">*</span><span class="op">*</span><span class="op">*</span><span class="op">*</span><span class="op">*</span><span class="op">*</span><span class="op">/</span> ain <span class="opc">diskin2</span> "beats.wav", 1, 0, 1 aphs <span class="opc">phasor</span> gicps andx <span class="op">=</span> aphs <span class="op">*</span> gilen <span class="opc">tablew</span> ain, andx, gitab <span class="op">/</span><span class="op">*</span><span class="op">*</span><span class="op">*</span><span class="op">*</span><span class="op">*</span><span class="op">*</span><span class="op">*</span><span class="op">*</span> write <span class="opc">table</span> to file <span class="op">*</span><span class="op">*</span><span class="op">*</span><span class="op">*</span><span class="op">*</span><span class="op">*</span><span class="op">*</span><span class="op">*</span><span class="op">/</span> aosc <span class="opc">table</span> aphs, gitab, 1 <span class="opc">out</span> aosc <span class="opc">fout</span> "beats_copy.wav", 6, aosc <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="stamnt">i</span>1 0 2 <span class="stamnt">e</span> <span class="csdtag"></CsScore></span> <span class="csdtag"></CsoundSynthesizer></span> </pre> </div> </div> <p><br class="example-break" /> </p> </div> <div class="refsect1" title="See Also"> <a id="idp24211640"></a> <h2>See Also</h2> <p> <a class="link" href="fiopen.html" title="fiopen"><em class="citetitle">fiopen</em></a>, <a class="link" href="fouti.html" title="fouti"><em class="citetitle">fouti</em></a>, <a class="link" href="foutir.html" title="foutir"><em class="citetitle">foutir</em></a>, <a class="link" href="foutk.html" title="foutk"><em class="citetitle">foutk</em></a>, <a class="link" href="monitor.html" title="monitor"><em class="citetitle">monitor</em></a> </p> </div> <div class="refsect1" title="Credits"> <a id="idp24214576"></a> <h2>Credits</h2> <p> </p> <table border="0" summary="Simple list" class="simplelist"> <tr> <td>Author: Gabriel Maldonado</td> </tr> <tr> <td>Italy</td> </tr> <tr> <td>1999</td> </tr> </table> <p> </p> <p>New in Csound version 3.56</p> <p>October 2002. Added a note from Richard Dobson.</p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="foscili.html">Prev</a> </td> <td width="20%" align="center"> <a accesskey="u" href="OpcodesTop.html">Up</a> </td> <td width="40%" align="right"> <a accesskey="n" href="fouti.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">foscili </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> fouti</td> </tr> </table> </div> </body> </html>