I am almost finished writing a Pd external to do blobtracking but I have hit a problem that has me scratching my head. I know I might not get much help here but maybe someone with a good knowledge of c++ can help. I am desperate. I have also posted in the pd development forum.
I have a class that stores a few integers and returns them. something like this:
class Intstore {
public:
Intstore();
int m_xmax;
int m_ymax;
int xmax() {return m_xmax};
int ymax() {return m_ymax};
}
Intstore *storepointer;
I also have a function to store arrays of the class like this:
void myexternal :: addToArray(Intstore *pointer, int arraynumber) {
storepointer[arraynumber] = *pointer;
}
So when I store arrays I do something like:
Intstore *storepointer = new Intstore();
for (i=0; i
storepointer->m_ymax = (whatever int);
addToArray(storepointer, i)
}
So to send it out an outlet I do this:
t_atom*ap = new t_atom[2+anumber*2];
for(bn=0; bn
SETFLOAT(ap+bn*2+1, x->storepointer[bn].ymax());
}
outlet_anything(x->outlet1, 2+anumber*2, ap);
This works fine for regular operations but when I get a heavy cpu load (like capturing from camera) I get a Pd crash like this:
Thread 0 Crashed:
0 pd 0x00061c40 outlet_anything + 80
Now if I remove the “addToArray(storepointer, i)” function even on capturing from camera the external does not crash and works perfect but odviously my data is not passed out of the outlet.
Is there a mistake I am making here somewhere? Is there a more simple way to do this? I dont undestand what is happening here or why its crashing?
BTW It is working perfect tracking quicktime movies but the camera tracking only works if I exclude the addToArray function. This really has me scratching my head!
For anyone who is interested in Pd I will post a link here in the forum when the external is finished.
Sorry for the long post,
Alain
