|
----------
De: Christian Lyra[SMTP:chr-lyra@cce.ufpr.br]
Asunto: pulse width
Hi, Csounders!
How can i modify the pulse width of a pulse wave in Csound. I'd
like to modify the pulse width with a lfo (like the old analog synths),
but how can i do this if the waves stored in ftables are "static"?
Thanks,
Christian Lyra
a simple way of achieving this is using linseg as your audio signal generator instead of oscil or other table-reading unit.
you must use reinit with a cycle of duration 1/freq.
this way the linseg functions as an oscilator and its shape may change continously from cycle to cycle.
the evolution can be controlled with an envelope (see instr 1 in the orchestra below)
or with an lfo, as you want (instr 2).
the same principle can be used for changing from sawtooth to triangle and other analog synth effects.
i hope this helps.
luis jure
;-----------------------------------------
; PWM.ORC
; luis jure
; 01/1998
;-----------------------------------------
sr = 44100
kr = 44100
ksmps = 1
nchnls = 1
;-----------------------------------------
instr 1 ;pw modulated by envelope
ifreq = p5
idur = 1/ifreq
isamp = 1/sr
krel line .9, p3, .5 ;mod envelope (change this to your taste)
kenv linseg 0,p3*.1,p4,p3*.7,p4,p3*.2,0 ;amp envelope (id.)
cicle:
ir = i(krel)
ipos = idur*ir
ineg = idur-ipos
a1 linseg 1,ipos,1,isamp,-1,ineg,-1
timout 0,idur,label
reinit cicle
label:
out a1*kenv
endin
;-----------------------------------------
instr 2 ;pw modulated by lfo
ifreq = p5 ;fundamental pitch
idur = 1/ifreq
isamp = 1/sr
idpth = p6 ;modulation depth - vary between 0 (no mod) and .5
ifr = p7 ;modulation frequency
klfo oscil idpth,ifr,1
krel = .5 + klfo
kenv linseg 0,p3*.1,p4,p3*.7,p4,p3*.2,0
cycle:
ir = i(krel)
ipos = idur*ir
ineg = idur-ipos
a1 linseg 1,ipos,1,isamp,-1,ineg,-1
timout 0,idur,label
reinit cycle
label:
out a1*kenv
endin
;-----------------------------------------
; PWM.SCO
f1 0 1024 9 .5 1 0
i1 0 3 15000 150
i2 4 4 15000 150 0 1
i2 + . . . .2 3
i2 . . . . .3 2
i2 . . . . .4 1.5
e
|