Hi All
What I’m trying to do is to be able to dynamically create instances of Pd, so I can have separate signal paths for each patch (i.e. not static). I'm actually working with libpd, but it's still pd under the hood. The reason being that I want to make an audio plugin for Logic, and hopefully other formats, so people can create their instruments and effects in Pd.
At the moment, since everything is static in Pd, my audio unit works fine when there’s only one instance, but sounds dreadful or crashes when there’s another one running – this is because its running the same instance of Pd, but calling libpd_process_float() for both patches twice in one block.
I’ve tried a couple of ways now to make libpd instanceable:
1. Make it into a dylib, then dynamically load it for each instance. This doesn’t work because when you load the lib a second time, the OS sees that it’s the same lib and reuses the one in memory (even if I copy the lib to a new location with a new name!!)
2. Hacking the Pd source. I’ve had a little bit of success with this, but I don’t really know what I’m doing, and was hoping there would be someone out there who could point me in the right direction. I’ve been trying to copy and clear the dsp_chain after loading each patch, and then swapping them back before each individual render. What I've got at present sometimes works for simple patches, but usually crashes pretty quickly.
Anyone have any ideas? Am I doomed?
cheers
Marek
-- w: www.mazbox.com t: +44 (0) 7866 141 047
I'll repost my comment from the noisepages where this started: http://noisepages.com/groups/pd-everywhere/forum/topic/multiple-instances-of...
Pd was designed to be its own process, hence the current structure. You can easily run multiple instances of Pd if you run them in separate threads or processes. Not ideal, but it works. The pd~ object lets you embed pd processes in other pd processes.
.hc
On Jan 28, 2011, at 7:31 AM, Marek wrote:
Hi All
What I’m trying to do is to be able to dynamically create instances of Pd, so I can have separate signal paths for each patch (i.e. not static). I'm actually working with libpd, but it's still pd under the hood. The reason being that I want to make an audio plugin for Logic, and hopefully other formats, so people can create their instruments and effects in Pd.
At the moment, since everything is static in Pd, my audio unit works fine when there’s only one instance, but sounds dreadful or crashes when there’s another one running – this is because its running the same instance of Pd, but calling libpd_process_float() for both patches twice in one block.
I’ve tried a couple of ways now to make libpd instanceable:
- Make it into a dylib, then dynamically load it for each instance.
This doesn’t work because when you load the lib a second time, the OS sees that it’s the same lib and reuses the one in memory (even if I copy the lib to a new location with a new name!!)
- Hacking the Pd source. I’ve had a little bit of success with this,
but I don’t really know what I’m doing, and was hoping there would be someone out there who could point me in the right direction. I’ve been trying to copy and clear the dsp_chain after loading each patch, and then swapping them back before each individual render. What I've got at present sometimes works for simple patches, but usually crashes pretty quickly.
Anyone have any ideas? Am I doomed?
cheers
Marek
-- w: www.mazbox.com t: +44 (0) 7866 141 047
Pd-dev mailing list Pd-dev@iem.at http://lists.puredata.info/listinfo/pd-dev
----------------------------------------------------------------------------
All mankind is of one author, and is one volume; when one man dies, one chapter is not torn out of the book, but translated into a better language; and every chapter must be so translated.... -John Donne
Thanks for the reply. My goal *is* to get multiple instances of Pd running in the same process. Having studied the source a bit, I see that it would be quite a tricky thing to do, but I still want to persevere, because I think it would be awesome to be able to use Pd patches in a DAW along side other plugins, and I think a lot of people would benefit!
I've pretty much finished the first version of the AudioUnit wrapper, but originally I was using ZenGarden (an awesome C++ clone of pd), which could be instantiated no problem, but decided to move over to libpd, just so it would have full parity with actual Pd. That's when everything started breaking!
cheers
Marek
On Fri, Jan 28, 2011 at 2:46 PM, Hans-Christoph Steiner hans@at.or.at wrote:
I'll repost my comment from the noisepages where this started: http://noisepages.com/groups/pd-everywhere/forum/topic/multiple-instances-of...
Pd was designed to be its own process, hence the current structure. You can easily run multiple instances of Pd if you run them in separate threads or processes. Not ideal, but it works. The pd~ object lets you embed pd processes in other pd processes.
.hc
On Jan 28, 2011, at 7:31 AM, Marek wrote:
Hi All
What I’m trying to do is to be able to dynamically create instances of Pd, so I can have separate signal paths for each patch (i.e. not static). I'm actually working with libpd, but it's still pd under the hood. The reason being that I want to make an audio plugin for Logic, and hopefully other formats, so people can create their instruments and effects in Pd.
At the moment, since everything is static in Pd, my audio unit works fine when there’s only one instance, but sounds dreadful or crashes when there’s another one running – this is because its running the same instance of Pd, but calling libpd_process_float() for both patches twice in one block.
I’ve tried a couple of ways now to make libpd instanceable:
- Make it into a dylib, then dynamically load it for each instance.
This doesn’t work because when you load the lib a second time, the OS sees that it’s the same lib and reuses the one in memory (even if I copy the lib to a new location with a new name!!)
- Hacking the Pd source. I’ve had a little bit of success with this,
but I don’t really know what I’m doing, and was hoping there would be someone out there who could point me in the right direction. I’ve been trying to copy and clear the dsp_chain after loading each patch, and then swapping them back before each individual render. What I've got at present sometimes works for simple patches, but usually crashes pretty quickly.
Anyone have any ideas? Am I doomed?
cheers
Marek
-- w: www.mazbox.com t: +44 (0) 7866 141 047
Pd-dev mailing list Pd-dev@iem.at http://lists.puredata.info/listinfo/pd-dev
All mankind is of one author, and is one volume; when one man dies, one chapter is not torn out of the book, but translated into a better language; and every chapter must be so translated.... -John Donne