René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

varpulse 01 (CSound instrument)

asig varpulse kwidth, kfrq
0 <= kwidth <= 1
Here's an example
The orchestra file:
sr     = 44100
ksmps  = 2
nchnls = 2

instr 1

  p3=p3*1.4

  ilen = p3
  iamp = ampdb(p4)
  ifrq = cpspch(p5)

  k0_1   phasor ifrq
  kwidth linseg 0.5, ilen, 0.01
  kenv   linseg 0, 0.02, 1, ilen-0.05, 1, 0.03, 0

  if k0_1 > kwidth then
    asig = -1;
  else
    asig = +1;
  endif

  outs asig*kenv*iamp, asig*kenv*iamp

endin
The score file:
i1 0 0.2 70 7.00
i1 + 0.2 72 8.00
i1 + 0.2 74 7.03
i1 + 0.2 76 6.03
i1 + 0.2 78 5.10
i1 + 0.2 80 6.10
i1 + 0.2 82 7.00
varpulse is a similar instrument.