Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-release > by-pkgid > b707d9a4ee443103660a75ccb6e51334 > files > 565

csound-doc-5.19.01-10.mga5.noarch.rpm

<?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>endif</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="elseif.html" title="elseif" />
    <link rel="next" href="endin.html" title="endin" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">endif</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="elseif.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="endin.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="endif">
      <a id="endif"></a>
      <div class="titlepage"></div>
      <a id="IndexEndif" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">endif</span>
        </h2>
        <p>endif — 
      Closes a block of code that begins with an "if...then" statement.
          </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="idp19114840"></a>
        <h2>Description</h2>
        <p>
      Closes a block of code that begins with an <a class="link" href="if.html" title="if"><em class="citetitle">"if...then"</em></a> statement.
    </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="idp19115912"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">
          <span class="command">
            <strong>endif</strong>
          </span>
        </pre>
      </div>
      <div class="refsect1" title="Performance">
        <a id="idp19126184"></a>
        <h2>Performance</h2>
        <p>
      Any block of code that begins with an <a class="link" href="if.html" title="if"><em class="citetitle">"if...then"</em></a> statement must end with an <span class="emphasis"><em>endif</em></span> statement.
    </p>
      </div>
      <div class="refsect1" title="Examples">
        <a id="idp19127536"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the endif opcode. It uses the file <a class="ulink" href="examples/endif.csd" target="_top"><em class="citetitle">endif.csd</em></a>.
            </p>
        <div class="example">
          <a id="idp19204872"></a>
          <p class="title">
            <strong>Example 203. Example of the endif 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">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</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 endif.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</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

<span class="oblock">instr</span> 1
  <span class="comment">; Get the note value from the fourth p-field.</span>
  knote <span class="op">=</span> p4

  <span class="comment">; Does the user want a low note?</span>
  <span class="octrl">if</span> (knote <span class="op">==</span> 0) then
    kcps <span class="op">=</span> 220
  <span class="comment">; Does the user want a middle note?</span>
  <span class="octrl">elseif</span> (knote <span class="op">==</span> 1) then
    kcps <span class="op">=</span> 440
  <span class="comment">; Does the user want a high note?</span>
  <span class="octrl">elseif</span> (knote <span class="op">==</span> 2) then
    kcps <span class="op">=</span> 880
  <span class="octrl">endif</span>

  <span class="comment">; Create the note.</span>
  kamp <span class="opc">init</span> .8
  ifn <span class="op">=</span> 1
  a1 <span class="opc">oscili</span> kamp, kcps, ifn

  <span class="opc">outs</span> a1, a1
<span class="oblock">endin</span>


<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="comment">; Table #1, a sine wave.</span>
<span class="stamnt">f</span> 1 0 16384 10 1

<span class="comment">; p4: 0=low note, 1=middle note, 2=high note.</span>
<span class="comment">; Play Instrument #1 for one second, low note.</span>
<span class="stamnt">i</span> 1 0 1 0
<span class="comment">; Play Instrument #1 for one second, middle note.</span>
<span class="stamnt">i</span> 1 1 1 1
<span class="comment">; Play Instrument #1 for one second, high note.</span>
<span class="stamnt">i</span> 1 2 1 2
<span class="stamnt">e</span>


<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1" title="See Also">
        <a id="idp19206760"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="elseif.html" title="elseif"><em class="citetitle">elseif</em></a>,
      <a class="link" href="else.html" title="else"><em class="citetitle">else</em></a>,
      <a class="link" href="goto.html" title="goto"><em class="citetitle">goto</em></a>,
      <a class="link" href="if.html" title="if"><em class="citetitle">if</em></a>,
      <a class="link" href="igoto.html" title="igoto"><em class="citetitle">igoto</em></a>,
      <a class="link" href="kgoto.html" title="kgoto"><em class="citetitle">kgoto</em></a>,
      <a class="link" href="tigoto.html" title="tigoto"><em class="citetitle">tigoto</em></a>,
      <a class="link" href="timout.html" title="timout"><em class="citetitle">timout</em></a>
    </p>
        <p> More information on this opcode: <a class="ulink" href="http://www.csounds.com/journal/2006spring/controlFlow.html" target="_top"><em class="citetitle">http://www.csounds.com/journal/2006spring/controlFlow.html</em></a>  , written by Steven Yi </p>
      </div>
      <div class="refsect1" title="Credits">
        <a id="idp19211080"></a>
        <h2>Credits</h2>
        <p>New in version 4.21</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="elseif.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="endin.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">elseif </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> endin</td>
        </tr>
      </table>
    </div>
  </body>
</html>