Pure Data help. How to use conditional logic in Pd

GingerDom picture GingerDom · Dec 6, 2016 · Viewed 7.7k times · Source

I've confused my myself a lot and need your help. I'm trying to make a little function in Pure Data which says when the toggle is on it sends a 1 but when it isn't on it allows the computed value through.

So the program works a value 1 or 2 and when the toggle isn't on the computed value goes through, but when the togggle is on it sends 1 through.

I would show my code but its Pd so I can't copy and paste it. My attempt so far is making use of spigots but that isn't working its still sending 1 through no matter what the toggle is doing, and I know for a fact the computed value changes.

In normal code I would do something like:

value = computedVal

if (toggle == 1) then return 1;

else return value;

Answer

Max N picture Max N · Dec 7, 2016

There is more than one way to solve this. Assuming that you want a 1 to be sent out each time the computedVal changes while toggle is 1, it could look like this:

conditional statement