how to generate a bang when signal reaches peak amplitude?

Sophia's icon

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

Luke Hall's icon

Try [delta~] which will output something positive when the [triangle~] is ascending and negative when descending, then check which using [

lh

Sophia's icon

Perfect. Thanks!

marlon brando's icon

what about ==~1. and then snapshot?

the_man361's icon

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

AlexHarker's icon

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

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

Alex

lem's icon

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

lem's icon

i'm trying to find out based on the previous replies on this thread, but [

the help file for it says:
"

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?

Floating Point's icon

must be a typo in the help file-- should read:
"
in answer to your original question use >=~ 0.5 and edge~

seabed's icon

Hi, I am doing some logical operations with signals and I want to count every time I have 1 as result and not only the crossings from 1 to 0 or vise versa . Any idea?

Peter McCulloch's icon

Send it into the left in left of +=~. It will do a running sum.