"permatoggle" object

jamesson's icon

I need an object that sends 1 (or a bang) when a given condition is satisfied but a 0 (or nothing) if the condition is ever violated and continues to send zero until it is reset by a different condition (even if the first condition is satisfied again). Isn't onebang supposed to do this? If so I am not using it right.

Peter McCulloch's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Here's a way of doing it with onebang.

jamesson's icon

Didnt even know that sel could have multiple arguments - very cool

jamesson's icon

Silly that there's no other way to do this tho.

Peter McCulloch's icon
Max Patch
Copy patch and select New From Clipboard in Max.

There are actually other ways of doing it. What you're describing is an AND sort of process where the outcome is dependent on the state of two things. Here's how to do it using &&. (you could also change togedge to sel 1)

jamesson's icon

You'd think that there'd be an object that does this in one step, is all I'm saying. I've built a patch that seems to do a relatively simple thing (will post later on)but is IMO inordinately complex as it is. I'm starting to see the limits of trading flexibility for speed.

Chris Muir's icon

Whenever I hear a request for an object to do one specific thing I get suspicious. There isn't a word for every thought, sometimes you have to use sentences. Do you need to do this sort of thing very often?

Do you _really_ need the speed that a native object would give for this? An abstraction would get you the same clarity of intent as an external object would.

Roman Thilenius's icon

finding different solutions for it depending on the concrete situation is the way to go.

to find out if one of up to 8 conditions are met

[expr (condition 1) * (condition 2) * (condition 3) * (condition 4) * (condition 5)]

should be the most straightforward solution.

and if you make bigger projects, you will eventually need to analyze the state of
buttons or things like that which are all but linear and contain various serial and
paralell processes- then the use of a bunch of basic objects like &&, >, route and
gate can be the best way.

in jamessons problem from above, [gate] would be the first object i´d put in my patch.

-110

jamesson's icon

Roman's multiplication idea is great - saves on complex && newroks

Peter McCulloch's icon

You can also use things like: vexpr $i1!=0 --> zl sum --> == (list length--use zl len)
if you want to evaluate whole lists of conditions.