Background: I recently made a project which emits pure tones on a speaker, and it got me thinking about how I was restricted to simple pitches. How would I simulate a chord if I can only play one frequency at a time?

The approach that makes the most sense to me would be to take multiple PWM outputs, each at a component frequency, and feed them into a summing amplifier. Perhaps they'd also need to be level shifted first (assuming for example 0V to 5V square waves in the PWM to -2.5V to 2.5V) to avoid it becoming a purely additive process. Either way I believe I understand the concept there.

But consider a scenario where I'm using a system where other PWMs are already allocated and I need to use just 1. This question's answer addresses it but I don't really follow it. I'm not sure where I get lost but to me I feel like this would just result in some other pure tone somewhere between the two. It's not clear to me exactly what the user is calculating when "adding those phases to two phase accumulators, look up their values in the sine table, add them, and set a PWM output to that value." What does adding them actually do? What if they're both at a max value (e.g 1 -> 100%)? You can't PWM more than 100% duty cycle.

  • \$\begingroup\$ You just have to ensure the sum doesn't exceed 100% (or 0%) before feeding it to the PWM generator. \$\endgroup\$
    – user16324
    Commented Dec 19, 2020 at 23:54
  • \$\begingroup\$ I believe that when you read "PWM" you assume "square wave at the audio frequency". If you use a PWM signal that's much faster than the audio frequency, then you can modulate it by changing its duty cycle, and low-pass filter it. This is how a class D amplifier works. If you can generate PWM at 100kHz and filter it down to 20kHz, then you can generate fairly good audio from that -- to the limits of the precision of your PWM generator. \$\endgroup\$
    – TimWescott
    Commented Dec 20, 2020 at 0:20
  • \$\begingroup\$ you are describing DDS, if you look that up you may find more information. \$\endgroup\$ Commented Dec 20, 2020 at 1:32

1 Answer 1


You can easily play more than one channel of pure sine tone or any audio. For example playing 4 channels is possible when each channel is only 25% of max amplitude. Just sum the audio samples together.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.