performance optiization for interactive installation

Hi there Touchdesinger commmunity

I am a beginner in Touchdesigner and I am creating an interactive installation that detects presence of user(s) through webcam to play 7 layers of sound and video. The problem is when I run the whole network even in perform mode there is bad stutter and lag. I have tried lower resolutions than suitable for projecting the video but still it runs too heavily.Can anyone look at my toe file and suggest optimizations?
new shamseh.toe (154 KB)

by using the ‘probe’ in the tools of the palette you’ll see which operator take more juice.

Here it seems the worsts are the multiple analyseTOP and multiple top2chops (this one is always tricky)

I’m not sure what you’re going for exactly with the crops but I think you could have about the same result by reducing the input resolution (resTOP) so there’s less pixels to compute, blurring it to average the zones (a single blurTOP instead of many analyseTOP) and sampling multiple positions with a single toptochop using uv coordinates (instead of the multiple toptochop). Set the values on their own channels of 1 sample lenght and send that to a trigger chop, then into a null set to ‘select’ cook; it will cook only on demand (the wires will stop moving telling you that they cook only when a value changes - and prevend the chopExec from checking if conditions are met every frame). The chopExec would take into account what channel triggered it
ex: op(‘audiodevout’+str(channel.index)).par.active = 1

There’s many audiodeviceOUT. you could add audio together with a mathCHOP (Make sure volumes dont clip though) and send that to a single audiodevice out.

Thanks a lot guarna for your thorough help. Although I still have to figure out working with uv coordinates, it is now much better. The mathCHOP slows it down but I can do without it I think.