Initial clipping in Gen~

Daniel Neshama Itach's icon

I've come across a seemingly straightforward problem that has me stumped.
I'm looking to address it using gen~.

Specifically, I'm aiming for an initial clipping effect (let's say with a range of 0 to 1)
However, I want the clipping to cease once the input surpasses the lower clip value (set at 0, for example).

What would be the most effective approach to achieve this?

Graham Wakefield's icon

I'm not entirely sure what you mean -- do you mean that the clipping is bypassed once the input is above zero?

The basic clipping between 0 and 1 can be done with [clip 0 1]. To switch between clipped and non-clipped signal you can just use a [switch]. The condition of the switch is whether the input has ever gone above zero. Testing for above zero is just [> 0]. The only tricky part is the state change once you've gone above zero. That means you need some kind of memory element -- it could be a [history] for example.

With a history you can make a feedback loop: [in 1] -> [> 0] -> [or] left inlet -> [history] -> [or] right inlet. That will open once the input goes above zero, and once it is open it will stay open, because the open status (held in the [history]) feeds back through to the [or].

If you want to close it again you could add a [switch 0] between the [history] and the [or] (route the [history] the the [switch 0] right inlet. Now you can send any nonzero value to the [switch 0] left inlet to reset it.

Now the output of the [or] can also be routed to your [switch] between [in 1] and [in 1] -> [clip 0 1].

Stevon's icon

I would have a similar approach on this as Graham, kinda like this:

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