cell
Prev | Orchestra Opcodes and Operators | Next

## cell

cell — Cellular Automaton

## Description

One-Dimensional Cellular Automaton. This opcode is the modified version of vcella by Gabriel Maldonado.

## Syntax

    cell ktrig, kreinit, ioutFunc, initStateFunc, iRuleFunc, ielements

## Initialization

ioutFunc -- number of the table where the state of each cell is stored.

initStateFunc -- number of the table containing the inital states of cells.

iRuleFunc -- number of a lookup table containing the 8-bit rule.

ielements -- total number of cells in a row.

## Performance

ktri -- trigger signal. Each time it is non-zero, a new generation of cells is evaluated.

kreinit -- reset signal. Each time it is non-zero, state of all cells is forced to be that of initStateFunc.

cell models a classical 1D cellular automaton and stores the state of each cell in the table identified by ioutFunc.

initStateFunc is an input vector containing the inital value of the row of cells, while iRuleFunc is an input vector containing the chosen rule in the binary form (least significant bit first).

A new generation of cells is evaluated each time ktrig contains a non-zero value. Also the status of all cells can be forced to assume the status corresponding to the contents of initStateFunc each time kreinit contains a non-zero value.

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.

## Examples

Here is a simple example of the cell opcode. It uses the file cell.csd.

Example 94. A simple example of the cell opcode.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    ;-odac           -iadc     ;;;RT audio I/O
    ; For Non-realtime ouput leave only the line below:
    ; -o cell.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>
    ; cell.csd by Gleb Rogozinsky

    sr        = 44100
    kr        = 4410
    ksmps     = 10
    nchnls    = 1
    0dbfs     = 1

    ; Cellular automaton-driven synthesis in spectral domain
    instr 1

      iatt      = p4                                ; envelope attack time
      isus      = p5                                ; envelope sustain time
      irel      = p6                                ; envelope release time
      ivol      = p7                                ; overall volume

      ; create some white noise
      asig      rand      0.8

      ; spectral analysis of asig
      fsig      pvsanal   asig, 2048, 1024, 2048, 0  ; get a vector of magnitudes

      ; calculate cellular automaton state
      kfreq     line      50, 5, 1                  ; variable CA triggering frequency
      ktrig     metro     kfreq                     ; trigger the CA to update cells
                cell      ktrig, 0, 3, 1, 2, 2048   ; cells are written into ftable 3

      ; use current row of cells in spectral domain
      fmas      pvstencil fsig, 0, 1, 3             ; apply spectral mask
      aout      pvsynth   fmas                      ; reconstruct time signal

      ; apply envelope and out signal
      kenv      expseg    .001, iatt, 1, isus, 1, irel, .001
                out       aout*kenv*ivol
    endin

    </CsInstruments>
    <CsScore>

    ; This example uses one-dimensional cellular automaton
    ; to produce structures in spectral domain

    ; We have to prepare initial row of cells.
    ; One alive cell is enough to produce a simple fractal,
    ; so two alivee cells will make structure more sophisticated
    f1 0 2048 7 0 150 0 0 1 1 1 0 0 45 0 0 1 1 1 0 0

    ; The CA rule is used as follows:
    ; the states (values) of each cell are summed with their neighboring cells.
    ; Each sum is used as an index to read a next state of cell
    ; from the rule table.
    ; Let us try rule # 129 (LSB binary 1 0 0 0 0 0 0 1).
    ; This rule will produce a fractal structure for single active cell
    ; For more rules see http://mathworld.wolfram.com/ElementaryCellularAutomaton.html
    f2 0 8 -2 1 0 0 0 0 0 0 1
    ; 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)

    ; Prepare the output table of ielements size
    f3 0 2048 10 0

    ; Time to make it sound!
    i1 0  13  0.3  7  3  1
    e

    </CsScore>
    </CsoundSynthesizer>

## Credits

Author: Gleb Rogozinsky
October 2011

New in Csound version 5.16.6

Prev | Up | Next
ceil | Home | cent