Hi! Hope you're enjoying this blog. I have a new home at www.goldsborough.me. Be sure to also check by there for new posts <3

Friday, April 4, 2014

The Lanczos sigma factor

When creating complex waveforms through Fourier synthesis, also known as Additive synthesis, it may have occurred to you that the waveforms have a slight ripple and "horn" or overshoot on the left and right of a peak or trough. This is known as the Gibbs phenomenon and is a result of summing only a finite series of sine and cosine waves, opposed to an infinite series as suggested by Joseph Fourier's theorem. Luckily, Hungarian scientist Cornelius Lanczos came up with a solution, namely the so-called Lanczos sigma ( σ ) factor, also known as sigma-approximation. This little factor, added to the amplitude of each partial of a waveform, reduces the Gibbs phenomenon almost entirely (enough for most cases). 


Here is an image of a square wave created by summing 64 partials. You can clearly see the little horns as well as the ripples at the ends of the peaks and throughs.




The sigma factor is defined as:

σ = sin (x) / x

x being:

x = nπ / M

Where n is the current partial number and M is the total partial number.

So, say you want to calculate this factor for the first partial and you want to add 32 partials in total. Take into account here that the fundamental pitch is seen as partial number one, so for this algorithm the total partials are then 33 and the first "real" partial is actually number 2. 


x = 2 * π / 33


x = 0.19039955476

σ = sin (x) / x

σ = 0.99396894386

This means that the amplitude of partial number 2, which we would have had set at something like 0.5 (normalised between  1 and -1), will now be 0.5 * 0.99396894386 = 0.49698447193. If we do this for all the other partials as well, we will almost entirely make the Gibbs phenomenon disappear.

Here is a picture showing the same waveform (64 partials) as in the picture above, but now with the Lanczos factor added:


Convinced? Nevertheless, however great this might seem, it is important to point out that this perfection is not always wanted. I am not saying that the sigma factor takes away from the realism of the sound, as you will still get a very natural, nicely sounding sound for waveforms with high partials, when you are trying to get as close as possible to a perfect square wave while still retaining the natural sound as much as possible. The “problem” with the Lanczos factor is, however, that it straightens out every sound wave, no matter how many partials. Even waveforms with only two partials will be straightened out heavily. 

Here a square wave consisting of a fundamental pitch and two partials:




And here the same waveform with the Lanczos sigma factor:



Wanted? Rarely. Therefore, I suggest that the sigma factor be used only when you really want to get a near perfect waveform. Whenever you’re actually out for the sound of a square wave with so and so many partials, I recommend not using it, as it really then destroys the shape of the additively synthesized waves. 

If you have any questions, suggestions or free cake, feel free to comment. 

No comments :

Post a Comment