Sophie

Sophie

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

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>stack</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="sr.html" title="sr" />
    <link rel="next" href="statevar.html" title="statevar" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">stack</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="sr.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="statevar.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="stack">
      <a id="stack"></a>
      <div class="titlepage"></div>
      <a id="IndexStack" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">stack</span>
        </h2>
        <p>stack — 
      Initializes the stack.
    </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="idp45263416"></a>
        <h2>Description</h2>
        <p>
      Initializes and sets the size of the global stack.
    </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="idp45264080"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>stack</strong></span>  iStackSize</pre>
      </div>
      <div class="refsect1" title="Initialization">
        <a id="idp45317536"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>iStackSize</em></span>  - size of the stack in bytes.
    </p>
      </div>
      <div class="refsect1" title="Performance">
        <a id="idp45318352"></a>
        <h2>Performance</h2>
        <p>
      Csound implements a single global stack. Initializing the stack with the <span class="emphasis"><em>stack</em></span> opcode is not required - it is optional, and if not done, the first use of <a class="link" href="push.html" title="push"><em class="citetitle">push</em></a> or <a class="link" href="push_f.html" title="push_f"><em class="citetitle">push_f</em></a> will automatically create a stack of 32768 bytes. Otherwise, <span class="emphasis"><em>stack</em></span> is normally called from the orchestra header, and takes a stack size parameter in bytes (there is an upper limit of about 16 MB). Once set, the stack size is fixed and cannot be changed during performance.
    </p>
        <p>
      The global stack works in LIFO order: after multiple <a class="link" href="push.html" title="push"><em class="citetitle">push</em></a> calls, <a class="link" href="pop.html" title="pop"><em class="citetitle">pop</em></a> should be used in reverse order.
    </p>
        <p>
      Each <a class="link" href="push.html" title="push"><em class="citetitle">push</em></a> or <a class="link" href="pop.html" title="pop"><em class="citetitle">pop</em></a> operation can work on a "bundle" of multiple variables. When using <a class="link" href="pop.html" title="pop"><em class="citetitle">pop</em></a>, the number, type, and order of items must match those used by the corresponding <a class="link" href="push.html" title="push"><em class="citetitle">push</em></a>. That is, after a 'push Sfoo, ibar', you must call something like 'Sbar, ifoo pop', and not e.g. two separate 'pop' statements.
    </p>
        <p>
      <a class="link" href="push.html" title="push"><em class="citetitle">push</em></a> and <a class="link" href="pop.html" title="pop"><em class="citetitle">pop</em></a> opcodes can take variables of any type (i-, k-, a- and strings). Variables of type 'a' and 'k' are passed at performance time only, while 'i' and 'S' are passed at init time only.
    </p>
        <p>
      push/pop for a, k, i, and S types copy data by value. By contrast, <a class="link" href="push_f.html" title="push_f"><em class="citetitle">push_f</em></a> only pushes a "reference" to the f-signal, and then the corresponding <a class="link" href="pop_f.html" title="pop_f"><em class="citetitle">pop_f</em></a> will copy directly from the original variable to its output signal. For this reason, changing the source f-signal of <a class="link" href="push_f.html" title="push_f"><em class="citetitle">push_f</em></a> before <a class="link" href="pop_f.html" title="pop_f"><em class="citetitle">pop_f</em></a> is called is not recommended, and if the instrument instance owning the variable that was passed by push_f is deactivated before pop_f is called, undefined behavior may occur.
    </p>
        <p>
      Any stack errors (trying to push when there is no more space, or pop from an empty stack, inconsistent number or type of arguments, etc.) are fatal and terminate performance.
    </p>
      </div>
      <div class="refsect1" title="Examples">
        <a id="idp45328552"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the stack opcode. It uses the file <a class="ulink" href="examples/stack.csd" target="_top"><em class="citetitle">stack.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp45329520"></a>
          <p class="title">
            <strong>Example 795. Example of the stack 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 stack.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">0dbfs</span>  <span class="op">=</span> 1 
<span class="ohdr">nchnls</span> <span class="op">=</span> 2

<span class="opc">stack</span> 100000 

<span class="oblock">instr</span> 1 

a1	<span class="opc">oscils</span> 0.7, 220, 0 
k1	<span class="opc">line</span> 0, p3, 1 
        <span class="opc">push</span> "blah", 123.45, a1, k1 
        <span class="opc">push</span> <span class="opc">rnd</span>(k1) 

k_rnd	<span class="opc">pop</span> 
S01, i01, a01, k01 <span class="opc">pop</span> 
        <span class="opc">printf_i</span> "S01 <span class="op">=</span> '<span class="op">%</span>s', i01 <span class="op">=</span> <span class="op">%</span>g\n", 1, S01, i01 
ktrig	<span class="opc">metro</span> 5.0 
        <span class="opc">printf</span> "k01 <span class="op">=</span> <span class="op">%</span>.3f, k_rnd <span class="op">=</span> <span class="op">%</span>.3f\n", ktrig, k01, k_rnd 
        <span class="opc">outs</span> a01, a01 

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

<span class="stamnt">i</span> 1 0 5 
<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="idp45331792"></a>
        <h2>See also</h2>
        <p>
      <a class="link" href="pop.html" title="pop"><em class="citetitle">pop</em></a>,
      <a class="link" href="push.html" title="push"><em class="citetitle">push</em></a>,
      <a class="link" href="pop_f.html" title="pop_f"><em class="citetitle">pop_f</em></a> and 
      <a class="link" href="push_f.html" title="push_f"><em class="citetitle">push_f</em></a>.
    </p>
        <p>Using this opcode is somewhat hackish, as you can read here: <a class="ulink" href="http://csound.1045644.n5.nabble.com/passing-a-string-to-a-UDO-td1099284.html" target="_top">http://csound.1045644.n5.nabble.com/passing-a-string-to-a-UDO-td1099284.html</a></p>
      </div>
      <div class="refsect1" title="Credits">
        <a id="idp45334776"></a>
        <h2>Credits</h2>
        <p>By: Istvan Varga.</p>
        <p>2006</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="sr.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="statevar.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">sr </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> statevar</td>
        </tr>
      </table>
    </div>
  </body>
</html>