Polybuffer subpatch with dynamic name

David Medina's icon

I want to do a subpatch that I could use to load different folders with a few hundreds of samples each.

I'm trying with this but I can't name the polybuffer inside with a name set from the inlet (in this case and example would be "silabas_mia". The idea is that this name changes in every instance of this subpatch. How can I do this? Thanks for any advice!

Max Patch
Copy patch and select New From Clipboard in Max.


11OLSEN's icon

You mean #0 which provides a unique id per patcher? Or #1, which is replaced with the 1st argument you set when creating the object or manually later.

David Medina's icon

The things is that I need that the name I input to this subpatch would be the same to refer the internal samples in other places of the main patch. So if I input "mia_syllables" to the subpatch this can be used in the url of the folder to do the folderload in the polyBuffer but also as the name of the polyBuffer—so I can use "mia_syllables.147" in other places to access and play the sample #147..

The thing with #0 is that generates a random 4-digit number before the name of the variable? in that case I can't access the samples with the same name (and I won't know what numbers it attached to the original name)?

11OLSEN's icon

ok, you can't name the polybuffer after it has been created. you can name it [polybuffer~ #1] and save the whole thing as an abstraction. Then when you need it create the object with the name arg. [myabstr silabas]

11OLSEN's icon

Instead of changing the name with the inlet, you then have to replace the complete subpatcher with the required name as argument.

11OLSEN's icon

That's one way, another is to replace the polybuffer with a new name via scripting

11OLSEN's icon
Max Patch
Copy patch and select New From Clipboard in Max.

I think you have to check the help patcher for [combine] again. There are no %s placeholders with this object.

David Medina's icon

I did this and works for the first instance. I just need to put the name in the control like [loadPolybuffer silabas_mia]. This works well and all the substitutions of #1 occurs and the polybuffer load the samples from the same name folder. The problem happens in the second instance, e.g.: [loadPolybuffer silabas_miguel] —I encounter an error when I try to join "tts/" and the name of the folder/control received as #1. In the first instance works, but in the second the sprintf appears as "%s". The question would be then how can we join strings with #1s?

The abstraction/subpatch:

loadPolybuffer.maxpat
Max Patch


11OLSEN's icon

check the order of your messages! the first inlet of combine triggers output. [trigger] outlets go from right to left. Also check my previous post.

David Medina's icon

}Oh, I get it! the patch calling itself with the renaming via script works really great.

Thanks a lot!