Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-release > by-pkgid > 5fcfcb7517038d1f44ab4e478e6e61fa > files > 2991

csound-doc-6.10.0-1.mga7.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>subinstr</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="strupperk.html" title="strupperk" />
    <link rel="next" href="subinstrinit.html" title="subinstrinit" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">subinstr</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="strupperk.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="subinstrinit.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="subinstr"></a>
      <div class="titlepage"></div>
      <a id="IndexSubinstr" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">subinstr</span>
        </h2>
        <p>subinstr — 
      Creates and runs a numbered instrument instance.
          </p>
      </div>
      <div class="refsect1">
        <a id="idm281472882906984"></a>
        <h2>Description</h2>
        <p>
      Creates an instance of another instrument and is used as if it were an opcode.
    </p>
      </div>
      <div class="refsect1">
        <a id="idm281472882929064"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">a1, [...] [, a8] <span class="command"><strong>subinstr</strong></span> instrnum [, p4] [, p5] [...]</pre>
        <pre class="synopsis">a1, [...] [, a8] <span class="command"><strong>subinstr</strong></span> "insname" [, p4] [, p5] [...]</pre>
      </div>
      <div class="refsect1">
        <a id="idm281472882878728"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>instrnum</em></span> -- Number of the instrument to be called.
    </p>
        <p>
      <span class="emphasis"><em><span class="quote">“<span class="quote">insname</span>”</span></em></span> -- A string (in double-quotes) representing a named instrument.
    </p>
      </div>
      <div class="refsect1">
        <a id="idm281472882875896"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>a1, ..., a8</em></span> --  The audio output from the called instrument. This is generated using the <a class="link" href="SigioOutput.html" title="Signal Output"><em class="citetitle">signal output</em></a> opcodes.
    </p>
        <p>
      <span class="emphasis"><em>p4, p5, ...</em></span> -- Additional input values the are mapped to the called instrument p-fields, starting with p4.
    </p>
        <p>
      The called instrument's p2 and p3 values will be identical to the host instrument's values. While the host instrument can <a class="link" href="ControlDurctl.html" title="Duration Control Statements"><em class="citetitle">control its own duration</em></a>, any such attempts inside the called instrument will most likely have no effect.
    </p>
      </div>
      <div class="refsect1">
        <a id="idm281472882870456"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="event.html" title="event"><em class="citetitle">event</em></a>, 
      <a class="link" href="schedule.html" title="schedule"><em class="citetitle">schedule</em></a>,
      <a class="link" href="subinstrinit.html" title="subinstrinit"><em class="citetitle">subinstrinit</em></a>
     </p>
      </div>
      <div class="refsect1">
        <a id="idm281472882866392"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the subinstr opcode. It uses the file <a class="ulink" href="examples/subinstr.csd" target="_top"><em class="citetitle">subinstr.csd</em></a>.

      </p>
        <div class="example">
          <a id="idm281472882864616"></a>
          <p class="title">
            <strong>Example 962. Example of the subinstr 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="idm281472704371384"></a>
              <pre class="programlisting">
<span class="nt">&lt;CsoundSynthesizer&gt;</span>
<span class="nt">&lt;CsOptions&gt;</span>
<span class="c1">; Select audio/midi flags here according to platform</span>
<span class="c1">; Audio out   Audio in</span>
-odac           -iadc    <span class="c1">;;;RT audio I/O</span>
<span class="c1">; For Non-realtime ouput leave only the line below:</span>
<span class="c1">; -o subinstr.wav -W ;;; for file output any platform</span>
<span class="nt">&lt;/CsOptions&gt;</span>
<span class="nt">&lt;CsInstruments&gt;</span>

<span class="c1">; Initialize the global variables.</span>
<span class="vg">sr</span> <span class="o">=</span> <span class="mi">44100</span>
<span class="vg">kr</span> <span class="o">=</span> <span class="mi">4410</span>
<span class="vg">ksmps</span> <span class="o">=</span> <span class="mi">10</span>
<span class="vg">nchnls</span> <span class="o">=</span> <span class="mi">1</span>

<span class="c1">; Instrument #1 - Creates a basic tone.</span>
<span class="kd">instr</span> <span class="nf">1</span>
  <span class="c1">; Print the value of p4, should be equal to</span>
  <span class="c1">; Instrument #2's iamp field.</span>
  <span class="nb">print</span> <span class="nb">p4</span>

  <span class="c1">; Print the value of p5, should be equal to</span>
  <span class="c1">; Instrument #2's ipitch field.</span>
  <span class="nb">print</span> <span class="nb">p5</span>

  <span class="c1">; Create a tone.</span>
  a<span class="n">sig</span> <span class="nb">oscils</span> <span class="nb">p4</span><span class="p">,</span> <span class="nb">p5</span><span class="p">,</span> <span class="mi">0</span>

  <span class="nb">out</span> a<span class="n">sig</span>
<span class="kd">endin</span>


<span class="c1">; Instrument #2 - Demonstrates the subinstr opcode.</span>
<span class="kd">instr</span> <span class="nf">2</span>
  i<span class="n">amp</span> <span class="o">=</span> <span class="mi">20000</span>
  i<span class="n">pitch</span> <span class="o">=</span> <span class="mi">440</span>

  <span class="c1">; Use Instrument #1 to create a basic sine-wave tone.</span>
  <span class="c1">; Its p4 parameter will be set using the iamp variable.</span>
  <span class="c1">; Its p5 parameter will be set using the ipitch variable.</span>
  a<span class="n">basic</span> <span class="nb">subinstr</span> <span class="mi">1</span><span class="p">,</span> i<span class="n">amp</span><span class="p">,</span> i<span class="n">pitch</span>

  <span class="c1">; Output the basic tone that we have created.</span>
  <span class="nb">out</span> a<span class="n">basic</span>
<span class="kd">endin</span>


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

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

<span class="c1">; Play Instrument #2 for one second.</span>
<span class="nb">i</span> <span class="mi">2</span> <span class="mi">0</span> <span class="mi">1</span>
<span class="nb">e</span>


<span class="nt">&lt;/CsScore&gt;</span>
<span class="nt">&lt;/CsoundSynthesizer&gt;</span>
</pre>
            </div>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
        <p>
      Here is an example of the subinstr opcode using a named instrument. It uses the file <a class="ulink" href="examples/subinstr_named.csd" target="_top"><em class="citetitle">subinstr_named.csd</em></a>.

      </p>
        <div class="example">
          <a id="idm281472882859224"></a>
          <p class="title">
            <strong>Example 963. Example of the subinstr opcode using a named instrument.</strong>
          </p>
          <div class="example-contents">
            <div class="refsect1">
              <a id="idm281472704326632"></a>
              <pre class="programlisting">
<span class="nt">&lt;CsoundSynthesizer&gt;</span>
<span class="nt">&lt;CsOptions&gt;</span>
<span class="c1">; Select audio/midi flags here according to platform</span>
<span class="c1">; Audio out   Audio in</span>
-odac           -iadc    <span class="c1">;;;RT audio I/O</span>
<span class="c1">; For Non-realtime ouput leave only the line below:</span>
<span class="c1">; -o subinstr_named.wav -W ;;; for file output any platform</span>
<span class="nt">&lt;/CsOptions&gt;</span>
<span class="nt">&lt;CsInstruments&gt;</span>

<span class="c1">; Initialize the global variables.</span>
<span class="vg">sr</span> <span class="o">=</span> <span class="mi">44100</span>
<span class="vg">kr</span> <span class="o">=</span> <span class="mi">4410</span>
<span class="vg">ksmps</span> <span class="o">=</span> <span class="mi">10</span>
<span class="vg">nchnls</span> <span class="o">=</span> <span class="mi">1</span>

<span class="c1">; Instrument "basic_tone" - Creates a basic tone.</span>
<span class="kd">instr</span> <span class="nf">basic_tone</span>
  <span class="c1">; Print the value of p4, should be equal to</span>
  <span class="c1">; Instrument #2's iamp field.</span>
  <span class="nb">print</span> <span class="nb">p4</span>

  <span class="c1">; Print the value of p5, should be equal to</span>
  <span class="c1">; Instrument #2's ipitch field.</span>
  <span class="nb">print</span> <span class="nb">p5</span>

  <span class="c1">; Create a tone.</span>
  a<span class="n">sig</span> <span class="nb">oscils</span> <span class="nb">p4</span><span class="p">,</span> <span class="nb">p5</span><span class="p">,</span> <span class="mi">0</span>

  <span class="nb">out</span> a<span class="n">sig</span>
<span class="kd">endin</span>


<span class="c1">; Instrument #1 - Demonstrates the subinstr opcode.</span>
<span class="kd">instr</span> <span class="nf">1</span>
  i<span class="n">amp</span> <span class="o">=</span> <span class="mi">20000</span>
  i<span class="n">pitch</span> <span class="o">=</span> <span class="mi">440</span>

  <span class="c1">; Use the "basic_tone" named instrument to create a </span>
  <span class="c1">; basic sine-wave tone.</span>
  <span class="c1">; Its p4 parameter will be set using the iamp variable.</span>
  <span class="c1">; Its p5 parameter will be set using the ipitch variable.</span>
  a<span class="n">basic</span> <span class="nb">subinstr</span> <span class="s">"basic_tone"</span><span class="p">,</span> i<span class="n">amp</span><span class="p">,</span> i<span class="n">pitch</span>

  <span class="c1">; Output the basic tone that we have created.</span>
  <span class="nb">out</span> a<span class="n">basic</span>
<span class="kd">endin</span>


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

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

<span class="c1">; Play Instrument #1 for one second.</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">&lt;/CsScore&gt;</span>
<span class="nt">&lt;/CsoundSynthesizer&gt;</span>
</pre>
            </div>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idm281472882857240"></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="strupperk.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="subinstrinit.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">strupperk </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> subinstrinit</td>
        </tr>
      </table>
    </div>
  </body>
</html>