sterrain

sterrain — A wave-terrain synthesis opcode using curves computed with the superformula

Description

A wave-terrain synthesis opcode using curves computed with the superformula (see Wikipedia for more information).

Syntax

aout sterrain kamp, kcps, kx, ky, krx, kry, krot, ktab0, ktab1, km1, km2, kn1, kn2, kn3, ka, kb, kperiod
    

Performance

ktabx, ktaby -- The two tables that define the terrain - they can be changed at krate.

The output is the result of drawing the superformula curve with parameters km1, km2, kn1, kn2, kn3, ka, kb (see on wikipedia), scaled with krx and kry and centered at kx, ky on the terrain, rotated around the center with krot radians, and traversing it at frequency kcps/kperiod.km1,km2 are converted to integers.

As the speed of the point can change considerably for some parameter classes when drawing curve on the terrain some different sounds can be produced compared with other standard curves e.g. it can make triangle like parts in the output wave.

The following ranges are supported and useful:

kn1, ka, kb -- !=0 and continous.

kn2, kn3 -- continous.

km1, km2 -- positive integer > 0: note that the curves are not on all combinations of km1,km2 closed and have poles (closed in infinity) for example if kn1>0 and there exists an n,m in Z with 2*km1/km2 = 2m+1/n i.e curves with (3,2) (5,2) (7,2) etc and (5,4) (6,4) (7,4) (9,4) etc. have a pole which is noticeable when listening. If kn1 < 0 then the curve is reversed and the poles go towards zero in this case. If km1 and km2 are zero silence is produced (a plain circ - same effect occurs with the tuple 2,2,2,2,2,1,1).

kperiod -- some km1 and km2 ratios may cause pitch shifts. With the kperiod parameter this can be fixed. If the ratio is 1 then the kperiod value should also be set to km1 to get the incoming pitch out.

Examples

Here is an example of the sterrain opcode wich shows the impact of letting kn1 running towards zero. It uses the file sterrain.csd.

Example 1007. Example of the sterrain opcode.

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

<CsoundSynthesizer>
<CsOptions>
-odac -d
</CsOptions>

<CsInstruments>
sr     = 44100
ksmps  = 64
nchnls = 1
0dbfs  = 1

gisine ftgen 0,0,2^12,10,1

instr 1

kdclk   linseg  0, 0.1, 1, p3-0.02, 1, 0.1, 0
kn1 transeg 2,p3/2,-5,0.15,p3/2,5,2

asig sterrain 0.5, 220, 0.5, 0.5, 0.5, 0.5, 0, gisine, gisine, 4, 4, kn1, 1, 1.5, 1.5, 1, 4
asig dcblock asig
out asig*kdclk

endin

</CsInstruments>

<CsScore>

i 1 0 20

e
</CsScore>
</CsoundSynthesizer>


Here is an other example of the sterrain opcode showing overtone building. It uses the file sterrain2.csd.

Example 1008. Another Example of the sterrain opcode showing overtone building

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

<CsoundSynthesizer>
<CsOptions>
-odac -d
</CsOptions>

<CsInstruments>
sr     = 44100
ksmps  = 64
nchnls = 2
0dbfs  = 1

gisine ftgen 0,0,2^12,10,1

instr 1

kdclk   linseg  0, 0.1, 1, p3-0.02, 1, 0.1, 0
kb linseg 1,p3/2,1.7,p3/2,1
krot linseg 0,p3,1

asig sterrain 0.5, 220, 0.5, 0.5, 0.5, 0.5, krot, gisine, gisine, 2,2,0.5,2,2,0.7,kb,2
asig dcblock asig
asig = asig * kdclk
aL,aR reverbsc asig, asig , 0.6, 12000, 44100, 0.5, 1
outs aL, aR

endin

</CsInstruments>

<CsScore>

i 1 0 40

e
</CsScore>
</CsoundSynthesizer>


See Also

wterrain,

More information on this opcode: https://youtu.be/E75xakCueA8 , made by Christian Bacher

Credits

Author: Christian Bacher
New in version 6.15