Hi Miller,
On Wed, Dec 10, 2008 at 09:12:23AM -0800, Miller Puckette wrote:
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?
That would definately be a great start! An example program would be fantastic for now. So would this have to be compiled against Pd sources, or would Pd object files be archived in a .dll or .so files and then this main function would dynamically link against that? The latter would be preferable, but anything along these lines is really excellent.
Eventually it would be really cool to be able to go "apt-get install pdlib" or "pd-dev" and then link programs against Pd. It would also be great for programs to be able to control everything, so they could actually schedule Pd 'ticks' themselves, and they could get the contents of Pd's output buffers for mixing with their own audio stream or whatever. (Isn't that what Spore does?) I guess small steps first. :)
Thanks for your work!
Best,
Chris.
PS You might like to look at how Python handles pipes on Windows. As far as I know Python is bundled with an executable called 'w9xpopen.exe' which helps with interprocess communication. I might be way off the mark here though.