Any object more stable than if?

alexandros's icon

Hi all,
I've trying to trigger a recording using the if object, so as soon as I get input from the mic, if triggers a toggle that starts the recording, which toggle, triggers another toggle as soon as it goes off (with an 'if $i1 == 0 then 1 else 0') to start the playback.
My problem is that the second toggle goes crazy, and I think it happens because the if object receives values constantly from the mic, so it constantly sends bangs.
Is there any other object that can be used in such a way, but can be more reliable? Select also won't work cause the value changes are very fast for it to catch.

Cheers,
Alex

Luke Woodbury's icon

Sounds like an 'envelope follower' might help you. Have a search, or there's a nice one here:
https://cycling74.com/forums/envelope-follower-3

Ben Bracken's icon

Maybe the change object?

seejayjames's icon

also maybe not a toggle, which flips when banged. try [led] or as mentioned, [change] will filter out repetitions.

you shouldn't need [if] in most Max situations. in your case you can use [select] and bang out a 1 if it's 0 and vice-versa, or even quicker, run the 1/0 through [!- 1] which will invert the values. if you're using [change] the really-fast-sensing shouldn't be a problem.

Roman Thilenius's icon

he could also include the functionality of [change] INTO his [if].

CowboyTakeTwo's icon

Not sure if it's fast enough, but try the external [pitch~].. Plug your audio in, and one of the outlets will bang whenever a peak in the sound occurs. So the first thing through the mic triggers it, then you could start recording and turn off the signal to pitch~.

pucklermuskau's icon

so you say he shouldn't need if in most situations, but is there a pressing reason not to use if statements?

David Butler's icon

I spent five years using if for simple routing before I discovered the split object....(hangs head in shame)

mzed's icon

This sounds like something you should be doing in the signal domain. peakamp~ is a handy object (puts out a float). Also average~ or avg~, depending on the situation, are a good basis for envelop followers. thresh~ is another one.

mz

alexandros's icon

Guys, thank you all for your replies. I still haven't really solved the problem, but it should be somewhere there. When I'll deal with the patch seriously again, I'm sure all these tips will be really helpful.
Once again, thanks,
Alex

EasyMac's icon

Not really sure, but perhaps [togedge] will help.