Sophie

Sophie

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

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>r Statement (Repeat Statement)</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="ScoregensTop.html" title="Score Statements and GEN Routines" />
    <link rel="prev" href="q.html" title="q Statement" />
    <link rel="next" href="s.html" title="s Statement" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">r Statement (Repeat Statement)</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="q.html">Prev</a> </td>
          <th width="60%" align="center">Score Statements and GEN Routines</th>
          <td width="20%" align="right"> <a accesskey="n" href="s.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="r Statement (Repeat Statement)">
      <a id="r"></a>
      <div class="titlepage"></div>
      <a id="IndexRStatement" class="indexterm"></a>
      <a id="IndexRepeatStatement" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">r Statement (Repeat Statement)</span>
        </h2>
        <p>r — 
      Starts a repeated section.
    </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="idp76778448"></a>
        <h2>Description</h2>
        <p>
      Starts a repeated section, which lasts until the next <span class="emphasis"><em>s</em></span>, <span class="emphasis"><em>r</em></span> or <span class="emphasis"><em>e statement</em></span>.
    </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="idp76797968"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>r</strong></span> p1 p2</pre>
      </div>
      <div class="refsect1" title="Initialization">
        <a id="idp76798976"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>p1</em></span> -- Number of times to repeat the section.
    </p>
        <p>
      <span class="emphasis"><em>p2</em></span> -- Macro(name) to advance with each repetition (optional).
    </p>
      </div>
      <div class="refsect1" title="Performance">
        <a id="idp76800424"></a>
        <h2>Performance</h2>
        <p>
      In order that the sections may be more flexible than simple editing, the macro named p2 is given the value of 1 for the first time through the section, 2 for the second, and 3 for the third.  This can be used to change p-field parameters, or ignored.
    </p>
        <div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;">
          <table border="0" summary="Warning: Warning">
            <tr>
              <td rowspan="2" align="center" valign="top" width="25">
                <img alt="[Warning]" src="images/warning.png" />
              </td>
              <th align="left">Warning</th>
            </tr>
            <tr>
              <td align="left" valign="top">
                <p>
        Because of serious problems of interaction with macro expansion, sections must start and end in the same file, and not in a macro.
      </p>
              </td>
            </tr>
          </table>
        </div>
      </div>
      <div class="refsect1" title="Examples">
        <a id="idp76819976"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the r statement. It uses the file <a class="ulink" href="examples/r.csd" target="_top"><em class="citetitle">r.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp76820952"></a>
          <p class="title">
            <strong>Example 1029. Example of the r statement.</strong>
          </p>
          <div class="example-contents">
            <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>
<span class="comment">; Audio out   Audio in</span>
-odac           -iadc    <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 r.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="comment">; Initialize the global variables.</span>
<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">kr</span> <span class="op">=</span> 4410
<span class="ohdr">ksmps</span> <span class="op">=</span> 10
<span class="ohdr">nchnls</span> <span class="op">=</span> 1

<span class="comment">; Instrument #1.</span>
<span class="oblock">instr</span> 1
  <span class="comment">; The score's p4 parameter has the number of repeats.</span>
  kreps <span class="op">=</span> p4
  <span class="comment">; The score's p5 parameter has our note's frequency.</span>
  kcps <span class="op">=</span> p5
  
  <span class="comment">; Print the number of repeats.</span>
  <span class="opc">printks</span> "Repeated <span class="op">%</span><span class="opc">i</span> time(s).\\n", 1, kreps

  <span class="comment">; Generate a nice beep.</span>
  a1 <span class="opc">oscil</span> 20000, kcps, 1
  <span class="opc">out</span> 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">; We'll repeat this section 6 times. Each time it </span>
<span class="comment">; is repeated, its macro REPS_MACRO is incremented. </span>
<span class="stamnt">r</span>6 REPS_MACRO

<span class="comment">; Play Instrument #1.</span>
<span class="comment">; p4 = the r statement's macro, REPS_MACRO.</span>
<span class="comment">; p5 = the frequency in cycles per second.</span>
<span class="stamnt">i</span> 1 00.10 00.10 $REPS_MACRO 1760
<span class="stamnt">i</span> 1 00.30 00.10 $REPS_MACRO 880
<span class="stamnt">i</span> 1 00.50 00.10 $REPS_MACRO 440
<span class="stamnt">i</span> 1 00.70 00.10 $REPS_MACRO 220

<span class="comment">; Marks the end of the section.</span>
<span class="stamnt">s</span>

<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="Credits">
        <a id="idp76821936"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: John ffitch</td>
          </tr>
          <tr>
            <td>University of Bath/Codemist Ltd.</td>
          </tr>
          <tr>
            <td>Bath, UK</td>
          </tr>
          <tr>
            <td>April, 1998</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in Csound version 3.48</p>
        <p>Example written by Kevin Conder</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="q.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="ScoregensTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="s.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">q Statement </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> s Statement</td>
        </tr>
      </table>
    </div>
  </body>
</html>