Csound Csound-dev Csound-tekno Search About

[Csnd] Smooth PWM

Date2012-10-01 02:16
FromRoger Kelly
Subject[Csnd] Smooth PWM
How can I get the pulse width mod to produce a smooth sound?  I have gap sounds as the width gets close to .97.    

    instr 2
kcps    expon p4, p3, p5                        ; instr 2:

kpw       lfo 1, .33, 0

kpw phasor .233

a1      vco2 10000, p4, 2,kpw
        out a1
        endin


Date2012-10-01 09:37
FromRory Walsh
SubjectRe: [Csnd] Smooth PWM
Won't gaps always occur if the pulse width is at times 0? Plus, the
manual states that kpw should never be either 1 or 0. Does the
following do what you want:

instr 2
kcps    = 100
kpw       lfo .9, .3
a1      vco2 10000, kcps, 2,abs(kpw)+.01
out a1
endin