Delaying output of number until new number is recieved

Noah Park-Roesel's icon

Hi, I am currently building a patch I am struggling massively with what seemingly should be a very simple task.

When a number object is at 5, for instance, I want the patch to output the previous number, effectively storing what it was before it was changed. So if it was a 5, and is then changed to a 7 I want to be able to store the 5 to use in a different place. And then when the same number object is changed from 7 to a 3, I want that to in turn change the same "stored" number that was previously a 5 to a 7 and so on and so on.

I have looked up "how to delay output of number until the new number is received" and other things along those lines but surprisingly have found nothing.

I would just use a basic delay object, but I want the delay to be input-dependent, not time-dependent.

Please help!!!

TFL's icon

You are probably getting flooded by results using the [delay] object, which is a time-driven delay, while the logic you want to achieve is event driven and don't even require any kind of temporal delay. It's just about holding in memory a value until the next one arrives.

Check the doc for hot and cold inlets, the [trigger] object, and also [int] or [float] or [zl.reg] that you'll be able to use to hold your data.

Wil's icon

two ways - [int] and [zl reg]


Max Patch
Copy patch and select New From Clipboard in Max.

double_UG's icon

bucked

Max Patch
Copy patch and select New From Clipboard in Max.

Source Audio's icon

Problem with t i b is that

initial output would be a zero,

unless you initialise it to some needed value. that in case of int.

if you use zl.reg, then no output at all...

Wil's icon

yes, initial conditions --

up to the composer

bucket doesn't solve it

Source Audio's icon

it would be easy to patch something if conditions are clear.

conditions are:

1 what initial input number does

2 if both (current & previous) number need to get output

or need to be available.

if it is as title describes :

"Delaying output of number until new number is recieved"

then initial number is not output till 2nd one comes in.

bucket does it well.

Pedro Santos's icon

Another solution, using zl.stream.

Max Patch
Copy patch and select New From Clipboard in Max.