| Hi,
This is the Csound code I am planning to base my moogvco opcode on. Let me
know if you find any problems with it. The modulated triangle waveform is
still a little messy but I think it is quite usable. Looks like a lot of
line wraps to fix in this email.
Good luck,
Hans Mikelson
; ORCHESTRA
;---------------------------------------------------------------
; A set of analog modeling instruments using resonant low-pass
; filter by Hans Mikelson November 1998
;---------------------------------------------------------------
sr = 44100
kr = 4410
ksmps = 10
nchnls = 2
zakinit 50, 50
;---------------------------------------------------------------
; LFO
;---------------------------------------------------------------
instr 5
idur = p3
iamp = p4
ifqc = p5
iwave = p6
ioffset = p7
ioutch = p8
ksig oscil iamp, ifqc, iwave
kout = ksig*.5+ioffset
zkw kout, ioutch
endin
;---------------------------------------------------------------
; Moog VCO with Mikleson filter
;---------------------------------------------------------------
instr 10
idur = p3 ; Duration
iamp = p4 ; Amplitude
ifqc = cpspch(p5) ; Frequency
irtfqc = sqrt(ifqc) ; Square root of frequency
ifco = p6*ifqc/500 ; Filter cut off (higher frequencies get
a higher cut off)
krez init p7 ; Resonance does not change in this
instrument
iwave = p8 ; Selected wave form 1=Saw, 2=Square/PWM,
3=Tri/Saw-Ramp-Mod
ipwch = p9 ; PWM SRM modulation channel
ileak = (iwave==2 ? .999 : (iwave==3 ? .995 : .999)) ; Leaky
integration value
kpw zkr ipwch ; Read the Zak modulation channel
kpwn = kpw-.5 ; Get a pulse width that goes from -.5 to
.5
kfco expseg 100+.01*ifco, .2*idur, ifco+100, .5*idur, ifco*.1+100,
.3*idur, .001*ifco+100 ; Filter envelope
apulse1 buzz 1, ifqc, sr/2/ifqc, 1 ; Band-limited impulse train
apulse2 vdelay apulse1, 1000/ifqc*kpw, 1000/ifqc ; Delay the impulse
train by lambda/pw.
asaw biquad apulse1, 1, 0, 0, 1, -ileak, 0 ; Biquad is used to do
a leaky integrator for saw wave
apdiff = apulse1-apulse2 ; Pulse difference is
needed for square wave
asqr1 biquad apdiff, 1, 0, 0, 1, -ileak, 0 ; Biquad used for leaky
integrator of pulse difference
asqr = asqr1+kpwn ; Adjustment to remove
DC component
atri1 biquad asqr1, 1, 0, 0, 1, -ileak, 0 ; Triangle wave, many
adjustments are necessary to conteract amplitude
atri =
(atri1*irtfqc/(kpw*(1-kpw))/3000+5*kpwn/irtfqc)*(1-kpwn*kpwn*20/irtfqc)/sr*4
4100 ; and DC variations
asig = (iwave==2 ? asqr : (iwave==3 ? atri : asaw)) ; Select
your waveform here
;aout rezzy asig, kfco, krez ; Apply the
filter
outs asig*iamp, asig*iamp ; Stereo
ouput and amplification
endin
; SCORE
f1 0 16384 10 1
; LFO Note 0 |