## how to generate a bang when signal reaches peak amplitude?

Jan 20, 2010 at 12:59am

# how to generate a bang when signal reaches peak amplitude?

I need to generate a bang every time my MSP signal reaches it’s peak amplitude. I only need it to work for a triangle~ that oscillates from -1. to 1. The problem is that snapshot~ doesn’t seem to ever capture the 1. and I am not aware of something like sel that works with signals.

Thanks,
Zach

#47899
Jan 20, 2010 at 1:09am

Try [delta~] which will output something positive when the [triangle~] is ascending and negative when descending, then check which using [< =~ 0] and finally detect the changes with [edge~].

lh

#172269
Jan 20, 2010 at 1:38am

Perfect. Thanks!

#172270
Jan 20, 2010 at 5:40pm

what about ==~1. and then snapshot?

#172271
Jan 20, 2010 at 11:37pm

dont think you can use snapshot, as the signal might hit one and then pass by so quickly that snapshot may not necessarily see this

#172272
Jan 21, 2010 at 2:50am

The real problem with looking for a signal equal to 1 is that the oscillator probably won’t hit 1. It might happen every now and again, but most often the 1 of the waveform would theoretically fall between samples, and hence if you examine the signal out of the object you won’t see a value of 1.

In the past this ‘issue’ came up quite a lot, so actually this made it to the Max FAQs as you can see here (5th question down):

http://cycling74.com/support/faq_max4/#6

delta~ based approaches for this task are generally much more appropriate, simpler and accurate then any methods based on detecting a particular value….

Alex

#172273
Jul 11, 2012 at 10:26pm

hi,

i need to output a bang each time a square wave changes from 0 to 1, or from 1 to 0. how might i do this??

thanks :) :) :)

#172274
Jul 11, 2012 at 11:16pm

i’m trying to find out based on the previous replies on this thread, but [< =~ 0] is really confusing me:?

the help file for it says:
“< =~ outputs a 1 when the left input is less than or equal to the right output and a 0 when it is less than the right input"

maybe i’m being dim, but doesn’t that mean it outputs two values with a less than zero input?

or just any help with my question in my previous post?

#172275
Jul 12, 2012 at 11:11am

must be a typo in the help file– should read:
“< =~ outputs a 1 when the left input is less than or equal to the right output and a 0 when it is MORE than the right input"