Audio using PWM, what is the principle behind it?

Usually an audio signal would have multiple frequencies summed up simultaneously. How does PWM do that?

The audio signal that contains a spectrum of multiple frequencies is still just an audio signal that can be sampled by and ADC and recreated by a DAC. Providing the sampling rate used is higher than twice the highest audio frequency then all is good. A DAC that uses PWM techniques is no different. In any one cycle of the PWM waveform, the ratio of mark-to-space must accurately "represent" the instantaneous analogue signal and a single PWM cycle must be shorter in time than half the period of the highest audio signal: -

enter image description here

The above is a simple representation of 3 DC levels using PWM. Clearly if the PWM frequency is "high" those three levels can be regarded as part of a complex AC waveform. Hopefully you can see that controlling the PWM mark-space ratio accurately is really fundamental to obtaining low audio distortion.

Is the audio quality as good as using PCM with DAC, filter and amplifier?

Traditionally no, but it's getting better.

Since this technique looks and is so convenient, why don't all audio devices use this to save money and cost, including sound cards in computers?

Controlling PWM ratio accuracy is quite difficult to get really good hi-fi quality and with class D amplifiers power supply rejection is still a pretty difficult challenge. See the embedded picture above - if the 5V power rail doubled then the gain also doubles - now imagine that instead of it simply doubling, you had a load of crappy noise on that rail - this would directly modulate your audio signal and create some very noticeable effects.


PCM with DAC, filter and amplifier

This depends on how your DAC is built internally. Most sound card DACs will be using sigma-delta modulation, which resembles PWM in that it's a one-bit signal turned on and off at high speed through a filter, but using a smarter algorithm to ensure the correct output level and slew rate.

This example sound card codec datasheet has a nice diagram on the first page.enter image description here

You can get quite decent sound out of pure PWM if your PWM is fast enough. It needs to have a PWM frequency much higher than the highest audio frequency you want, into the MHz region.

See Converting PWM into an analog signal

Tags:

Audio

Pcm

Pwm