SynthMaker

Simple question about code masks, and stuff...

Archive · 2006 10 old posts

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

Zyxoas ·

Sorry for such a retarded question, but how do I implement absolute value in the code module? On the Kvr forums I found this extremely good approximation of tanh: tanh(2x) = x*(2-abs(x)). I tried doing this in SM. Since I have very little experience with SSE I came up with incorrect code for the abs: x*(-1)*((x<0)&1.0). The resultant distortion is asymmetric (no, it's not good for making a tube, either) which is obviously wrong. Could someone perhaps tell me the correct way of doing this is, and perhaps point me to some online resource where I can learn more about masks? I have the Intel SSE tutorial, but it doesn't really give much info on the topic of masks. Thank you for any help you may offer (please don't flame me sk0re, I promise I'm not a lamer 😉).

skOre ·

lmao, I have quite a good judgement on these things, and I can tell that you are far from posing everyday questions 😉

Yet, these might be helpful:

fastest code ABS()? abs() in code component

Zyxoas ·

max(), duh! See what I meant about it being retarded? Know of any place where I can learn more about masks (a tut or something)? Thanks!

Zyxoas ·

The code component produces some really weird code. What's the point of the movaps xmm1, xmm0; maxps xmm1, xmm0; in the code for the max(), exactly?

oddson ·

If you're retarded the rest of us are morons... about the only people on this form who are going to be able to help are the developers, Sambean, Rudolph (rl), and maybe one or two others that know DSP and asm well enough to help sort you out.

About masks... the users guide has a section on the code component and it covers masks a little bit. Also there's a WIKI entery by Stefan on it...

Conditional Statements and Assignments

Zyxoas ·

Oh... So the comparison operators produce all 1's for true? That's the part I was missing! Now everything makes sense. Thanks a lot, oddson. 🙂

skOre ·

See? We may be morons, but we can still help 🙂

unkargherth ·

Zyxoas wrote: Sorry for such a retarded question, but how do I implement absolute value in the code module? On the Kvr forums I found this extremely good approximation of tanh: tanh(2x) = x*(2-abs(x)). I tried doing this in SM. Since I have very little experience with SSE I came up with incorrect code for the abs: x*(-1)*((x<0)&1.0). The resultant distortion is asymmetric (no, it's not good for making a tube, either) which is obviously wrong. Could someone perhaps tell me the correct way of doing this is, and perhaps point me to some online resource where I can learn more about masks? I have the Intel SSE tutorial, but it doesn't really give much info on the topic of masks. Thank you for any help you may offer (please don't flame me sk0re, I promise I'm not a lamer 😉).

Check this for a reasonably good approximation for tanh

streamin in; streamout out;

float a; float sgn; float res; //get the sign sgn = -1; sgn = sgn + (in>=0) & 2; // this approximates tanh in the -0.5 to 0.5 interval. We multiply by 20 to obtain // a more "to the limit" values, suitable for a kind of basic "valve distrosion" // substitute 20 by 2 for mathematically correct values a = 20 * in; // aproximate tanh by taylor series of e^x a=6+a*(6+a*(3+a)); res = sgn*(a-6)/(a+6);

Zyxoas ·

Wow! It's graph looks fantastic! But there's an error in your code which makes it asymmetrical.

You forgot to remove the sign of in (setting it to its absolute value) after working out its sign. Naturally, you would do this either with some abs() implementation, or by saying a = 20 * in * sgn.

unkargherth ·

You're true Zyxoas. It's a mistranscription. In fact second option you sgest is the one i used, and copy/paste killed. Thanks for pointing it out

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.