Multiple coll objects using same data

R Kaelberer's icon

Can multiple coll objects refer to the same data file in a patch? It sees to work, but I haven't tested it extensively and now wonder if this is a bad idea for a reason I have not yet encountered. I'm doing this to tidy up a patch and make the logic easier to follow.

Roman Thilenius's icon

it works in most cases as described in the helpfile - that is what the option to give a name is for: [coll mydata]

but be warned... it can become confusing... for example when you edit a copy which is not set to "save with patcher".

best practice is probably that when you need it at 3 positions in your patch, you make a fourth copy in a special place which is the "main" one - and then edit only this copy.

R Kaelberer's icon

Thanks, Roman, for your quick response. I am currently using it with a data file saved with the patch. But thinking ahead, I'm including a receive node on the input of each coll object so that I can send a new file name to all the objects at once if the patch evolves into needing that feature. Not sure if it would be necessary, but I could also send any file editing messages to the same common receive input.

Roman Thilenius's icon

loading from disc at startup (loadbang) might fail when you have more than one instance.

R Kaelberer's icon

Yes. I think you have hit the unease that I have had in the back of my mind. I don't understand exactly how the files live in memory. Since my files are fairly large, currently 10,000 lists and potentially several time that, I guess I better get a better understanding before I go too far.

tyler mazaika's icon

Be careful not to conflate the coll "name" and the coll "file". By all means give all your coll objects the same name (and even better: consider using one of the special localizing prefixes like --- or #0 if they're appropriate).

Then just read a stored file into one of them and they will all have access to the same data. Or, as Roman mentioned, if you need embedded data (rather than read from a file): keep one in the top level of the patcher with the "embed" checkmark checked and leave that bit unset everywhere else. I usually keep this one isolated from any other connected objects and marked with a different color so it's easier to find.