SynthMaker

string function calculator

Archive · 2011 13 old posts

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

MyCo ·

Hi,

Here is a new tool, to play with. It's just a one-day project, so it might have some bugs.

It's a calculator, that you can give any "valid" equation, and it tries to calculate a float result. The supported functions are:

-,+,/,*,^,sqrt abs,round,floor,ceil sin,cos,tan acos,asin,atan cosh,sinh,tanh

it also knows PI as a constant and it supports brackets as well. Synthmaker doesn't support recursive algorithms, so I had to use a different approach -> loops 😈

Have fun!

adamszabo ·

wow thats badass! I wonder if we can further evolve this were we can have variables like x

trogluddite ·

Excellent work, Myco. 🙂 I haven't been able to catch it out yet - even the precedence of *,/ over +,- seems to work perfectly!

stw ·

MyCo wrote: Hi,

Here is a new tool, to play with. It's just a one-day project, so it might have some bugs.

Aha - one day!

Anyone else feeling like an complete idiot? 😉

DigitalWhiteByte ·

Excellent Lavorone 😉 1+1-6+(-1*2) but this does not seem to work well

infuzion ·

stw wrote: Aha - one day! Anyone else feeling like an complete idiot? 😉

Yes 😊

MyCo, so nice you being active again! BTW, is "floor/ceil" = min/max?

DigitalWhiteByte ·

DigitalWhiteByte wrote: Excellent Lavorone 😉 1+1-6+(-1*2) but this does not seem to work well

I do not know if this is the best method, but I added a module to check if the equation has been solved or there are new elements to be calculated. so it seems to work fine.

MyCo ·

infuzion wrote: BTW, is "floor/ceil" = min/max?

floor = round down ceil = round up

DigitalWhiteByte wrote: I do not know if this is the best method, but I added a module to check if the equation has been solved or there are new elements to be calculated

The fix does work, but i'm not sure if this is a good solution, because inside a loop you restart it. I guess the problem is the sign again. I tried to fix that before. But this case is not handled.

The calculator does 1+1-6+(-1*2) this way: brackets first: -1*2 = -2 result: 1+1-6+-2 now it does the minus (from right): it has no left param so it does 0-2 = -2 result: 1+1-6+-2 now it does the same minus again, because it's the same equation, but it should do 1-6 now come plus (from right): -6+-2 = -8 result: 1+1-8 plus again (from right): 1+1 = 2 result: 2-8

DigitalWhiteByte ·

I noticed that the result would stop at 2-8, so I decided to do a check on the string and see if it was empty, it starts only if the string is not empty and still contains an operation there.

I also believe it is not the best solution. 😕

DigitalWhiteByte ·

Ok, I deleted the module created in the previous version, and I believe I have located the problem, the first loop calculation was not initialized correctly. I hope this works well now.

MyCo ·

What did you change ?

DigitalWhiteByte ·

In the screen that appears when you loads the schematic I made ​​the changes by adding links and reordering trig.

Trig order: 1. get the string equation 2. to loop through occurrences. (link added) 3. to loop through ops

I removed the S & H before the module "doubled signs", it seemed superfluous at this point.

MyCo ·

OK, here is my fix for the above problem, and also for another which happened with stuff like:

1-1*-1

The basic of the fix is, that the calculater now differentiates between a sign flag and a minus operation. A flag has high priority, and the operation has low priority.

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.