<?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>fiopen</title> <link rel="stylesheet" type="text/css" href="csound.css" /> <link rel="stylesheet" type="text/css" href="syntax-highlighting.css" /> <meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /> <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="fink.html" title="fink" /> <link rel="next" href="flanger.html" title="flanger" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">fiopen</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="fink.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="flanger.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry"> <a id="fiopen"></a> <div class="titlepage"></div> <a id="IndexFiopen" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">fiopen</span> </h2> <p>fiopen — Opens a file in a specific mode. </p> </div> <div class="refsect1"> <a id="idm281472937207080"></a> <h2>Description</h2> <p> <span class="emphasis"><em>fiopen</em></span> can be used to open a file in one of the specified modes. </p> </div> <div class="refsect1"> <a id="idm281472937127880"></a> <h2>Syntax</h2> <pre class="synopsis">ihandle <span class="command"><strong>fiopen</strong></span> ifilename, imode</pre> </div> <div class="refsect1"> <a id="idm281472937125768"></a> <h2>Initialization</h2> <p> <span class="emphasis"><em>ihandle</em></span> -- a number which specifies this file. </p> <p> <span class="emphasis"><em>ifilename</em></span> -- the target file's name (in double-quotes). </p> <p> <span class="emphasis"><em>imode</em></span> -- choose the mode of opening the file. <span class="emphasis"><em>imode</em></span> can be a value chosen among the following: </p> <div class="itemizedlist"> <ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> <p>0 - open a text file for writing</p> </li> <li class="listitem"> <p>1 - open a text file for reading</p> </li> <li class="listitem"> <p>2 - open a binary file for writing</p> </li> <li class="listitem"> <p>3 - open a binary file for reading</p> </li> </ul> </div> <p> </p> </div> <div class="refsect1"> <a id="idm281472937118296"></a> <h2>Performance</h2> <p> <span class="emphasis"><em>fiopen</em></span> opens a file to be used by the <a class="link" href="fout.html" title="fout"><em class="citetitle">fout</em></a> family of opcodes. It is safer to use it in the header section, external to any instruments. It returns a number, <span class="emphasis"><em>ihandle</em></span>, which unequivocally refers to the opened file. </p> <p> If <span class="emphasis"><em>fiopen</em></span> is called on an already open file, it just returns the same handle again, and does not close the file. </p> <p> Notice that <a class="link" href="fout.html" title="fout"><em class="citetitle">fout</em></a> 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 <span class="emphasis"><em>fiopen</em></span>. 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> <div class="refsect1"> <a id="idm281472937109416"></a> <h2>Examples</h2> <p> Here is an example of the fiopen opcode. It uses the file <a class="ulink" href="examples/fiopen.csd" target="_top"><em class="citetitle">fiopen.csd</em></a>. Note that the example must be run from a directory for which the user has write access. </p> <div class="example"> <a id="idm281472937107464"></a> <p class="title"> <strong>Example 281. Example of the fiopen 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> <div class="refsect1"> <a id="idm281472769627176"></a> <pre class="programlisting"> <span class="nt"><CsoundSynthesizer></span> <span class="nt"><CsOptions></span> <span class="c1">; Select audio/midi flags here according to platform</span> -odac <span class="c1">;;;realtime audio out</span> <span class="c1">;-iadc ;;;uncomment -iadc if realtime audio input is needed too</span> <span class="c1">; For Non-realtime ouput leave only the line below:</span> <span class="c1">; -o fiopen.wav -W ;;; for file output any platform</span> <span class="nt"></CsOptions></span> <span class="nt"><CsInstruments></span> <span class="vg">sr</span> <span class="o">=</span> <span class="mi">44100</span> <span class="vg">ksmps</span> <span class="o">=</span> <span class="mi">32</span> <span class="vg">nchnls</span> <span class="o">=</span> <span class="mi">2</span> <span class="vg">0dbfs</span> <span class="o">=</span> <span class="mi">1</span> gi<span class="n">hand</span> <span class="nb">fiopen</span> <span class="s">"test1.txt"</span><span class="p">,</span> <span class="mi">0</span> <span class="kd">instr</span> <span class="nf">1</span> i<span class="n">res</span> <span class="nb">random</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">100</span> <span class="nb">fouti</span> gi<span class="n">hand</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> i<span class="n">res</span> <span class="nb">ficlose</span> gi<span class="n">hand</span> <span class="kd">endin</span> <span class="nt"></CsInstruments></span> <span class="nt"><CsScore></span> <span class="nb">i</span> <span class="mi">1</span> <span class="mi">0</span> <span class="mi">1</span> <span class="nb">e</span> <span class="nt"></CsScore></span> <span class="nt"></CsoundSynthesizer></span> </pre> </div> </div> </div> <p><br class="example-break" /> </p> </div> <div class="refsect1"> <a id="idm281472937103176"></a> <h2>See Also</h2> <p> <a class="link" href="ficlose.html" title="ficlose"><em class="citetitle">ficlose</em></a> <a class="link" href="fout.html" title="fout"><em class="citetitle">fout</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> </p> </div> <div class="refsect1"> <a id="idm281472937097320"></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> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="fink.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="flanger.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">fink </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> flanger</td> </tr> </table> </div> </body> </html>