| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
; Select audio/midi flags here according to platform |
| 4 |
;-odac -iadc ;;;RT audio I/O |
| 5 |
; For Non-realtime ouput leave only the line below: |
| 6 |
; -o cell.wav -W ;;; for file output any platform |
| 7 |
</CsOptions> |
| 8 |
<CsInstruments> |
| 9 |
; cell.csd by Gleb Rogozinsky |
| 10 |
|
| 11 |
sr = 44100 |
| 12 |
kr = 4410 |
| 13 |
ksmps = 10 |
| 14 |
nchnls = 1 |
| 15 |
0dbfs = 1 |
| 16 |
|
| 17 |
; Cellular automaton-driven synthesis in spectral domain |
| 18 |
instr 1 |
| 19 |
|
| 20 |
iatt = p4 ; envelope attack time |
| 21 |
isus = p5 ; envelope sustain time |
| 22 |
irel = p6 ; envelope release time |
| 23 |
ivol = p7 ; overall volume |
| 24 |
|
| 25 |
; create some white noise |
| 26 |
asig rand 0.8 |
| 27 |
|
| 28 |
; spectral analysis of asig |
| 29 |
fsig pvsanal asig, 2048, 1024, 2048, 0 ; get a vector of magnitudes |
| 30 |
|
| 31 |
; calculate cellular automaton state |
| 32 |
kfreq line 50, 5, 1 ; variable CA triggering frequency |
| 33 |
ktrig metro kfreq ; trigger the CA to update cells |
| 34 |
cell ktrig, 0, 3, 1, 2, 2048 ; cells are written into ftable 3 |
| 35 |
|
| 36 |
|
| 37 |
; use current row of cells in spectral domain |
| 38 |
fmas pvstencil fsig, 0, 1, 3 ; apply spectral mask |
| 39 |
aout pvsynth fmas ; reconstruct time signal |
| 40 |
|
| 41 |
; apply envelope and out signal |
| 42 |
kenv expseg .001, iatt, 1, isus, 1, irel, .001 |
| 43 |
out aout*kenv*ivol |
| 44 |
endin |
| 45 |
|
| 46 |
</CsInstruments> |
| 47 |
<CsScore> |
| 48 |
|
| 49 |
; This example uses one-dimensional cellular automaton |
| 50 |
; to produce structures in spectral domain |
| 51 |
|
| 52 |
; We have to prepare initial row of cells. |
| 53 |
; One alive cell is enough to produce a simple fractal, |
| 54 |
; so two alivee cells will make structure more sophisticated |
| 55 |
f1 0 2048 7 0 150 0 0 1 1 1 0 0 45 0 0 1 1 1 0 0 |
| 56 |
|
| 57 |
; The CA rule is used as follows: |
| 58 |
; the states (values) of each cell are summed with their neighboring cells. |
| 59 |
; Each sum is used as an index to read a next state of cell |
| 60 |
; from the rule table. |
| 61 |
; Let us try rule # 129 (LSB binary 1 0 0 0 0 0 0 1). |
| 62 |
; This rule will produce a fractal structure for single active cell |
| 63 |
; For more rules see http://mathworld.wolfram.com/ElementaryCellularAutomaton.html |
| 64 |
f2 0 8 -2 1 0 0 0 0 0 0 1 |
| 65 |
; 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) |
| 66 |
|
| 67 |
; Prepare the output table of ielements size |
| 68 |
f3 0 2048 10 0 |
| 69 |
|
| 70 |
; Time to make it sound! |
| 71 |
i1 0 13 0.3 7 3 1 |
| 72 |
e |
| 73 |
|
| 74 |
</CsScore> |
| 75 |
</CsoundSynthesizer> |