I can imagine simply writing an example program to do this (putting some boilerplate first and then a rewritable main at the end). It would look more like this:
/* don't touch me */ .... /* but replace the following with your code */
main() { pd_startthread("arg1 arg2..."); /* do anything you want */ pd_send("foo bang;"); /* etc */ pd_endthread(); }
... the idea would be that pd itself would live in a subthread and you'd be able to send messages to it and even somehow get return callbacks. This wouldn't be like pd~ at all, since in this scenario Pd would open audio and MIDI as needed and schedule itself (with pd~ the subprocess slaves itself synchronously to the parent). Another restriction would be that you could only have one Pd thread (it isn't thread-safe!). On the other hand, this would work fine in Windows, which pd~ doesn't (since windows appears not to offer pipes unless you add a library with funny licensing restrictions.)
Would that be a useful thing to have?
cheers Miller
On Wed, Dec 10, 2008 at 11:28:22AM +0000, Andy Farnell wrote:
Yes! Even if it's already 'doable' having a clearly abstracted libPd with documented API is clearly the next step in Pure Data development. This should be an overriding consideration in all current dev directions.
On Wed, 10 Dec 2008 20:07:04 +0900 Chris McCormick chris@mccormick.cx wrote:
On Wed, Dec 10, 2008 at 09:05:16AM +0100, IOhannes m zmoelnig wrote:
Zach Dwiel wrote:
Hello
first of all, there is no official API.
It would be so nice if there were an easy way to invoke Pd as a library from within other code. I know it's possible to do this (Spore, pd~, RjDj, Pd browser plugin), it's just that it requires writing a bunch of non-trivial support code that must be re-written every time. It shouldn't have to. Pd -nogui could and should be as easily invokeable as any other library.
For example, I just wish it was possible to go:
#include <pd.h>
*PDInstance pd = make_pd_instance(); pd->init(/* ..args.. */);
while (1) { /* Do stuff here */ pd->schedloop(); /* Do other stuff here */ pd->sendMessage(";my-receiver bang;"); }
Ok maybe not quite as easy as that, but I reckon you'd see Pd used as the audio engine for loads of other apps and games if this was simple. There has already been interest from e.g. the Blender project and the several other apps that already embed Pd.
If this is already easy and I have just missed something obvious, please let me know. (Sorry for not contributing code.)
Best,
Chris.
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
-- Use the source
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list