getting rid of signal 0 / storing signal values

Florent Ghys's icon

Hello,
This is probably a super simple MSP question, but I can't figure it out.

I am receiving a signal going from 0. to 1., and eventually 1. to 0. When the incoming signal reaches a low threshold (0.3 in the example), I want to output a signal 1. When the incoming signal reaches a high threshold (0.7), I want to output a signal -1.
My goal is to create a ping pong (palindrome) playback for groove~ (in MSP all the way through), so I need:
From 0. to 1.:
- 0. to low threshold > output 1.
- low threshold to high threshold > output 1.
- high threshold to 1. > output -1.
From 1. to 0.:
- 1. to high threshold > output -1.
- high threshold to low threshold > output -1.
- low threshold to 0. > output 1.

Here is was I have so far:

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

It's basically working except there is this unnecessary 0. in between the two thresholds.
Is there a way to get rid of a signal value in MSP? (like sel in max)
Or is there a way to store a signal value so it is sent later?
any help would be appreciated!
thanks
Florent

double_UG's icon

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

Florent Ghys's icon

thanks! this is awesome
how would you change the behavior when it's going from 1. to 0.?
I've tried something like this but something is wrong

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

double_UG's icon

change~

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

Jean-Francois Charles's icon

Or with less objects:

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

Florent Ghys's icon

yay! thanks guys!!
the thresh~ object is exactly what I needed!
best,
Florent

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