<?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>cell</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="ceil.html" title="ceil" /> <link rel="next" href="cent.html" title="cent" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">cell</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="ceil.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="cent.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry" title="cell"> <a id="cell"></a> <div class="titlepage"></div> <a id="IndexCell" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">cell</span> </h2> <p>cell — Cellular Automaton </p> </div> <div class="refsect1" title="Description"> <a id="idp15295200"></a> <h2>Description</h2> <p> One-Dimensional Cellular Automaton. This opcode is the modified version of <span class="emphasis"><em>vcella</em></span> by Gabriel Maldonado. </p> </div> <div class="refsect1" title="Syntax"> <a id="idp15296128"></a> <h2>Syntax</h2> <pre class="synopsis"><span class="command"><strong>cell</strong></span> ktrig, kreinit, ioutFunc, initStateFunc, iRuleFunc, ielements</pre> </div> <div class="refsect1" title="Initialization"> <a id="idp15306528"></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 the table containing the inital states of cells. </p> <p> <span class="emphasis"><em>iRuleFunc</em></span> -- number of a lookup table containing the 8-bit rule. </p> <p> <span class="emphasis"><em>ielements</em></span> -- total number of cells in a row. </p> </div> <div class="refsect1" title="Performance"> <a id="idp15308776"></a> <h2>Performance</h2> <p> <span class="emphasis"><em>ktri</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> -- reset signal. Each time it is non-zero, state of all cells is forced to be that of initStateFunc. </p> <p> <span class="emphasis"><em>cell</em></span> models a classical 1D cellular automaton and stores the state of each cell in the table identified by <span class="emphasis"><em>ioutFunc</em></span>. </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 chosen rule in the binary form (least significant bit first). </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> Note that each cell is supposed to be in one of two possible states (1 = "alive", 0 = "dead"), although fractional values should work too, because truncation is used. </p> </div> <div class="refsect1" title="Examples"> <a id="idp15344272"></a> <h2>Examples</h2> <p> Here is a simple example of the cell opcode. It uses the file <a class="ulink" href="examples/cell.csd" target="_top"><em class="citetitle">cell.csd</em></a>. </p> <div class="example"> <a id="idp15345248"></a> <p class="title"> <strong>Example 94. A simple example of the cell 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">;-odac -iadc ;;;RT audio I/O</span> <span class="comment">; For Non-realtime ouput leave only the line below:</span> <span class="comment">; -o cell.wav -W ;;; for file output any platform</span> <span class="csdtag"></CsOptions></span> <span class="csdtag"><CsInstruments></span> <span class="comment">; cell.csd by Gleb Rogozinsky</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="ohdr">0dbfs</span> <span class="op">=</span> 1 <span class="comment">; Cellular automaton-driven synthesis in spectral domain</span> <span class="oblock">instr</span> 1 iatt <span class="op">=</span> p4 <span class="comment">; envelope attack time</span> isus <span class="op">=</span> p5 <span class="comment">; envelope sustain time</span> irel <span class="op">=</span> p6 <span class="comment">; envelope release time</span> ivol <span class="op">=</span> p7 <span class="comment">; overall volume</span> <span class="comment">; create some white noise</span> asig <span class="opc">rand</span> 0.8 <span class="comment">; spectral analysis of asig</span> fsig <span class="opc">pvsanal</span> asig, 2048, 1024, 2048, 0 <span class="comment">; get a vector of magnitudes</span> <span class="comment">; calculate cellular automaton state</span> kfreq <span class="opc">line</span> 50, 5, 1 <span class="comment">; variable CA triggering frequency</span> ktrig <span class="opc">metro</span> kfreq <span class="comment">; trigger the CA to update cells</span> <span class="opc">cell</span> ktrig, 0, 3, 1, 2, 2048 <span class="comment">; cells are written into ftable 3 </span> <span class="comment">; use current row of cells in spectral domain</span> fmas <span class="opc">pvstencil</span> fsig, 0, 1, 3 <span class="comment">; apply spectral mask </span> aout <span class="opc">pvsynth</span> fmas <span class="comment">; reconstruct time signal </span> <span class="comment">; apply envelope and out signal</span> kenv <span class="opc">expseg</span> .001, iatt, 1, isus, 1, irel, .001 <span class="opc">out</span> aout<span class="op">*</span>kenv<span class="op">*</span>ivol <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="comment">; This example uses one-dimensional cellular automaton</span> <span class="comment">; to produce structures in spectral domain</span> <span class="comment">; We have to prepare initial row of cells.</span> <span class="comment">; One alive cell is enough to produce a simple fractal,</span> <span class="comment">; so two alivee cells will make structure more sophisticated</span> <span class="stamnt">f</span>1 0 2048 7 0 150 0 0 1 1 1 0 0 45 0 0 1 1 1 0 0 <span class="comment">; The CA rule is used as follows:</span> <span class="comment">; the states (values) of each cell are summed with their neighboring cells.</span> <span class="comment">; Each sum is used as an index to read a next state of cell</span> <span class="comment">; from the rule table.</span> <span class="comment">; Let us try rule # 129 (LSB binary 1 0 0 0 0 0 0 1).</span> <span class="comment">; This rule will produce a fractal structure for single active cell</span> <span class="comment">; For more rules see http://mathworld.wolfram.com/ElementaryCellularAutomaton.html</span> <span class="stamnt">f</span>2 0 8 -2 1 0 0 0 0 0 0 1 <span class="comment">; Try some different rules i.E. 254 (0 1 1 1 1 1 1 1) or 169 (1 0 0 1 0 1 0 1)</span> <span class="comment">; Prepare the output table of ielements size</span> <span class="stamnt">f</span>3 0 2048 10 0 <span class="comment">; Time to make it sound!</span> <span class="stamnt">i</span>1 0 13 0.3 7 3 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="idp15347528"></a> <h2>Credits</h2> <p> </p> <table border="0" summary="Simple list" class="simplelist"> <tr> <td>Author: Gleb Rogozinsky</td> </tr> <tr> <td>October 2011</td> </tr> </table> <p> </p> <p>New in Csound version 5.16.6</p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="ceil.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="cent.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">ceil </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> cent</td> </tr> </table> </div> </body> </html>