SynthMaker

A State-Machine Example

Archive · 2005 7 old posts

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

rl ·

The statemachine is an often overlooked module in the toolbox, but sometimes complicated logic can be expressed much simpler using a state machine.

This example shows a nice usage for it: a button that shows it's "pressed" state. It is part of a scrollbar implementation that is intended to work like a standard windows scrollbar, painted using SM drawing primitives.

Button in normal state:

Button (arrow down) in pressed state:

How the button works:

When the button is pressed, it shows it's pressed state. - if the mouse is released, the button fires and shows it's normal state again, ready. - if the mouse is moved outside, the button shows it's normal state, but still recognizes that it is pressed. - - if the mouse is released outside nothing happens, the button returns into normal state, ready. - - if the mouse is moved inside again (still pressed) the button shows it's pressed state again.

Schematic explanation:

In the center of the schematic LDown, DragXY and MOver create triggers, these switch the numbers 0, 1, 2, 3 to the input of the state machine. The string input defines the state machine rules, giving 4 rules for 4 states: For example the second rule reads:

in state 1: if input = 0 -> remain in state 1 if input = 1 -> switch to state 3 if input = 2 -> switch to state 2 if input = 3 -> switch to state 1

Right of the state-machine is a little logic to fire a trigger (mouse released) when state 3 is reached. Additionally the state-machine is initialized (instant transition back to state 0)

The pressed state is displayed as a transparent grey button overlay, either beeing fully (normal, state != 1) or partially (pressed, state=1) transparent (upper right part of schematic). Thus looking pretty close to the scrollbar widget of the mozilla "modern"-skin.

The Sound Scientist ·

This is a nice one rl.... I'll have to try this one out for myself... 😉 😀 🙂 ..Thanks.. much love 😍 Peace and Science

Shifrin ·

Very interesting rl, I've not looked at the state machine before so this is gret for me to look at and fiddle with 😉

Thanks!

Shif.

Tom7777 ·

This looks cool, i also have not looked at the state machine yet so this is very useful. Was there suppost to be a download link? thanks

rl ·

it's not finished yet, so I just posted a picture of the centre-logic.

In the meantime print out a copy on a good colour printer and use a decent scan-to-osm-o-matic device.

The Sound Scientist ·

good one....! lol lol =) 😀 😉 🙂

fritzman ·

rl wrote: it's not finished yet, so I just posted a picture of the centre-logic.

In the meantime print out a copy on a god colour printer and use a decent scan-to-osm-o-matic device.

😀 😀 😀 Thanx Rudolf.

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.