Sunday, February 24, 2019

ex2. csound lfo and amplitude modulation

The lfo opcode will create a low frequency oscillator of various shapes.


It is of format


  • kres lfo kamp, kcps [, itype]


or


  • ares lfo kamp, kcps, [, itype].


itype is optional (default 0). Otherwise it will give the shapes determined from itype


  • itype = 0 - sine, default

  • itype = 1 - triangles

  • itype = 2 - square (bipolar)

  • itype = 3 - square (unipolar)

  • itype = 4 - saw-tooth

  • itype = 5 - saw-tooth(down)

The six different shapes are shown here:


In this example, we create a lfo oscillator of 220 amplitude at 2 Hz. We will use lfo to modulate the carrier of 660 Hz. Thus the amplitude will vary from minimum to maximum every 0.5 second. In the score, we run instrument 1 for 40 seconds. We use a linen to create envelope to fadein for 1 second at beginning and 1 second fadeout at the end.


We use this program with the csd module used is ex1:


# ex2.py

from csd import CSD

csd = CSD(__file__)

csd.s1()

csd.add('giSine ftgen 0, 0, 2^10, 10, 1')

ins = '''
    instr 1
kres lfo 0.5, 2
kenv linen 1, p3/40, p3, p3/40
aOsc poscil kres, 660, giSine
outs kenv*aOsc, kenv*aOsc
    endin
'''

csd.add(ins)

csd.s2()

csd.add('i 1 0 40')

csd.s3()

We have the video here.

No comments:

Post a Comment