Forums > MaxMSP

—unique id in subpatch

May 31, 2012 | 4:35 pm

i am aware that putting —before certain object creates unique ids when loaded, but i just tried this using a buffer object inside a subpatch (naming —test) but when i created a copy of that subpatch the id was the same.

is there a way round solving this? so if i have a subpatch containing such objects like buffers and i want mutiple versions of that subpatch within a patch that ids get created the same way?

thanks
ned.


May 31, 2012 | 5:42 pm

— works for unique s/r ids -and maybe other objects – in M4L. If you have an *abstraction* (not subpatcher) with an object with id of #0test, (as opposed to —test) each instance will have a unique number when instantiated (ie 1000test)


June 1, 2012 | 7:21 am

ok i’ll give that a go. i am trying to build a looper, with several instances of one looper within the whole patch, and i want to record into each of the individually, but i dont want to create several versions on the same patch and go in and rename all the buffers accordingly. with this method work for me?


June 1, 2012 | 7:34 am

I also built a patch using [buffer~] with the — trick in M4L and it worked. I had also tried the #0 trick with no success. So it only works within abstractions ?


June 1, 2012 | 8:22 am

Can’t speak with very much authority on what will or will not work in M4L, but in Max:

@nedrush, yes, should work if you use abstractions. The ‘alternative’ is to go with poly~

@Stephane: yes, as I said above, #0 will only work with abstractions, not subpatchers.



pid
June 1, 2012 | 10:29 am

it is very simple.

in Max (both Max and M4L), the #0 notation creates a unique id for that abstraction only, with complete depth (but only for that abstraction). so, if you made an abstraction called "hello" in your search path, and in that abstraction there was a buffer~ called [buffer~ #0_sillysilly 1000 1], and you then instantiated that "hello" abstraction in your main patch ten times, you would have ten completely different buffers with unique four-digit numbers before all their names. each individual buffer would be able to communicate only inside the instantiated abstraction with any similarly refering #0_sillysilly objects, never interfering with any of the other abstractions in your main patch.

in M4L (ONLY in M4L), the — notation makes something unique but to the ENTIRE device, regardless of whether or not the notation is inside an abstraction or subpatch or whatever. so, if in your "hello" abstraction you had a buffer [buffer~ ---sillysilly 1000 1], it would refer to the SAME buffer in all ten of your instantiated abstractions, and any other level / subpatch etc of your entire device. so writing to one —sillysilly would be writing to ALL —sillysilly ‘s.

remember, you can always pass #0 and — notations into abstractions as #1 etc arguments, to temporarily get round complex sharing scenarios. and you can easily send the #0 result out of an abstraction for other id-ing, for example a [loadmess #0] sent out an outlet.

etc.


June 1, 2012 | 11:33 am

success chaps! thanks.

[attachment=195517,3976]

Attachments:
  1. success.tiff

June 1, 2012 | 12:12 pm

Nedrush, just to be clear: the #0 argument should not have a space after it (ie #0test or #0_test etc. is ok) otherwise the object will interpert #0 and test as two seperate arguments, as appears to be the case in your image. Not sure if that’s what you actually intended…


June 1, 2012 | 3:22 pm

i’ll bare that in mind. many thanks.


Viewing 9 posts - 1 through 9 (of 9 total)