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-modern.csd.
<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 Rogozinskysr=44100kr=4410ksmps=10nchnls=10dbfs=1; Cellular automaton-driven synthesis in spectral domaininstr1att:i=p4; envelope attack timesus:i=p5; envelope sustain timerel:i=p6; envelope release timevol:i=p7; overall volume; create some white noisesig:a=rand(0.8); spectral analysis of sigfsig=pvsanal(sig,2048,1024,2048,0); get a vector of magnitudes; calculate cellular automaton statefreq:k=line(50,5,1); variable CA triggering frequencytrig:k=metro(freq); trigger the CA to update cellscell(trig,0,3,1,2,2048); cells are written into ftable 3 ; use current row of cells in spectral domainmask:f=pvstencil(fsig,0,1,3); apply spectral maskaout=pvsynth(mask); reconstruct time signal; apply envelope and out signalenv:k=expseg(0.001,att,1,sus,1,rel,0.001)out(aout*env*vol)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 sophisticatedf102048701500011100450011100; 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.htmlf208-210000001; 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 sizef302048100; Time to make it sound!i10130.3731e</CsScore></CsoundSynthesizer>
Here is a simple example of the cell opcode. It uses the file
cell.csd.
<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 Rogozinskysr=44100kr=4410ksmps=10nchnls=10dbfs=1; Cellular automaton-driven synthesis in spectral domaininstr1iatt=p4; envelope attack timeisus=p5; envelope sustain timeirel=p6; envelope release timeivol=p7; overall volume; create some white noiseasigrand0.8; spectral analysis of asigfsigpvsanalasig,2048,1024,2048,0; get a vector of magnitudes; calculate cellular automaton statekfreqline50,5,1; variable CA triggering frequencyktrigmetrokfreq; trigger the CA to update cellscellktrig,0,3,1,2,2048; cells are written into ftable 3 ; use current row of cells in spectral domainfmaspvstencilfsig,0,1,3; apply spectral mask aoutpvsynthfmas; reconstruct time signal ; apply envelope and out signalkenvexpseg.001,iatt,1,isus,1,irel,.001outaout*kenv*ivolendin</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 sophisticatedf102048701500011100450011100; 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.htmlf208-210000001; 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 sizef302048100; Time to make it sound!i10130.3731e</CsScore></CsoundSynthesizer>