<?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" /> <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="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" title="subinstr"> <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" title="Description"> <a id="idp46490360"></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" title="Syntax"> <a id="idp46491160"></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" title="Initialization"> <a id="idp46748480"></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> <p> For more information about specifying input and output interfaces, see <a class="link" href="instr.html#InstrSubinstrument" title="Calling an Instrument within an Instrument"><em class="citetitle">Calling an Instrument within an Instrument</em></a>. </p> </div> <div class="refsect1" title="Performance"> <a id="idp46750952"></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" title="See Also"> <a id="idp46754080"></a> <h2>See Also</h2> <p> <a class="link" href="instr.html#InstrSubinstrument" title="Calling an Instrument within an Instrument"><em class="citetitle">Calling an Instrument within an Instrument</em></a>, <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" title="Examples"> <a id="idp46756664"></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="idp46757656"></a> <p class="title"> <strong>Example 836. 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> <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</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 subinstr.wav -W ;;; for file output any platform</span> <span class="csdtag"></CsOptions></span> <span class="csdtag"><CsInstruments></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 - Creates a basic tone.</span> <span class="oblock">instr</span> 1 <span class="comment">; Print the value of p4, should be equal to</span> <span class="comment">; Instrument #2's iamp field.</span> <span class="opc">print</span> p4 <span class="comment">; Print the value of p5, should be equal to</span> <span class="comment">; Instrument #2's ipitch field.</span> <span class="opc">print</span> p5 <span class="comment">; Create a tone.</span> asig <span class="opc">oscils</span> p4, p5, 0 <span class="opc">out</span> asig <span class="oblock">endin</span> <span class="comment">; Instrument #2 - Demonstrates the subinstr opcode.</span> <span class="oblock">instr</span> 2 iamp <span class="op">=</span> 20000 ipitch <span class="op">=</span> 440 <span class="comment">; Use Instrument #1 to create a basic sine-wave tone.</span> <span class="comment">; Its p4 parameter will be set using the iamp variable.</span> <span class="comment">; Its p5 parameter will be set using the ipitch variable.</span> abasic <span class="opc">subinstr</span> 1, iamp, ipitch <span class="comment">; Output the basic tone that we have created.</span> <span class="opc">out</span> abasic <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="comment">; Table #1, a sine wave.</span> <span class="stamnt">f</span> 1 0 16384 10 1 <span class="comment">; Play Instrument #2 for one second.</span> <span class="stamnt">i</span> 2 0 1 <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 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="idp46760568"></a> <p class="title"> <strong>Example 837. Example of the subinstr opcode using a named instrument.</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</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 subinstr_named.wav -W ;;; for file output any platform</span> <span class="csdtag"></CsOptions></span> <span class="csdtag"><CsInstruments></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 "basic_tone" - Creates a basic tone.</span> <span class="oblock">instr</span> basic_tone <span class="comment">; Print the value of p4, should be equal to</span> <span class="comment">; Instrument #2's iamp field.</span> <span class="opc">print</span> p4 <span class="comment">; Print the value of p5, should be equal to</span> <span class="comment">; Instrument #2's ipitch field.</span> <span class="opc">print</span> p5 <span class="comment">; Create a tone.</span> asig <span class="opc">oscils</span> p4, p5, 0 <span class="opc">out</span> asig <span class="oblock">endin</span> <span class="comment">; Instrument #1 - Demonstrates the subinstr opcode.</span> <span class="oblock">instr</span> 1 iamp <span class="op">=</span> 20000 ipitch <span class="op">=</span> 440 <span class="comment">; Use the "basic_tone" named instrument to create a </span> <span class="comment">; basic sine-wave tone.</span> <span class="comment">; Its p4 parameter will be set using the iamp variable.</span> <span class="comment">; Its p5 parameter will be set using the ipitch variable.</span> abasic <span class="opc">subinstr</span> "basic_tone", iamp, ipitch <span class="comment">; Output the basic tone that we have created.</span> <span class="opc">out</span> abasic <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="comment">; Table #1, a sine wave.</span> <span class="stamnt">f</span> 1 0 16384 10 1 <span class="comment">; Play Instrument #1 for one second.</span> <span class="stamnt">i</span> 1 0 1 <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="Credits"> <a id="idp46761632"></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>