channelling two inputs into one output - maybe expression?

slee's picture

hello,

i am looking for a way to channel two inputs into one output.

the concept is simply to output the one value that is changing.

the most logical thing would be an expression like this:

(a!=0)? a:b

but b does not get put through.

is there an object or macro to do this?

i also tried fiddling with conditions to flip the 1/0 switch in a multiplexer by evaluating whether one of the values is changing, but don't understand what to do.

any ideas?

harrisonpault's picture
Re: channelling two inputs into one output - maybe expression?

slee, I think the key to a solution is to better define "the one value that is changing". What does "change" mean formally? What does it mean if neither or both a and b "change" ? What is the range of values (boolean, number, image, structure)? If you can define these things, then putting together a simple patch should be straightforward. For example, if "change" means the last value of say a is different from the current value of a, you could use a Queue patch of length 2 and compare the values.

bwalkin's picture
Re: channelling two inputs into one output - maybe expression?

If a is a Number you might need to compare it with a tolerance like:

(a > 0.001 || a < -0.001) ? a : b

jersmi's picture
Re: channelling two inputs into one output - maybe expression?

Watcher and Sample & Hold might also be helpful. For ex., pic outputs a (number) if a changes, b if b changes (and a is not changing).

PreviewAttachmentSize
Screen Shot 2013-02-14 at 11.18.59 PM.png
Screen Shot 2013-02-14 at 11.18.59 PM.png54.8 KB

slee's picture
Re: channelling two inputs into one output - maybe expression?

thanks for your suggestions!

best of course would be to throughput any kind of value, to make this a universal utility.

bwalkin wrote:
If a is a Number you might need to compare it with a tolerance like:

(a > 0.001 || a < -0.001) ? a : b

ok, this makes sense, but b still does never get through. odd... maybe there needs to be something like an additional pulse to push the signal. no idea how to do that though. in maxmsp or pure-data, you sometimes have to trigger-bang one input to signal a change of another.

I'll use with jersmis solution, which works perfectly! My only thought about it is, whether an expression would be faster.

I plan on using this a lot (as in lots of times in one patch), so i need to get my head around, how to implement it best.

Save it to the library or import it via a composition importer or does saving it flattened have the best performance?