| I´m quite disapointed with the implementation of a variable pulse width
unit generator in the new 3.47 release.BV?
Apart from some amplitude related problems, I´m afraid the waveform is
generated by pure arithmetic methods, and the result is an extremely
aliased wave, which I find absolutely unnacceptable except, maybe, for
control signals. You can easily comfirm this by looking at a
spectrogram...
It is not difficult to generate bandlimited PWM... you can just use the
already implemented pulse generator (buzz) in that way:
sr = 44100
kr = 44100
ksmps = 1
instr 1; bandlimited PWM coded by Josep Mª Comajuncosas
; note: you could further integrate the output
; to get Triangle waves with pulse modulation
kamp init 10000
kfreq line 100, p3, 200
krel line 1, p3 ,0; 0 to 1 (modulation index)
apulse1 buzz 1,kfreq, sr/(2*kfreq), 1;no aliasing here! ;-)
apulse delayr 1/50;don´t try to use below 50 Hz <- a better idea?
apulse2 deltapi krel/kfreq;interpolating to get the proper phase
delayw apulse1
avpw = apulse1 - apulse2; two inverted pulses at variable distance
apwmdc integ avpw; integrating gives a square wave with WM
apwm atone apwmdc,1; remove DC offset caused by integ
apwm balance apwm,apulse1; and restore original power
out kamp*apwm; look at its sonogram! it´s really nice!!
endin
f1 0 16384 10 1
i1 0 10
e
|