Re:Variable duty cycle square waves with the Web Audio API
by timewizard on Monday April 07, 2025 @08:34PM
(#43617286)
> Anytime the duty cycle is not 0%, 50%, or 100%, you will have non-zero even harmonics.
The article is specifically trying to achieve those harmonics. This is the initial problem.
> A linear combination (scaled sum or difference) of two balanced square waves will necessarily still have all even harmonics at zero
Yea, that's why you need the phase offset, as I mentioned.
> and thus cannot emulate a square wave with a duty cycle different from 50%.
You can /synthesize/ a square wave at any duty cycle you like. We're still doing Fourier just without the whole transform.
I don't think this is possible. A balanced square wave has no even harmonics in the frequency domain. Anytime the duty cycle is not 0%, 50%, or 100%, you will have non-zero even harmonics.
A linear combination (scaled sum or difference) of two balanced square waves will necessarily still have all even harmonics at zero, and thus cannot emulate a square wave with a duty cycle different from 50%.