FM synths - Anti-aliasing/Oversampling

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

Hey all. I'm coding my first instrument which uses FM synthesis. I was hoping to start up a general but perhaps broader discussion of anti-aliasing and oversampling in FM synthesis, so as to find out as much as possible before I try and overcome the issues I' currently having.

Basically I'm at the stage where my plugin doesn't use any anti-aliasing, so if I crank up the sample rate in the host, this will decrease the aliasing. Otherwise (if I leave the sample rate at around 48KHz), there are serious problems with folding back frequencies when playing the higher octaves.

It seems to me that I would be able to overcome this issue by oversampling in the synthesis calculations, however, I have never actually implemented oversampling before and am quite unsure what the best practices are, especially when downsampling back to the host sample rate (after the synthesis calculations). Secondly, it is really unclear to me what other developers typically do in a situation like this with FM, given that in some cases the aliasing is actually desirable.

Any advice or chat about developing FM synths would be welcome and appreciated here - it seems to be one of those dark arts...

Post

Never done an FM synth, but I know about 2 ways to address aliasing:

- Reduce aliasing effect by reducing modulation amount.
Reduce the amount of modulation as notes increase.
Simply do less modulation if you play A9 note then if you play A0 note.
Won't remove aliasing completly, but it will reduce it.

- Analyze the FM signal, then reconstruct w/o side bands
https://www.johndcook.com/blog/2016/02/ ... fm-signal/
FM -> Analyze signal -> use additive to reconstruct the signal up to nyquist
Don't know if it is practicable on current CPUs or if you end up with 101% CPU load.

Maybe some FM synth dev can bring more light into the dark :D

Post

Regarding the additive approach, there's an old paper that's been linked to at least a couple of times in this forum that has band limited sinusoid summation formulas for spectra with overtones and undertones. I don't recall the link or the thread, so sorry about that, and not 100% sure how useful it'd be for approximating FM. Anyway I'll try find a link to it...

Edit: didn't take too long :D
https://www.google.co.th/url?sa=t&sourc ... DcYZTQL642

Post

PurpleSunray wrote:Never done an FM synth, but I know about 2 ways to address aliasing:

- Reduce aliasing effect by reducing modulation amount.
Reduce the amount of modulation as notes increase.
Simply do less modulation if you play A9 note then if you play A0 note.
Won't remove aliasing completly, but it will reduce it.

- Analyze the FM signal, then reconstruct w/o side bands
https://www.johndcook.com/blog/2016/02/ ... fm-signal/
FM -> Analyze signal -> use additive to reconstruct the signal up to nyquist
Don't know if it is practicable on current CPUs or if you end up with 101% CPU load.
Most FM synths on the market have a 'key scaling' feature which allows the user to set the modulation amount across the full note range. I had planned on implementing that, however, as you say it wouldn't completely remove aliased frequencies. I was hoping to destroy them all!

@matt42 & PurpleSunray
Thanks to both of you for the links. They'll make interesting reads for sure.

Post

EchoGecko wrote: It seems to me that I would be able to overcome this issue by oversampling in the synthesis calculations, however, I have never actually implemented oversampling before and am quite unsure what the best practices are, especially when downsampling back to the host sample rate (after the synthesis calculations). Secondly, it is really unclear to me what other developers typically do in a situation like this with FM, given that in some cases the aliasing is actually desirable.
Oversampling is covered here on a fairly regular schedule (so might want to search for past threads) but you could also search "poly-phase resampling" or something on Google to find some useful material.

As far as "desirable aliasing" goes, keep in mind that host sampling rate can vary and presets designed for aliasing at a particular sampling rate are potentially going to sound completely wrong on another sampling rate. In order to get predictable aliasing you'd have to use a fixed internal rate (and arbitrary rate resampling with all the complexity it brings) and honestly it's probably not worth it unless you want to try to emulate some particular vintage FM synth.

That said.. before you try anything else, I'd probably start with the good old trick of averaging two samples of the modulation signal. This will result in some low-pass filtering of the highest frequencies and especially with feedback helps keep things under control without really costing much of anything. If I remember right (no guarantees on my memory being correct on this one though), even the good old DX7 did something like this at least with feedback. ;)

Post

You can also combine pre integration/differentiation with oversampling. It is quite efficient even when the carrier and the modulator are not sine waves.

https://stash.reaper.fm/28384/Different ... Tables.pdf

and a little JSFX example (a three operator synth with parabolic waveforms instead of sines) :
https://forum.cockos.com/showthread.php?t=180926
See you here and there... Youtube, Google Play, SoundCloud...

Post

Here is another example:
a non trivial waveform with integro/differentiation aliasing limiting for phase modulation :

https://github.com/axoloti/axoloti-cont ... Wave3b.axo

It is a Axoloti object coded/optimised for ARM proc with float unit.
One of the drawback of this method is that it needs a division per sample.
Luckily on ARM procs float division can operate in parallel with int operations, hence the usability of the method with ARM procs.
See you here and there... Youtube, Google Play, SoundCloud...

Post

Smashed Transistors wrote: Luckily on ARM procs float division can operate in parallel with int operations, hence the usability of the method with ARM procs.
By carefull with that asumption. NEON and FPU share same registers. So if your int-crunching-code translates to SIMD, it cannot execute in parallel with float-crunching.

Post

If you stay with sine (operator) FM, aliasing shouldn't be a big concern unless the modulation amount or the modulator frequency/ratio is high. (As you might have realized already).

Consider that synths that first came up with FM (sin operator modulation) like the Yamaha DX7 most probably did not have any oversampling there. Otherwise these old processors would have been cooked. These synths parameters either have been limited to prevent aliasing or just did allow aliasing.

People now a days seam to judge software by it's closeness to hardware and vintage. If the judge objective had trouble, then trouble is good.
www.solostuff.net
Advice is heavy. So don’t send it like a mountain.

Post

All these links are great - thanks all!
S0lo wrote:If you stay with sine (operator) FM, aliasing shouldn't be a big concern unless the modulation amount or the modulator frequency/ratio is high. (As you might have realized already).
I have noticed indeed. I have also noticed that sometimes high amounts of modulation are required to achieve certain sounds. It has been pretty challenging to build something that is free of restrictions in that regard, but that also does not end up badly aliasing if tweaked slightly the wrong way.

Currently I'm only using sine operators, but I do hope to add other waveforms eventually. At least with sines I can anticipate precisely where aliasing will occur, in accordance with the FM theory i.e I will know where the significant sidebands are going to appear in the spectrum depending on the modulation index, and whether or the sidebands will fold back at Nyquist. Bit of a different story with more complex waveforms, I imagine.

Post

You can try PM with triangles instead of sines, they do not alias too much and you will get an idea of how using something else than sine waves affects the sound ;)
See you here and there... Youtube, Google Play, SoundCloud...

Post

Smashed Transistors wrote:You can try PM with triangles instead of sines, they do not alias too much and you will get an idea of how using something else than sine waves affects the sound ;)
Incidentally, I'm actually yet to find a proper reason to use PM instead of FM. I asked around and experimented, and it seems to me that the only differences are that adding a DC offset to a modulator signal will cause the frequency to shift if we use FM. That and index values work across a different sort of range of numbers, depending on which implementation is used. I stuck with FM in case I wanted to deliberately introduce a DC offset to pitch shift, although, I think perhaps other people do the opposite in case a DC offset is ever introduced by accident. I've certainly always been interested to know people's thoughts on this.

I have tried other waveforms in Max/MSP with FM before so I know I'll want to add them eventually - I'm just not terribly clued into the academic side of using modulating waveforms other than sines. I'm trying to stay in the land of 'I know what I'm doing' as much as possible, in other words. :P


In other news, I came across this article which pretty much discusses the exact things I started this thread for. Talks about the harmonics in ring modulation causing aliasing, and goes into discussion about oversampling, interpolation, decimation, polyphase filtering etc. This is all stuff I'm pretty new to so finding this blog was really fortunate. https://christianfloisand.wordpress.com/tag/decimation/

Post

EchoGecko wrote:
Smashed Transistors wrote:You can try PM with triangles instead of sines, they do not alias too much and you will get an idea of how using something else than sine waves affects the sound ;)
Incidentally, I'm actually yet to find a proper reason to use PM instead of FM. I asked around and experimented, and it seems to me that the only differences are that adding a DC offset to a modulator signal will cause the frequency to shift if we use FM......
Under certain constrains they will sound exactly the same. But if you lift those constrains, they are very different. https://moinsound.wordpress.com/2011/03 ... hnologies/

I haven't looked into the details, but the outline is clear.
www.solostuff.net
Advice is heavy. So don’t send it like a mountain.

Post

If you use two sine operators, you can produce exactly the same sounds with FM and PM. The reason why is that the derivative of a sine wave is also a sine wave.
As soon as the modulator is not a sine, the results are different.

A main drawback of frequency modulation is that you may be careful with DC offset from the modulator that can cause frequency drift. A DC remove/high pass filter should be used.

One other advantage of phase modulation is that you can use the integration/differentiation scheme to limit aliasing.
See you here and there... Youtube, Google Play, SoundCloud...

Post

EchoGecko wrote:
Smashed Transistors wrote:You can try PM with triangles instead of sines, they do not alias too much and you will get an idea of how using something else than sine waves affects the sound ;)
Incidentally, I'm actually yet to find a proper reason to use PM instead of FM. I asked around and experimented, and it seems to me that the only differences are that adding a DC offset to a modulator signal will cause the frequency to shift if we use FM. That and index values work across a different sort of range of numbers, depending on which implementation is used.
The only difference between FM and PM is that with FM the modulation is integrated into phase, where as with PM it's just added into the instantaneous phase directly. You can turn one into another by integrating (PM to FM) or differentiating (FM to PM) the modulation signal. Usually you do this by changing the point where you add the modulation in, but you could also use a pre-filter on the modulation signal to go from one to the other. The 1/f frequency response of the integral (or the inverse for differential) explains essentially all the other differences.

Post Reply

Return to “DSP and Plugin Development”