Page 1 of 1

Alias Suppressed Wave Shaping

Posted: Mon Oct 14, 2024 7:23 pm
by martinvicanek
Recently I wrote a note about anti-aliased waveshaping To my surprise, one person actually read it! :o So I thought I might just as well post a demo here, would maybe reach a broader audience. :mrgreen: Basically there are two mechanisms at work, one is oversampling and the other is called ADAA (don't bother about the acronym). The nice thing is that they really do a good job when applied together. Check out the demo, and have fun!
AAshaper.fsm
(177.1 KiB) Downloaded 2975 times
Oh, and should you really want to uncover the mystery of the phenomenon, here is my little note: https://vicanek.de/articles/AADistortion.pdf

Re: Alias Suppressed Wave Shaping

Posted: Tue Oct 15, 2024 8:28 am
by adamszabo
Nice stuff, thanks! Just an observation, in the "AA Sigmoid" module the "w" constant is not declared in:

movaps xmm4,w; // w2
movaps w,xmm0;

But it should work just fine without it!

Re: Alias Suppressed Wave Shaping

Posted: Tue Oct 15, 2024 9:10 pm
by martinvicanek
Thanks, Adam, for the bug report! Fixed and uploaded to the first post.

Re: Alias Suppressed Wave Shaping

Posted: Wed Oct 16, 2024 11:33 am
by adamszabo
An optimization one can do is to use reciprocals instead of the division at the end of the code like so:

Code: Select all

addps xmm0,xmm1;	// w1 + w
addps xmm1,xmm4;	// w1 + w2
rcpps xmm0,xmm0;   // 1/(w1 + w)
rcpps xmm1,xmm1;   // 1/(w1 + w2)
mulps xmm3,xmm0;   // (3*x1 + x) * (1/(w1 + w))
mulps xmm2,xmm1;   // (3*x1 + x2) * (1/(w1 + w2))
addps xmm3,xmm2;
mulps xmm3,FP25;	// y
movaps y,xmm3;
I compared them and I didnt see any difference in the spectrum!

Re: Alias Suppressed Wave Shaping

Posted: Wed Oct 16, 2024 6:28 pm
by martinvicanek
Thanks again, Adam. Indeed, rcpps and the additional multipy are cheaper than divps, but you are aware that it comes at the cost of precision loss. rcpps has a relative error of up to 1.5*2^-12, which means you have a bit more than 3 significant digits (out of nearly 7 in single precision). In other words, your headroom above noise floor shrinks to less than 70 dB (compared to some theoretically possible135 dB in single precision). I would say that is still good enugh for rock and roll, but you have to know what you are doing (I now you do!).

Re: Alias Suppressed Wave Shaping

Posted: Wed Oct 16, 2024 7:14 pm
by adamszabo
martinvicanek wrote:Thanks again, Adam. Indeed, rcpps and the additional multipy are cheaper than divps, but you are aware that it comes at the cost of precision loss. rcpps has a relative error of up to 1.5*2^-12, which means you have a bit more than 3 significant digits (out of nearly 7 in single precision). In other words, your headroom above noise floor shrinks to less than 70 dB (compared to some theoretically possible135 dB in single precision). I would say that is still good enugh for rock and roll, but you have to know what you are doing (I now you do!).
Yes, you are absolutely right about the precision loss! As I didnt hear any real world difference between the two versions, I thought it would be possible to get away with this optimization ;) but its definitely something to to keep in mind!

Re: Alias Suppressed Wave Shaping

Posted: Fri Nov 01, 2024 3:03 pm
by Spogg
Just checked this out and it’s GREAT!
Thank you so much for this Martin. :D