Motion Dedection Triggered Audio

Jack Black's icon

Hello, I'm new at this forum and almost new at Max.

I just begin to work on a project that planned for my webcam triggers another audio when catches an action. When there's no action in the visual area i aim my patch to continue first audio track I have already managed the basics of my project (to play two sound sources seperately and got video from webcam) but i'm curious about the way to compound all those stuff. Which direction to go? Been googling about it for a while but couldn't find anything helpful yet.

hz37's icon

It depends on what your webcam can do. I have two of those motion detection devices as well, and I can choose between uploading a file or sending an email. These are events you can catch and react to. If you describe your options from this specific webcam, a more suitable answer may surface! Good luck,

Hens Zimmerman

Jack Black's icon

Thank you!

It's a Microsoft Lifecam1000. I believe that my project is doable with the basics, trying to simplyfy the project: The Cam is going to be placed in a dark room, when the lights are on i want my cam to bang an audio file. I can get video in Max with jit.grab object. When i try plug it to my sfplay object, it sends messages to my toggle button to on/off the audio, but continuously. What i wanted was just one shot! Would like to dip into yours.

hz37's icon

If I understand it correctly, you are fighting with the problem of hysteresis. You may want to define an upper threshold of light above which the sound file is played and a lower limit under which the sound file is muted. Am I correct? If that is the case, you can use [jit.iter] to add up the values of a (simplified) matrix and use that number to decide what you want to do. I'll post a quick and dirty experiment I did with my webcam on my Macbook Pro. If the light is on in the room, the large checkbox goes on. If it's dark it turns off. Maybe it is of help. Good luck!

Hens Zimmerman

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

MIB's icon

There is also jit.3m if you need more control and want to use the entire matrix rather than downsampling it.