Hi guys, I'm working on a multi-track music app where I have created several sample-based instruments as Pd patches. I'd like it to be possible for the user to load more than one instance of an instrument. For instance, they might want to have a lead part track and a rhythm part track both played by the acoustic guitar instrument. I've tried interlacing the parts to play on a single instance, but my instruments are designed with 4 to 8 voices which can quickly become swamped by such an approach.
I use a lot of send/receive messages between Java and Pd. I am aware of Pd's namespace issues but do not understand the $0 stuff mentioned in this thread http://createdigitalnoise.com/discussion/110/is-it-possible-to-run-multiple-patches-or-instances-of-the-same-patch-simultaneously/p1
So if I have a [r guitar_notes] object in my patch, and I've got two or more instances of the patch loaded, is there a best way in libPd to direct messages sent from Java to the intended instance?
Replace [r guitar_notes] with [r $0-guitar_notes]. Then, when you open your patch with libpd, Pd will expand $0 into some value that uniquely identifies the instance of the patch, and you can get the $0 tag of that instance from libpd and save it in some variable, say dz_tag. Now you can reconstruct the receive symbol in your code as dz_tag + "-guitar_notes" and send messages to that symbol.
Thanks, Peter! Yeah I just checked and see that openPatch() returns the $0 identifier int for the instance. So can I just prefix any named object like a table or internal message reference with $0- and it's like I have separate namespaces?
That's right!
awesome, thanks so much :)
It looks like you're new here. If you want to get involved, click one of these buttons!