SynthMaker

Code: sqrt(), abs(), pow(e,b), denorm(x,lim), +much more...

Archive · 2008 32 old posts

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

infuzion ·

To the readers: Though there are cut&paste workarounds here, this is a request thread. Please put discussions of what formula to use in help or examples areas please. 🙂

sqrt(x) While SM ASM has sqrtps activated, most feel uncomfortable with ASM. Should be easy to add, save people from wasteful approximations, & about as CPU heavy as a divide! Fabb already wants italso 😉

abs(x) Adding abs(x) is easy, & used frequently. If added to Code, it will save CPU since workarounds cost about +130% more cycles (edited to use hex per Fabb): hex ABSMASK=7FFFFFFF; movaps xmm0,i; andps xmm0,ABSMASK;

pow(exp,bas) You already have the (expensive) code for raising power; I'm sure Code writers who don't know ASM & don't like to split up their code will love you if you add it.

denorm(x,limit) ...or a default denormal of -140db, or call it "clipunder()", whatever). Takes only 3 ops (aside from the moves) & 2 declarations, so it should be easy to add, while being useful.

clip(x,limit) assumes that x is balanced +/- & limit is also symmetrical: int SIGNMASK=-2147483648; movaps xmm1,limit; minps xmm0,xmm1; orps xmm1,SIGNMASK; maxps xmm0,xmm1;

rndint() typically produces this, which is SSE1-safe: movaps smIntVarTemp,xmm0; fld smIntVarTemp[0]; frndint; fstp smIntVarTemp[0]; fld smIntVarTemp[1]; frndint; fstp smIntVarTemp[1]; fld smIntVarTemp[2]; frndint; fstp smIntVarTemp[2]; fld smIntVarTemp[3]; frndint; fstp smIntVarTemp[3]; movaps xmm0,smIntVarTemp; But the CPU cycles needed can be reduced 90% if the following SSE2 code is used instead when using SSE2 is activated in the prefs: cvtps2dq xmm0,xmm0; cvtdq2ps xmm0,xmm0;

NOT() & XOR()

sinh() & cosh() Approximations here, but I'm assuming people want exact?

fabb ·

Yes, I do 🙂

Acrobat ·

infuzion wrote: While SM ASM has sqrtps activated, most feel uncomfortable with ASM. Should be easy to add, save people from wasteful approximations, & about as CPU heavy as a divide! Fabb already wants italso 😉 TIA

+1 😀

bootsy ·

+1.42 😉

infuzion ·

I think abs(x) is a no-brainer... I'm trying to think of other helpful & often used functions... anyone?

Eska ·

maybe:RNDINT

streamin w; streamoutint; float x; x=w+8.38861e+006; int=x-8.38861e+006;

infuzion ·

Eska wrote: maybe:RNDINT

That's a neat trick! Code doesn't work 100% though :/ Once that thread has a few confirmations (discuss there please), I'll suggest a round-float as well.

Acrobat ·

Hey this thread has changed title! 😕 .. +1 anyway! 😉

infuzion ·

+ SSE2 rndint()

exonerate ·

Yes the code module definitely needs expanding......

One thing I've thought about is having the code module user expandable, so the code module would have a string input which you use to add extra functions.

So you would have a string like..

abs() { asm code...... }

sqrt() { asm code... }

And then where ever these function where used in the code the asm would get added, This I think would be the ideal solution, less work for the devs and more power for the (power)users. 🙂

We could then build up a lot of useful functions, for instance you could have a 'filter' function so you could just write 'lowpass(input,cut,res)' for a quick and easy filter ect....

Cheers 😉

Exo

Thorsten ·

topic: +1, but exonerate's idea is great, so +2 to that 😉

infuzion ·

exonerate wrote: One thing I've thought about is having the code module user expandable, so the code module would have a string input which you use to add extra functions.

Oh ok, more like an alias system, that is a cool idea! I hope that really doesn't take long to add, if so, then I'll be OK with the hard-coded functions.

Acrobat ·

bump!

Disco_Steve ·

BUMP! asm still scares me 😊

Acrobat ·

Disco_Steve wrote: BUMP! asm still scares me 😊

The fact is ASM it's not readable, I can read code from another user and imagine what it does to the sound, the same cannot be said for ASM, at least for me...

infuzion ·

I'll sometimes use Code to help me write the ASM, & these will make that technique faster.

Also, Code in itself will run faster with some of these often-used functions.

Acrobat ·

infuzion wrote: I'll sometimes use Code to help me write the ASM, & these will make that technique faster.

Also, Code in itself will run faster with some of these often-used functions.

I'd love to have pow (e,b) to build curvey envelopes in a hurry.. 🙂

kirkagur ·

all of this looks so simple to make...is it coming soon? 🙂 the big bang! 😮

infuzion ·

kirkagur wrote: all of this looks so simple to make...is it coming soon?

Doubt it; there are too many bugs to squash. & I'd rather have access to all SSE1,2,3,4x in the ASM module first.

Until then, we'll just have to cut & paste.

Acrobat ·

infuzion wrote: kirkagur wrote: all of this looks so simple to make...is it coming soon?

Doubt it; there are too many bugs to squash. & I'd rather have access to all SSE1,2,3,4x in the ASM module first.

Until then, we'll just have to cut & paste.

can you post the 4 ASM blocks so that we can use it anyhow? If I remember well, Andrew J has already posted the ASM for square root, I wish I have the other three... 🙂 😇

infuzion ·

Acrobat wrote: infuzion wrote: Until then, we'll just have to cut & paste.

can you post the 4 ASM blocks so that we can use it anyhow?

Urrmm.... Fate leggere la prima posta della prima pagina?

Acrobat ·

infuzion wrote: Acrobat wrote: infuzion wrote: Until then, we'll just have to cut & paste.

can you post the 4 ASM blocks so that we can use it anyhow?

Urrmm.... Fate leggere la prima posta della prima pagina?

AH! They are there! (Sono là!) Grazie! 😮

aliasant ·

AH! They are there! (Sono là!) Grazie! 😮

Were? A tutti a frutti primadonna..........

Acrobat ·

aliasant wrote: AH! They are there! (Sono là!) Grazie! 😮

Were? A tutti a frutti primadonna..........

ehe he eh.. in the first page there's something like ABS and other bits, still have to identify which is which... 😕

aliasant ·

Bump this again

Tom7777 ·

Bump, these really would be great, maybe even other things like sinh and cosh also but i guess thats what you mean with the , + bit in the thread title.

Some other possible things -

Now im coding these days i find it would be handy to have a scrollbar.

It seems if you have a long code and have it scrolled down then click outside of the module it scrolls back and looses the position you had.

This one might not be possible but if you have a wire in connection etc and then move it (add more inputs etc) it would be handy if it kept the link and moved it to the new slot position. Like a previous input memory, not essential but could save time in some cases.

TomC ·

Tom7777 wrote: Now im coding these days i find it would be handy to have a scrollbar.

Give it a bump as well 🙂

Tom

aliasant ·

Tom7777 wrote: Bump, these really would be great, maybe even other things like sinh and cosh also but i guess thats what you mean with the , + bit in the thread title.

Some other possible things -

Now im coding these days i find it would be handy to have a scrollbar.

It seems if you have a long code and have it scrolled down then click outside of the module it scrolls back and looses the position you had.

This one might not be possible but if you have a wire in connection etc and then move it (add more inputs etc) it would be handy if it kept the link and moved it to the new slot position. Like a previous input memory, not essential but could save time in some cases.

This is somtehing I have asked for many times and now Malc has it in the latest beta. Just wait a little while. =)

infuzion ·

Tom7777 wrote: ...maybe even other things like sinh and cosh also...

OK, I have added them. Is there a link somewhere to the exact formulas for them please (not approximations)?

BTW, please start your own thread if you want to chat about the editor! <cracks whip> This thread is for adding new functions to Code, not functionality 😉

jobro ·

BUMPing this topic. Good requests here.

infuzion ·

jobro wrote: BUMPing this topic. Good requests here.

Bad timing; 1.1.3 is in public beta. I'd wait for a few weeks after 1.1.3 is fully out.

infuzion ·

pow, exp, abs, sqrt, sign added in SM2.0; thanks SM team! SM2.0 Code Maths

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.