Alias Suppressed Wave Shaping

DSP related issues, mathematics, processing and techniques
Post Reply
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Alias Suppressed Wave Shaping

Post 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 2976 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
Last edited by martinvicanek on Tue Oct 15, 2024 9:09 pm, edited 1 time in total.
adamszabo
Posts: 667
Joined: Sun Jul 11, 2010 7:21 am

Re: Alias Suppressed Wave Shaping

Post 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!
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: Alias Suppressed Wave Shaping

Post by martinvicanek »

Thanks, Adam, for the bug report! Fixed and uploaded to the first post.
adamszabo
Posts: 667
Joined: Sun Jul 11, 2010 7:21 am

Re: Alias Suppressed Wave Shaping

Post 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!
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: Alias Suppressed Wave Shaping

Post 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!).
adamszabo
Posts: 667
Joined: Sun Jul 11, 2010 7:21 am

Re: Alias Suppressed Wave Shaping

Post 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!
User avatar
Spogg
Posts: 3368
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England
Contact:

Re: Alias Suppressed Wave Shaping

Post by Spogg »

Just checked this out and it’s GREAT!
Thank you so much for this Martin. :D
Post Reply