SynthMaker

EnvFollower-Denormal-CPU Load

Archive · 2010 29 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

DigitalWhiteByte ·

I wanted to investigate a little bit about why the CPU load went up when my project was idle, is investigating I saw this. I think someone has already stumbled into this thing. But I would understand more 🙂

trogluddite ·

You may have already seen tthis - but here's a thread I got going a while back about this, I was really struggling to understand it myself. Later in the thread there's some explanations of the whole denormal thing - can't say I understand all of it, it's a bit heavy on the maths, but I can see that the code in the Envelope follower does have a feedback loop inside it - these can generate denormals oh so easily. [old link]

DigitalWhiteByte ·

thanks trogluddite 🙂 But because the mono-signal has a different behavior on denormal?

aliasant ·

try this modified env foll instead. It has the denorm stuff built in.

//Envelope follower //ASM optimized by Exonerate streamin in;streamout out; streamin attack; streamin release; float denorm=0.0000000001; int ABSMASK=2147483647; movaps xmm4,denorm; // denorm to xmm4 movaps xmm6,out; movaps xmm0,in; movaps xmm1,attack; movaps xmm5,release; andps xmm0,ABSMASK; addps xmm0,xmm4; // Adds the denorm movaps xmm7,xmm0; cmpps xmm0,xmm6,5; subps xmm1,xmm5; andps xmm0,xmm1; addps xmm5,xmm0; subps xmm6,xmm7; mulps xmm5,xmm6; addps xmm5,xmm7; subps xmm5,xmm4; // subtracts the denorm movaps out,xmm5;

DigitalWhiteByte ·

Grazie, this is really handy 😉

Twisted_Chrylle ·

does this work? Im trying to learn this, and it's not easy. So please don't laugh... 😊

streamin in;streamout out; float denorm=0.0000000001; movaps xmm0,in; addps xmm0,denorm; movaps out,xmm0;

Cheers

aliasant ·

Twisted_Chrylle wrote: does this work? Im trying to learn this, and it's not easy. So please don't laugh... 😊

streamin in;streamout out; float denorm=0.0000000001; movaps xmm0,in; addps xmm0,denorm; movaps out,xmm0;

Cheers

Well. All you have done is adding the denorm value to the input and in that sence it is working.

Twisted_Chrylle ·

Gött!

With other words, I can use this instead of the original Denormal that can be found in SM?

exonerate ·

Twisted_Chrylle wrote: Gött!

With other words, I can use this instead of the original Denormal that can be found in SM?

Well it depends where you put it, for the adding and subtracting a small value to work it really has to be within a feedback loop. Just putting it in any random place will have no effect.

One of the easiest way to flush out denormals is to just put some very low noise say -120db or so after your oscillators in a synth or right at the beginning of your effect. Not the most efficient way to do it though.

Cheers 😉

Exo

Twisted_Chrylle ·

I plan to put it in the feedback in my little home made echo delay. But is it better to just put a denormal directly after the OSC or in every feedback?

exonerate ·

Twisted_Chrylle wrote: I plan to put it in the feedback in my little home made echo delay. But is it better to just put a denormal directly after the OSC or in every feedback?

No it's better to do it in the feedback.

Putting noise after the osc is just a carefree method of dealing with it (it will kill any denormals anywhere), but is more expensive CPU wise. It's much better to deal with it at the source of the denormals (the feedback loop).

Cheers 😉

Exo

MichaelBenjamin ·

and dont write in=in+denorm, or in general, dont write back to the input variables, since this has showed to propagate back and may cause wierdness.

Twisted_Chrylle ·

you are a great help Exo. You are pointing out thing that would be the least fun to experience the faults when Im finished. 🙂

the only "issue" I have now is my filter (in the feedback) when Im using Reso or and mid high amount of HP it gets nasty Feedback. Oh well, I will probebly limit the amout by the controlls manually.

maybe you have 5 min to tell me why Reso is mirrored? (1 as lowest and 0 as higest) [old link]

Twisted_Chrylle ·

Sorry MichaelBenjamin, im still new in ASM, how do you mean? 😊

stw ·

Twisted_Chrylle wrote: Sorry MichaelBenjamin, im still new in ASM, how do you mean? 😊

actually MBs syntax would work in a code block but ot in an ASM block. What he means is that you never should use any variable which is declared as an input to do temporary calculations. Do calculations only on other variables. E.g: NOT

streamin in; float a=1; ... movaps xmm0,a1; addps in,xmm0; ...

BUT:

streamin in; float a=1; float temp; ... movaps xmm1,in; movaps temp,xmm1; // now "in" is stored to the "temp" variable which is used for the calculation movaps xmm0,a1; addps temp,xmm0; ...

Twisted_Chrylle ·

ahhhh ok I got it... 🙂 thanks stw, as I said, Im totally new to this and it's probably not my first misstake I will do. 😈

Edit: hmmm... all code after "float temp;" gets black (not working) why?

aliasant ·

exonerate wrote: Twisted_Chrylle wrote: Gött!

With other words, I can use this instead of the original Denormal that can be found in SM?

Well it depends where you put it, for the adding and subtracting a small value to work it really has to be within a feedback loop. Just putting it in any random place will have no effect.

One of the easiest way to flush out denormals is to just put some very low noise say -120db or so after your oscillators in a synth or right at the beginning of your effect. Not the most efficient way to do it though.

Cheers 😉

Exo

That noise method is very easy and say you use a noise that use maybe 10cycles and you place it at the start of the mono section it wont be such a cpu hog at all. Just a few cycles right?

But that, as said, wont help with feedback denormals.

exonerate ·

aliasant wrote: exonerate wrote: Twisted_Chrylle wrote: Gött!

With other words, I can use this instead of the original Denormal that can be found in SM?

Well it depends where you put it, for the adding and subtracting a small value to work it really has to be within a feedback loop. Just putting it in any random place will have no effect.

One of the easiest way to flush out denormals is to just put some very low noise say -120db or so after your oscillators in a synth or right at the beginning of your effect. Not the most efficient way to do it though.

Cheers 😉

Exo

That noise method is very easy and say you use a noise that use maybe 10cycles and you place it at the start of the mono section it wont be such a cpu hog at all. Just a few cycles right?

But that, as said, wont help with feedback denormals.

Well yes if you have an efficient noise algo then it's not to bad, for instance the one inside SM's denormal module is quite inefficient because of the use of the sin1 command.

If you know where the exact cause of the denormals are it's much more efficient to do a simple add and subtract or even to truncate.

Cheers 😉

Exo

Twisted_Chrylle ·

Well, noticed my CPU went bananas when I had longer feedbacks (and more with filter on the feedback). I think when things like that happends, i need to do something about it.. 😉

With denormal my CPU stays at about 0.8% CPU, with out, im on 35-40%

But I still dont get that thing about the temp code. 🙁 can someone explain why all my code is black after float temp;

Cheers

MichaelBenjamin ·

if you type in the asm box, you need to specify a starting value, so write float temp=0; the code box works without a value and auto assigns zero to each variable that has no value assigned.

exonerate ·

Twisted_Chrylle wrote: Well, noticed my CPU went bananas when I had longer feedbacks (and more with filter on the feedback). I think when things like that happends, i need to do something about it.. 😉

With denormal my CPU stays at about 0.8% CPU, with out, im on 35-40%

But I still dont get that thing about the temp code. 🙁 can someone explain why all my code is black after float temp;

Cheers

It's because that code is not complete.

The dots ..... were to indicate code before and code after.

He was just showing an example of what was meant, it wasn't usable code "as is".

Cheers 😉

Exo

Twisted_Chrylle ·

Ok ok now I get it... I forgot that I needed to put =0 on temp... LOL well, beginners misstake and there will be more...... 😈

here is my new code and I have written down how I thought, only at one part im not sure of. 😇

streamin in; streamout out;

float denorm=0.0000000001; float temp=0; movaps xmm0,in; // adress in > xmm0 movaps temp,xmm0; // adress temp > xmm0 = varibles stored in movaps xmm1,denorm; // adress denorm > xmm1 addps xmm1,temp; // sends temp calculation in xmm1 = denorm? movaps out,xmm1; // send xmm1 calculation to out

MichaelBenjamin ·

i dont know if its a good way to mess around with asm before code, but if you feel fine with it i guess its ok. what i meant and what stw explained better is that in some code (code not asm) that is floating around, especially with the denormal the in variable is used to add the value. when you convert this to asm you easliy can get rid off it. you really dont need the temp variable here:

streamin in; streamout out; float denorm=0.0000000001; movaps xmm0,in; addps xmm0,denorm;//denorm added to xmm0, no need for a variable ... now the processing follows, a filter or a delay. if you just use this module as standalone it wont solve anything.

Twisted_Chrylle ·

Aha ok. thank you MichaelBenjamin. Well, atleast I try to get involved with it so I know what it is. But who knows, some day I maybe do something bigger than 3 varibles.. some day... 🙂

Im planning to use it within my delay feedback so it wont be standalone, but I already have runned in to another problem. but it's posted in the help section as Envelope in mono (blue). [old link]

cheers

Twisted_Chrylle ·

I don't know if this is right or wrong but it works more than fine here. Sorry about all my daft questions, but if it work's for you as good as for me you have an delay (with a builtin denormal) as a big thanks. 🙂

streamin in; streamin delay; streamout out;

int arrayindex=0; float denorm=0.0000000001; float memmax=44099.0; float index=0; float F1P0=1.0; float mem[262144];

movaps xmm0,index; movaps xmm1,denorm; cvtps2dq xmm0,xmm0; movaps arrayindex,xmm0;

push eax; mov eax,arrayindex[0];shl eax,4; fld in[0];fstp mem[eax]; mov eax,arrayindex[1];shl eax,4;add eax,4; fld in[1];fstp mem[eax]; mov eax,arrayindex[2];shl eax,4;add eax,8; fld in[2];fstp mem[eax]; mov eax,arrayindex[3];shl eax,4;add eax,12;fld in[3];fstp mem[eax]; pop eax;

movaps xmm0,index; addps xmm0,F1P0;

movaps xmm1,xmm0; cmpps xmm1,delay,1; andps xmm0,xmm1; minps xmm0,memmax; movaps index,xmm0;

cvtps2dq xmm0,xmm0; movaps arrayindex,xmm0;

push eax; mov eax,arrayindex[0];shl eax,4; fld mem[eax];fstp out[0]; mov eax,arrayindex[1];shl eax,4;add eax,4; fld mem[eax];fstp out[1]; mov eax,arrayindex[2];shl eax,4;add eax,8; fld mem[eax];fstp out[2]; mov eax,arrayindex[3];shl eax,4;add eax,12;fld mem[eax];fstp out[3]; pop eax;

Thanks for all help. 🙂

MichaelBenjamin ·

that wont work, since you only moved the denormal to xmm1 where it later gets overwritten, so it actually does nothing. with this piece you need the temp variable, since the array read directly acesses the in, so how it works is: move denorm to xmm1, then add in (or the other way around, does not matter) then write that to the temp variable, and change the array acess from "in" to "temp".

streamin in; streamin delay; streamout out;

int arrayindex=0; float denorm=0.0000000001; float memmax=44099.0; float index=0; float F1P0=1.0; float temp=0; float mem[262144];

movaps xmm0,index; movaps xmm1,denorm; addps xmm1,in; movaps temp,xmm1; cvtps2dq xmm0,xmm0; movaps arrayindex,xmm0;

push eax; mov eax,arrayindex[0];shl eax,4; fld temp[0];fstp mem[eax]; mov eax,arrayindex[1];shl eax,4;add eax,4; fld temp[1];fstp mem[eax]; mov eax,arrayindex[2];shl eax,4;add eax,8; fld temp[2];fstp mem[eax]; mov eax,arrayindex[3];shl eax,4;add eax,12;fld temp[3];fstp mem[eax]; pop eax;

movaps xmm0,index; addps xmm0,F1P0;

movaps xmm1,xmm0; cmpps xmm1,delay,1; andps xmm0,xmm1; minps xmm0,memmax; movaps index,xmm0;

cvtps2dq xmm0,xmm0; movaps arrayindex,xmm0;

push eax; mov eax,arrayindex[0];shl eax,4; fld mem[eax];fstp out[0]; mov eax,arrayindex[1];shl eax,4;add eax,4; fld mem[eax];fstp out[1]; mov eax,arrayindex[2];shl eax,4;add eax,8; fld mem[eax];fstp out[2]; mov eax,arrayindex[3];shl eax,4;add eax,12;fld mem[eax];fstp out[3]; pop eax;

MichaelBenjamin ·

and yes, you can make all the errors you want, actually the more you make the better. and if you make them in public thats just excellent since it gives me and the others a beautiful and easy opportunity to hang out the smartarse flag. no im kidding. i know its hard to understand at first, but when you got the hang of it a bit it becomes even harder.. or was it easier? dont know.

Twisted_Chrylle ·

Thanks MichaelBenjamin. I remember how hard it was when learned to walk and now when I can walk, I don't if I don't have to... 😉

As a baby learns to walk, it will take time and alot of falls, likewise it will take for me to learn this. And it is because of smartarses like you I will eventually learn... 😈

Jokes aside, I will study your code you just posted and add it to my learning archive, at the moment my brain is boiling becuase I've runned in to a very simple problem that I can't get solved (even if it seams to be very easy and straight foward). I can't get an envelope to work with mono stream!!! LOL

Just jump on and try again... 😀

cheers again

Twisted_Chrylle ·

Hi again... Maybe it's getting off topic now but can I have some help to make a streamin > mem[] in the code MichaelBenjamin posted a few days ago? With other words, an Denomal delay with flexible mem were I can connect a SampRat module to.

I haven't made it because Ive got the feeling it's alittle different to play around with mem[]...?

Cheers

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.