signal edge to click/trigger

Roland Cahen's icon

Triggering changes in a signal value using sah~ (from click to value) works using ramp~, but the revers operation (from changing value edge to click), seems to drop some changes.

See patch : I don't understand why I am loosing some clicks.

Would there be a way to set what~ 's sensitivity or another max object for converting more or less abrupt signal edges into triggers ?

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

Roland Cahen's icon

My actual hack is to add a delay and multiply the sah~ output with the delayed signal before what~, but this doesn't seem to work in the mc. version

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

Christopher Dobrian's icon

It seems you might be slightly misunderstanding the intention/usage of ramp~ and what~. Can you decscribe what you're trying to accomplish?

The ramp~ object requires a ramp duration, in ms, either in its argument or in its second inlet. You appear to have given it start point and end point arguments, which is incorrect. 0 and (almost) 1 are its default start and end point arguments, and those can be changed in the third and fourth inlets, but not by arguments. So, in your patch, ramp~ is attempting to do a ramp in 0 ms, which results in a single sample of 1 (which does trigger the latch behavior of sah~).

The what~ object expects a 0-to-1 ramp from ramp~ or phasor~. You can set what~ to send a trigger at specific points in the ramp. By default, with no argument, it sends a trigger when the incoming ramp wraps back to (approximately) 0 after completing its ascent. However, in your patch you are sending it random values from sah~ instead of a 0-to-1 ramp, so I believe it is only getting triggered when it sees those values decrease ("thinking" that that must be the ramp wrapping around).

Roman Thilenius's icon

that is usually a floating point problem, and it mostly happens at higher frequencies of the ramp/loop, but i never fully understood the pattern.

one solution is to + 0.5 and % 1. , and then sample-and hold at 0.5 instead of peak, another solution is to find when the delta < 0 (i.e. the one to zero transitions ib the phase accumulator)

Roland Cahen's icon

Thanks a lot Christopher and Roman for your anwsers. I see these objects are probably not the most appropriate ones for this purpose, which is to build a symetrical method:

A) To extract or generate 1 sample clicks from various signals (signal event to click)

B) To trigger signal events with 1 sample clicks (click to signal event)

I don't know how far this paradigm can be extended, but applying it to mc, it would allow interesting flow control.

Roman Thilenius's icon

oops, my answer is partially a bit off, i was under the impression that you wanted to receive bangs and not signal triggers... because of the appearance of the word "edge"... it is a bit warm here atm. :)

have you tried to generalize and isolate the problem by building a "change~" abstraction? it is a nice excursus for sure.

your "delay" thing - measuring the delta of signal values - also goes into the right direction.

Christopher Dobrian's icon

Roland,

Version 8.3 introduced several new objects for the sort of sample-accurate triggering that you seek. <https://cycling74.com/products/new-in-max/signal-music>

You're correct that ramp~ makes a ramp that can be triggered with a one-sample click, but you need to a duration for the ramp (and you can specify its starting and ending values with inlets 3 and 4). And the output of ramp~ (or phasor~) can be useful for governing musical behaviors, and even for generating other clicks (e.g. with what~), which, in turn can trigger other things (e.g. with sah~).

So, I think you're on the right track, and if you investigate those objects listed on that web page, and their help files, you'll surely find the solutions to get the results you're after.

--Chris

Roland Cahen's icon

Thanks Christopher and Roman,

Here is a consistant answer : this following patch shows how to sample and hold signal changes triggered by simple 1 sample clicks, as well as triggering clicks from instant changes in signals.

(change~ and mc.change~ are detecting instant changes in signal).

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

Next step would be to have an amplitude and a slope steepness threshold to vary or modulate triggers density from any signal.

Thanks to you and Victor Paredes.

Roland

👽!t W∆s ∆lienz!👽's icon

Here's a way using gen~, which is covered in the 'GO' book(Chapter 2), where you can detect the 'proportional change' (divide the 'difference' between current sample and previous(same as 'delta', also known as a 'discrete differentiator' 🤓), by the 'sum' of current sample and previous, then output absolute value from there). I then normalize from there using '> 0' to create full amplitude clicks same as original:

normalized absolute value of 'proportional change'
Max Patch
Copy patch and select New From Clipboard in Max.

______________________

@Graham - HA! Beat you to it! (also, hope you don't mind, i didn't give the full patch from the GO book, just a smaller modded version of it)