Csound Csound-dev Csound-tekno Search About

Re: Pulse width modulation!

Date1998-12-13 11:07
FromPaul Winkler
SubjectRe: Pulse width modulation!
Josep M Comajuncosas wrote:
> Horror! a graphycal approach to PWM synthesis guarantees massive
> aliasing
> ;-)Unless you plan to use it for techno hardcore

Maybe. :)

> I strongly reccomend to
> get
> PWM waves in the following way:
(snip)
> It will sound much better by sure, because all the process is
> bandlimited.

I found your old message where you posted an example orc. Your approach 
does sound a lot nicer on the higher notes. *BUT*...

--it requires sr=kr which I frequently don't like.
--First impression: it sounds subjectively weaker in the bass compared
to my approach. Maybe that's fixable.
--it glitches badly below 50 hz, and I don't understand your approach
well enough to fix that.

Today I spent some time playing with another approach:
use sine wave as the index to a table containing a straight line from -1
to 1. Amplify the index so that the output is clipped to a pseudo-square
wave, but add an offset to the index so that it's asymmetrical (at large
offset, it looks a lot like a narrow pulse). So the offset is our
"width" control. The trick is to limit the amplification and offset  as
frequency goes up, so that at higher pitches, the output gets closer and
closer to a sine wave.  This sounds a lot like my original version but
with a lot less aliasing (though there still is some).

I'll post it when I've got it  cleaned up and tweaked a bit better.