SynthMaker

If Then Else

Archive · 2011 3 old posts

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

trogluddite ·

Here's an example of the new If..Then..Else primivitve introduced in SM 2.0.3...

The one on the left is probably easiest to understand ..

Type - String, so all the "Conditions" are treated as strings If - your ibput value that you want to test goes in here Op - the type of comparison, in this case we're seeing if the input is an exact match for one of the conditions Conditions - the primitive works down this list from top to bottom, stopping when it finds a comparison which is true. In this case it will stop if the input matches exactly any of the strings in the array (because the 'Op' is "="). Then - each item in this list pairs up with each one in the 'Conditions' list - this is the output that you will get if the condition is true. So in this case "one"-->"sheep", "two"-->"cow", etc. Else - if no match is found in the conditions list, you get this output instead.

The right hand example is a bit tricker, but essentially works the same way.

Type - Float this time, so the strings at the 'If' and 'Conditions' inputs are now treated as numbers rather than strings. Important, because if you used strings, "100.00" would not equal "1e2" - but as floats, they are the same number. If - the input Op - I used 'Greater' this time, to demonstrate a particular point... Conditions - this time we're looking through the list until we find a number where the input is greater - but CARE NEEDED - say I had put 0.25 as the first number, and the input is 0.9 - 0.9 is greater than 0.25, wahay, it's true, BUT the rest of the list will not get scanned, so we'd never find out that 0.9 is greater than 0.75 too. So if using the primitive to sort numbers - be careful what order you list the conditions. Then - as before, the output is the 'Then' value with the same index as the 'True 'Condition' Else - as before, the default value if there is no match.

infuzion ·

Thanks trog!

philter5 ·

thank you for this nice explanation 😉

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.