wterrain2
Prev | Orchestra Opcodes and Operators | Next

## wterrain2

wterrain2 — A wave-terrain synthesis opcode using different curves

## Description

A wave-terrain synthesis opcode that enhances the wterrain opcode by providing some more curves, krate table parameters and a parameter for rotating the curve.

## Syntax

    aout wterrain2 kamp, kcps, kx, ky, krx, kry, krot, \
          ktab0, ktab1, kcurve, kcurveparam

## Performance

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

The output is the result of traversing at frequency kcps the curve kcurve with the parameter kcurveparam (see below), scaled with krx and kry and centered at kx, ky on the terrain and rotated around the center with krot radians.

kcurve=0: ellipse as in the wterrain opcode but with a special extension. kcurveparam controls a speed change of the traversing point. The formula is:

fx(t) = kx + krx * sin( t + kcurveparam * sin(t) )
fy(t) = ky + kry * cos( t + kcurveparam * sin(t) )

kcurve=1: lemniskate - this is a simple 8. here also the kcurveparam controls a speed change of the traversing point. The formula is:

fx(t) = kx + krx * cos( t + kcurveparam * sin(t) )
fy(t) = ky + kry * sin( t + kcurveparam * sin(t) ) * cos( t + kcurveparam * sin(t) )

kcurve=2: limacon

fx(t) = kx + krx * sin(t) * (cos(t) + kcurveparam);
fy(t) = ky + kry * cos(t) * (cos(t) + kcurveparam);

limacon curve with different parameters

kcurve=3: cornoid

fx(t) = kx + krx * sin(t) * (cos(t) + kcurveparam);
fy(t) = ky + kry * cos(t) * (cos(t) + kcurveparam);

a cornoid curve with different parameters

kcurve=4: trisectrix (Ceva)

fx(t) = kx + krx * cos(t) * (1+kcurveparam*sin(2*t));
fy(t) = ky + kry * sin(t) * (1+kcurveparam*sin(2*t));

a trisectrix curve with different parameters

kcurve=5: scarabeus

fx(t) = kx + krx * cos(t) * (1+kcurveparam*sin(2*t));
fy(t) = ky + kry * sin(t) * (1+kcurveparam*sin(2*t));

a scarabeus curve with different parameters

kcurve=6: folium

fx(t) = kx + krx * cos(t) * cos(t) * (sin(t)*sin(t) - kcurveparam);
fy(t) = ky + kry * sin(t) * cos(t) * (sin(t)*sin(t) - kcurveparam);

a folium with different parameters

kcurve=7: Talbot curve

fx(t) = kx + krx * cos(t) * (1 + kcurveparam * sin(t)*sin(t));
fy(t) = ky + kry * sin(t) * (1 - kcurveparam - kcurveparam*cos(t)*cos(t));

a Talbot curve with different parameters

## Examples

Here is an example of the wterrain2 opcode. It uses the file wterrain2.csd.

Example 1182. Example of the wterrain2 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     = 48000
    ksmps  = 32
    nchnls = 2
    0dbfs  = 1

    gisine ftgen 0,0,2^12,10,1
    gScurves[] fillarray "ELLIPSE ", "LEMNISKATE ", "LIMACON ","CORNOID ","TRISEXTIC ","SCARABEUS ","FOLIUM ","TALBOT "

    instr 1
    prints gScurves[p4]
    kdclk init 0
    kdclk   linsegr  0, 0.1, 1, p3-0.02, 1, 0.9, 0
    kparam init 0
    krot init 0
    krot linseg 0,p3,6.28 ; ROTATE THE CURVE SLOWLY
    kparam linseg 0,p3,4 ; INCREASE CURVEPARAMETER

    asigL wterrain2 0.5, 110, 0.5, 0.5, 0.8, 0.4, krot, gisine, gisine, p4, kparam
    ; LET THE POINT FOR RIGHT RUNNING BACKWARDS FOR A LITTLE STEREO EFFECT
    asigR wterrain2 0.5, -110, 0.5, 0.5, 0.8, 0.4, krot, gisine, gisine, p4, kparam
    asigR dcblock asigL
    asigL dcblock asigR
    asigL*=kdclk
    asigR*=kdclk
    aL,aR reverbsc asigL, asigR, 0.6, 15000, 44100, 0.5, 1
    outs aL,aR

    endin

    </CsInstruments>

    <CsScore>

    i 1 0 40 0 ; ELLIPSE
    i 1 41 40 1; LEMNSIKATE
    i 1 82 40 2; LIMACON
    i 1 123 40 3; CORNOID
    i 1 164 40 4; TRISEXTIC
    i 1 205 40 5; SCARABEUS
    i 1 246 40 6; FOLIUM
    i 1 287 40 7; TALBOT

    e
    </CsScore>
    </CsoundSynthesizer>

Here is an other example of the wterrain2 - a sound fugue. It uses the file wterrain2_2.csd.

Example 1183. Another Example of the wterrain2 opcode - a sound fugue

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

    <CsInstruments>
    sr     = 48000
    ksmps  = 32
    nchnls = 2
    0dbfs  = 1

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

    instr 1

    kamp adsr 0.1,0.01,1,10

    ; THE MODULATION PARAMETERS
    krot linseg 0,p3,6.28 ; ROTATE
    kparam randc 2.5,0.1,0.993 ; CONTROL CURVEPARAMETER WITH CUBIC RANDOM
    kx linseg 0,p3/2,1,p3/2,0 ; MOVE HORIZONTAL THROUGH THE TERRAIN
    ky linseg 0,p3,1 ; MOVE VERTICAL THROUGH THE TERRAIN

    ; TRY THE OTHER CURVES AS WELL
    asigL wterrain2 0.2, 55*p4, kx, ky, 0.5, 0.4, krot, gisine, gisine, 5, kparam
    asigR wterrain2 0.2, -55*p4, kx, ky, 0.5, 0.4, krot, gisine, gisine, 5, kparam

    asigR dcblock asigL
    asigL dcblock asigR
    asigL butterlp asigL,9000
    asigR butterlp asigR,9000
    aL,aR reverbsc asigL, asigR, 0.7, 15000, 44100, 0.5, 1
    outs aL*kamp*p5,aR*kamp*p5

    endin

    </CsInstruments>

    <CsScore>

    i 1 0 300 1 1
    i 1 1 300 7 0.4
    i 1 2 299 [9/2] 0.4
    i 1 3.1 296.9 [16/3] 0.45
    i 1 4.3 295.7 [27/4] 0.5
    i 1 6.9 292.1 6 0.5

    e
    </CsScore>
    </CsoundSynthesizer>

## See Also

wterrain, sterrain

## Credits

Author: Christian Bacher
New in version 6.15

Prev | Up | Next
wterrain | Home | xadsr