writing Pd external help c++
Posted: 25 July 2007 10:28 AM   [ Ignore ]
New Member
Rank
Total Posts:  59
Joined  2007-07-09

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_xmax = (whatever int);
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, x->storepointer[bn].xmax());
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

Profile
 
 
Posted: 25 July 2007 08:47 PM   [ Ignore ]   [ # 1 ]
New Member
Rank
Total Posts:  59
Joined  2007-07-09

ok I worked it out. I just used pointer = new Intstore[anumber] at every frame and it seems to work.
Any Pd users out there interested in this let me know.  It seems like most everyone is using vvvv or flash.
Alain

Profile
 
 
Posted: 25 July 2007 11:42 PM   [ Ignore ]   [ # 2 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  1348
Joined  2007-04-08
ding - 25 July 2007 08:47 PM

ok I worked it out. I just used pointer = new Intstore[anumber] at every frame and it seems to work.
Any Pd users out there interested in this let me know.  It seems like most everyone is using vvvv or flash.
Alain

Hi ding,

I’m a PD user, I’m very interested in testing or using the object you made. Feel free to post the file here or PM me. I will probably be using PD for sound applications I will be creating and it sounds like your work can be very useful.

Thanks!

 Signature 

My Multitouch Blog
My Youtube
Multitouch FAQ - Need Help? Click here!

Profile
 
 
Posted: 26 July 2007 08:57 AM   [ Ignore ]   [ # 3 ]
New Member
Rank
Total Posts:  59
Joined  2007-07-09

I am just finishing the filtering external right now.  I am almost done.  I think I might have something by next week. Stay tuned.
Are you planning on using Gem or PDP for the graphics part of it?  BTW this is compiled for os x using xcode.  I will probably need some help figuring out how to make a makefile so as to be able to compile for windows and linux.
Alain

Profile
 
 
Posted: 26 July 2007 07:53 PM   [ Ignore ]   [ # 4 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  1348
Joined  2007-04-08

Ok, sounds good. Just let us know about your progress. I’ve never written a PD external before and don’t know much C++. I’m on windows, so hopefully we can find a way to port it over.

I will probably using flash, vvvv, or processing for visual feedback since I’m not that fond of GEM or PDP in the “looks” department. Plus, I’ve really only used PD for music and haven’t done much visual work within it.

 Signature 

My Multitouch Blog
My Youtube
Multitouch FAQ - Need Help? Click here!

Profile
 
 
Posted: 06 August 2007 03:39 PM   [ Ignore ]   [ # 5 ]
New Member
Rank
Total Posts:  1
Joined  2007-07-11

how we can have acces to ur patch?
thx

Profile
 
 
Posted: 09 August 2007 06:07 PM   [ Ignore ]   [ # 6 ]
New Member
Rank
Total Posts:  59
Joined  2007-07-09

I’m still working on it.  Things have been crazy at my house and I have had little time to work on the project.  I have a beta version that is os x PPC if you want it I can post it. I would need the help of anyone that wants to compile it for other systems.  If you are willing let me know.
Alain

Profile