[sdiy] Screwing with Square Waves

cheater00 . cheater00 at gmail.com
Fri Nov 1 20:05:37 CET 2013

Hi Donald,

On Fri, Nov 1, 2013 at 5:28 PM, Donald Tillman <don at till.com> wrote:
> On Oct 31, 2013, at 3:12 PM, Mattias Rickardsson <mr at analogue.org> wrote:
>> So with the different phase relationships between the harmonics in the
>> examples you got either discontinuous waveforms (the square wave et
>> al.) or infinite spikes (the Hilbert wave et al.). Both of these are
>> practically impossible to realize electrically, so I'm wondering:
>> Is there any way of shifting the phases of the harmonics in a square
>> or sawtooth wave so that the resulting waveform has neither
>> discontinuities nor infinite spikes?
> I'm not completely sure.  And that's a *fantastic* question!
> We're summing an infinite number of sines, and each is at a strength of (1/i), inversely proportional to its frequency.  If this was a (1/(i^2)) series, like a Triangle Wave, that converges.  But a (1/i) series does not mathematically converge.

A correction has to be made. Obviously the series converges, because
there is a limit, and we know it. More technically, it converges
because there is such a function such that the absolute area between
that function and a partial sum of our series converges to 0 as the
number of terms of the partial series increases:

E.f(x) => Int (Sum_{n=0}^k f_n(x) - f(x)) dx -> 0, as k->+oo

That function is called the limit, and it is the square wave.

Similarly with the "Hilbert wave" and its associated series.

What you are trying to say is that it converges, but whereas every
partial sum is continuous, the limit has discontinuities.

> So that infinite energy has to go somewhere.
> And as you noted, we see that energy in infinite slopes or infinite spikes.

The reference to infinite energy is better put in more technical
terms. You might want to say that the slope is unbound. Let's see if
that is always the case.

> I thought that shifting the phase of each harmonic by 2pi divided by the Golden Ratio would have a chance, but no, that's just as spikey.
> It appears that an infinite number of sines of completely random phases is the closest you're going to get; no spikes, no discontinuities, but a lot of what looks like high frequency noise.  Or another way to describe it... it looks like any normal oscilloscope waveform of an acoustic source.

The series of a waveform (call it f(x)) with the power spectrum of the
square wave and arbitrary phases would be:

Sum_{n=0}^{+oo} 1/(2n+1) sin( (2n+1) x + t_n)

Differentiating, we obtain the following function, call it g(x):

Sum_{n=0}^{+oo} 1/(2n+1) cos( (2n+1) x + t_n) * (2n + 1)

= Sum_{n=0}^{+oo} cos( (2n+1) x + t_n)

So, as we look at higher and higher partials, their individual slopes
will be higher and higher.

Can the slope be limited? That is, for a certain sequence {t_n}, can
the series above be bound by a finite number?

Let's assume it is bound by a finite supremum S. That is, |g(x)| < S for all x.

I am going to assume that changing the phase of partials in a Fourier
series will not change average power of the function. I haven't been
able to come up with a quick proof for this, but I remember it is this
way. Maybe someone on the list can come up with a proof? It should be
in common literature. A nice counter-example would be fun to see, as

Parseval's theorem for periodic functions can be applied:

1/(2pi)  Int_{-pi}^pi |g(x)|^2 dx = Sum_{n=-oo}^{+oo} |a_n|^2

That is, the integral of the square of g(x) over its period, divided
by the period, is equal to the sum of squares of the Fourier
coefficients a_n of that function. However, we can see that the
Fourier coefficients are going to be an infinite amount of 1's, so the
right side diverges towards infinity. Note that on the right side we
have the Fourier coefficients for the series = Sum_{n=0}^{+oo} sin(
(2n+1) x). This is where my argument above about power not changing
due to phase comes into use.

The left side would have to be bound. In specific, since we have a
supremum S, we can do some estimation:

1/(2pi)  Int_{-pi}^pi |g(x)|^2 dx < 1/(2pi)  Int_{-pi}^pi |S|^2 dx =
1/(2pi) * (2pi) * S^2 = S^2

since S is finite, and we arrive at:

S^2 > +oo

we get a contradiction, which means that our initial hypothesis, that
a t_n of desired properties exists, is incorrect. Therefore, no
function with bound first derivative and the power spectrum of a
square wave exists.

> There should also be a more exotic way to do this; imagine putting together some metric for how spikey or discontinuous a waveform is, and then as you add in each new harmonic, adjust its phase to minimize that metric.
>   -- Don


More information about the Synth-diy mailing list