Apologies for spam; we've changed our policy by requiring approval for accounts, and deleted all existing spam and user - thanks for your help flagging content. We continue to test our forums and Vanilla software, aiming for release early in 2013. If you need to give us feedback outside the forum, contact us via http://createdigitalmusic.com/contact/ or on Facebook
best way to handle multiple instances of same patch in libPd?
  • 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?

  • pbrinkmannpbrinkmann
    Accepted Answer

    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 :)