Fade out audio after crossing video motion threshold

iamdabobo's icon

I'm having trouble googling this because I don't know what to call it.

Basically, I'm using a webcam to control the volume of sound in a room. If nobody is in the room, the sound shouldn't play. However, this needs to have a reasonably long time-out value so that it doesn't accidentally stop playing while there are people in the room.

So I've got a jit.qt.grab, going to a jit.change with a reasonably high threshold value. My playback is controlled by 4 play~ objects through a 4-channel live.gain~ object.

How do I extract the motion data from jit.change and give it to live.gain with a timeout so as to accomplish my purposes?

Thanks in advance

LSka's icon
Max Patch
Copy patch and select New From Clipboard in Max.

I'd suggest you using cv.jit externals to perform a more precise tracking. http://jmpelletier.com/cvjit/
In this example, I'm using [cv.jit.label] and [cv.jit.blobs.centroids] to track the presence of people in the room.
Then, the output of the [cv.jit.blobs.centroids] triggers a [line~] object connected to a [*~] generating a volume ramp.

hope it helps.

Stephane Morisse's icon

The qmetro can do all this voodoo by itself ? :))

LSka's icon

Yes, qmetro is a very powerful object, if you connect it to something else :)

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

Sorry for messing with copy & paste....
Here should be the right patch

iamdabobo's icon

LSka, I'm not sure what your example is--the posted code is just a qmetro.

I have a metro connected to the qt.grab, which outputs fps (i guess?) Not sure how it does that. However, I'm having a hard time getting reasonable results with the actual fps numbers. It doesn't just nicely decrease to zero, so I can't just pick an fps threshold (I think)

I'm currently looking into cv.jit; I'll see how that goes.

edit: sorry, I just saw your updated post.

iamdabobo's icon

edit: i'm dumb, thank you so much!

Thanks

bule's icon

Thank you for this patch LSKA !