hi. i have a c++ custom op (chop) which has a lots of other ops (chop)(Satelits) connected on its inputs. the satelits are generating different arrays of data (pattern, s-curve … ) which goes into the main c++ op. inside ive a lot of loops.
im now looking for an efficient way to only iterate throug parts of the code, if the satelit has changes in its parameter values. ( a classical dirty flag)
You can’t specifically detect parameter changes, but you can tell if an input has cooked since you last saw it using its totalCooks member (OP_CHOPInput::totalCooks for a CHOP) - if the OP itself is unchanged (the opId) and the number of cooks is the same, then the output of that input has not changed.
“dirty” state only makes sense from the point of view of your OP - if another OP is connected to the same node but cooked several times before yours cooks once, the node will no longer be dirty from its point of view - but still dirty for yours. You will have to track state like I suggest - here’s one way to do it:
for (int i = 0; i < inputs->getNumInputs(); i++)
{
const OP_CHOPInput *cinput = inputs->getInputCHOP(i);
if (myInputState[i].check(cinput))
{
// The input has changed, do something with it
// (cinput might be nullptr if no input is connected)
}
}