[sdiy] PWM or DAC better for audio out?

Olivier Gillet ol.gillet at gmail.com
Thu Jun 2 18:46:10 CEST 2011


> When considering how to output audio from an FPGA synth, PWM is so simple and
> cheap compared to a DAC.  I personally can't think of any reason to use a DAC
> over PWM but my hunch is that I'm missing something obvious.

If you look at the spectrum of the output signal, it has a huge peak
at the modulation frequency (and all its harmonics). Think of it: when
your synth is "at rest" (centered, null output), it will still
generate a 3.3V pp square wave at the PWM frequency. Scary! It's much
more a concern than the HF aliasing "noise" you get straight out of a
DAC.

If you don't filter the output, it can be easily mirrored down the
audio frequencies by a soundcard or sampler or digital FX with poor
anti-aliasing filter on its inputs - and if it happens it doesn't
sound nice trust me! Not to mention the occasional weird behavior of
some analog circuits if you feed them such signals - problems often
solved by adding extra poles at 25kHz here and there (at the cost of a
smudgier high-frequency response).

If you decide to filter it, you might have to design very sharp
filters, especially if the PWM frequency is near the limit of the
human hearing range - since you won't have a wide transition band.

Note that if you're working with a FPGA, you probably have the
resources to do something way smarter than PWM, for example
sigma-delta or any other pulse-density encodings - with such schemes +
oversampling, the HF components will be higher, hence easier to
filter, even with a simple RC filter.

While I have used PWM on the Shruthi, the couple of projects I am
working on are now using proper DACs - at least for the audio path.


Olivier



More information about the Synth-diy mailing list