Sophie

Sophie

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

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>vcella</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="vbapzmove.html" title="vbapzmove" />
    <link rel="next" href="vco.html" title="vco" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">vcella</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="vbapzmove.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="vco.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="vcella">
      <a id="vcella"></a>
      <div class="titlepage"></div>
      <a id="IndexVcella" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">vcella</span>
        </h2>
        <p>vcella — 
    Cellular Automata
      
    </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="idp50792984"></a>
        <h2>Description</h2>
        <p>
	Unidimensional Cellular Automata applied to Csound vectors
    </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="idp50845128"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>vcella</strong></span> ktrig, kreinit, ioutFunc, initStateFunc, \
      iRuleFunc, ielements, irulelen [, iradius]</pre>
      </div>
      <div class="refsect1" title="Initialization">
        <a id="idp50846336"></a>
        <h2>Initialization</h2>
        <p>
       <span class="emphasis"><em>ioutFunc</em></span> - number of the table where the state of each cell is stored
    </p>
        <p>
      <span class="emphasis"><em>initStateFunc</em></span>  - number of a table containig the inital states of each cell
    </p>
        <p>
      <span class="emphasis"><em>iRuleFunc</em></span> - number of a lookup table containing the rules
      </p>
        <p>
      <span class="emphasis"><em>ielements</em></span> - total number of cells
    </p>
        <p>
      <span class="emphasis"><em>irulelen</em></span>  - total number of rules
    </p>
        <p>
      <span class="emphasis"><em>iradius</em></span> (optional) - radius of Cellular Automata. At present time CA radius can be 1 or 2 (1 is the default)
    </p>
      </div>
      <div class="refsect1" title="Performance">
        <a id="idp50849936"></a>
        <h2>Performance</h2>
        <p>
       <span class="emphasis"><em>ktrig</em></span> - trigger signal. Each time it is non-zero, a new generation of cells is evaluated
    </p>
        <p>
      <span class="emphasis"><em>kreinit</em></span> - trigger signal. Each time it is non-zero, state of all cells is forced to be that of <span class="emphasis"><em>initStateFunc</em></span>.
    </p>
        <p>
      <span class="emphasis"><em>vcella</em></span> supports unidimensional cellular automata, where the state of each cell is stored in <span class="emphasis"><em>ioutFunc</em></span>. So <span class="emphasis"><em>ioutFunc</em></span> is a vector containing current state of each cell. This variant vector can be used together with any other vector-based opcode, such as
      <a class="link" href="adsynt.html" title="adsynt"><em class="citetitle">adsynt</em></a>,
      <a class="link" href="vmap.html" title="vmap"><em class="citetitle">vmap</em></a>,
      <a class="link" href="vpowv.html" title="vpowv"><em class="citetitle">vpowv</em></a> etc.
	</p>
        <p>
<span class="emphasis"><em>initStateFunc</em></span> is an input vector containing the inital value of the row of cells, while <span class="emphasis"><em>iRuleFunc</em></span> is an input vector containing the rules in the form of a lookup table. Notice that <span class="emphasis"><em>initStateFunc</em></span> and <span class="emphasis"><em>iRuleFunc</em></span> can be updated during the performance by means of other vector-based opcodes (for example <a class="link" href="vcopy.html" title="vcopy"><em class="citetitle">vcopy</em></a>) in order to force to change rules and status at performance time.
	</p>
        <p>
A new generation of cells is evaluated each time <span class="emphasis"><em>ktrig</em></span> contains a non-zero value. Also the status of all cells can be forced to assume the status corresponding to the contents of <span class="emphasis"><em>initStateFunc</em></span> each time <span class="emphasis"><em>kreinit</em></span> contains a non-zero value.
    </p>
        <p>
Radius of CA algorithm can be 1 or 2 (optional <span class="emphasis"><em>iradius</em></span> arguement). 
    </p>
      </div>
      <div class="refsect1" title="Examples">
        <a id="idp50857888"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the vcella opcode. It uses the file <a class="ulink" href="examples/vcella.csd" target="_top"><em class="citetitle">vcella.csd</em></a>.</p>
        <p>
      The following example uses <span class="emphasis"><em>vcella</em></span>
      </p>
        <div class="example">
          <a id="idp50859280"></a>
          <p class="title">
            <strong>Example 928. Example of the vcella 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>
<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 vcella.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">; vcella.csd</span>
<span class="comment">; by Anthony Kozar</span>

<span class="comment">; This file demonstrates some of the new opcodes available in</span>
<span class="comment">; Csound 5 that come from Gabriel Maldonado's CsoundAV.</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">; Cellular automata-driven oscillator bank using vcella and adsynt</span>
<span class="oblock">instr</span> 1
  idur      <span class="op">=</span> p3
  iCArate   <span class="op">=</span> p4                                <span class="comment">; number of times per second the CA calculates new values</span>
	
  <span class="comment">; f-tables for CA parameters</span>
  iCAinit   <span class="op">=</span> p5                                <span class="comment">; CA initial states					</span>
  iCArule   <span class="op">=</span> p6                                <span class="comment">; CA rule values</span>
  <span class="comment">; The rule is used as follows:</span>
  <span class="comment">; the states (values) of each cell are summed with their neighboring cells within</span>
  <span class="comment">; the specied radius (+/- 1 or 2 cells).  Each sum is used as an index to read a </span>
  <span class="comment">; value from the rule table which becomes the new state value for its cell.</span>
  <span class="comment">; All new states are calculated first, then the new values are all applied </span>
  <span class="comment">; simultaneously.</span>

  ielements <span class="op">=</span> <span class="opc">ftlen</span>(iCAinit)
  inumrules <span class="op">=</span> <span class="opc">ftlen</span>(iCArule)
  iradius   <span class="op">=</span> 1

  <span class="comment">; create some needed tables</span>
  iCAstate  <span class="ohdr">ftgen</span>     0, 0, ielements, <span class="op">-</span>2, 0    <span class="comment">; will hold the current CA states</span>
  ifreqs    <span class="ohdr">ftgen</span>     0, 0, ielements, <span class="op">-</span>2, 0    <span class="comment">; will hold the oscillator frequency for each cell</span>
  iamps     <span class="ohdr">ftgen</span>     0, 0, ielements, <span class="op">-</span>2, 0    <span class="comment">; will hold the amplitude for each cell</span>

  <span class="comment">; calculate cellular automata state</span>
  ktrig     <span class="opc">metro</span>     iCArate                   <span class="comment">; trigger the CA to update iCArate times per second</span>
            <span class="opc">vcella</span>    ktrig, 0, iCAstate, iCAinit, iCArule, ielements, inumrules, iradius

  <span class="comment">; scale CA state for use as amplitudes of the oscillator bank</span>
            <span class="opc">vcopy</span>     iamps, iCAstate, ielements
            <span class="opc">vmult</span>     iamps, (1<span class="op">/</span>3), ielements   <span class="comment">; divide by 3 since state values are 0-3</span>

            <span class="opc">vport</span>     iamps, .01, ielements     <span class="comment">; need to smooth the amplitude changes for adsynt</span>
  <span class="comment">; we could use adsynt2 instead of adsynt, but it does not seem to be working</span>

  <span class="comment">; i-time loop for calculating frequencies</span>
  index     <span class="op">=</span>         0
  inew      <span class="op">=</span>         1
  iratio    <span class="op">=</span>         1.125                     <span class="comment">; just major second (creating a whole tone scale)</span>
<span class="olabel">loop1</span><span class="op">:</span>
            <span class="opc">tableiw</span>   inew, index, ifreqs, 0    <span class="comment">; 0 indicates integer indices</span>
  inew      <span class="op">=</span>         inew <span class="op">*</span> iratio
  index     <span class="op">=</span>         index <span class="op">+</span> 1
  <span class="octrl">if</span> (index <span class="op">&lt;</span> ielements) <span class="octrl">igoto</span> <span class="olabel">loop1</span>

  <span class="comment">; create sound with additive oscillator bank</span>
  ifreqbase <span class="op">=</span> 64
  iwavefn   <span class="op">=</span> 1
  iphs      <span class="op">=</span> 2                                 <span class="comment">; random oscillator phases</span>

  kenv      <span class="opc">linseg</span>    0.0, 0.5, 1.0, idur <span class="op">-</span> 1.0, 1.0, 0.5, 0.0
  aosc      <span class="opc">adsynt</span>    kenv, ifreqbase, iwavefn, ifreqs, iamps, ielements, iphs

            <span class="opc">out</span>       aosc <span class="op">*</span> <span class="opc">ampdb</span>(68)
<span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">f</span>1 0 16384 10 1

<span class="comment">; This example uses a 4-state cellular automata</span>
<span class="comment">; Possible state values are 0, 1, 2, and 3</span>

<span class="comment">; CA initial state</span>
<span class="comment">; We have 16 cells in our CA, so the initial state table is size 16</span>
<span class="stamnt">f</span>10 0 16 -2  0 1 0 0  1 0 0 2  2 0 0 1  0 0 1 0

<span class="comment">; CA rule</span>
<span class="comment">; The maximum sum with radius 1 (3 cells) is 9, so we need 10 values in the rule (0-9)</span>
<span class="stamnt">f</span>11 0 16 -2  1 0 3 2 1  0 0 2 1 0

<span class="comment">; Here is our one and only note!</span>
<span class="stamnt">i</span>1 0  20  4  10  11

<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="idp50861552"></a>
        <h2>Credits</h2>
        <p>Written by: Gabriel Maldonado.</p>
        <p>New in Csound 5 (Previously available only on CsoundAV)</p>
        <p>Example by: Anthony Kozar</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="vbapzmove.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="vco.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">vbapzmove </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> vco</td>
        </tr>
      </table>
    </div>
  </body>
</html>