Forums > MaxMSP

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

Jan 20 2010 | 12:59 am

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

Jan 20 2010 | 1:09 am

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

Jan 20 2010 | 1:38 am

Perfect. Thanks!

Jan 20 2010 | 5:40 pm

what about ==~1. and then snapshot?

Jan 20 2010 | 11:37 pm

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

Jan 21 2010 | 2:50 am

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

Jul 11 2012 | 10:26 pm

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 :) :) :)

Jul 11 2012 | 11:16 pm

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?

Jul 12 2012 | 11:11 am

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"