Multiple instances of devices

Questions and discussion about building and using Max for Live devices
Post Reply
hoffman2k
Posts: 14718
Joined: Tue Jun 15, 2004 6:40 pm
Location: Belgium
Contact:

Multiple instances of devices

Post by hoffman2k » Thu Apr 01, 2010 1:44 pm

For some situations, like with send/receive, we can use the --- prefix to create a unique instance.
But just like the API ID's, these numbers are unique to a session.

So how are you guys dealing with multiple instances of a device? Say you're using a device that uses pattr to store data. A pattr object needs a unique name, otherwise it could conflict with a pattr object in a different instance using the same name. You can't use --- because that number will be different the next time. The number needs to remain the same to load it with Parameter Mode.

I've come up with a few methods, but after seeing the downsides too late of one method, I figured I'd see how you guys may be solving this.

My first idea was to use the device location (tracks X devices Y). That keeps the pattr nicely locked to a coordinate but has the downside that you can't move the device.

My second idea is to use Coll to keep track of how many active instances there are. But that way might be tricky if you would delete device instance 2 of 4. You would either need to fill in that empty 2 with another instance or move on to 5. This might be too complicated.

My third idea is to generate a unique word like jitter does for its matrices. In this scenario you would only need to build a function that ensures a name is only generated once. This seems like the best idea, but I may just be missing the downsides.

Anybody else dealing with similar problems?

LOFA
Posts: 3364
Joined: Mon Jan 10, 2005 7:10 pm

Re: Multiple instances of devices

Post by LOFA » Thu Apr 01, 2010 9:17 pm

I design systems that allow the track ids to be the differentiating component.

I have two messages that sandwich the track id via append and prepend and this gives the path at the start of a set. This is my method for creating flexibility in API-dependent sets. Not sure if it is related to your specific inquiry, but this has saved me an infinite amount of time already, so I thought I would share.

I should really come up with a package of reusable bits and pieces sometime in the future.

hoffman2k
Posts: 14718
Joined: Tue Jun 15, 2004 6:40 pm
Location: Belgium
Contact:

Re: Multiple instances of devices

Post by hoffman2k » Thu Apr 01, 2010 9:24 pm

LOFA wrote:I should really come up with a package of reusable bits and pieces sometime in the future.
Shouldn't we all? :wink:

The track Id's won't work. Because they're unique in each set. What is [pattr 12foo] in one set may end up being [pattr 13foo] the next time. Its the same problem as with the --- prefix.

pid
Posts: 354
Joined: Thu Nov 05, 2009 9:51 am

Re: Multiple instances of devices

Post by pid » Thu Apr 01, 2010 9:33 pm

i am currently pulling my hair out over this issue my old friends.

how far have i got? as good as nowhere. tried the id's thing too, and attempted unique name but my logic was sucky. at the moment i cannot use any pattrised devices more than once in a set without big mess.

we need to solve it! before we all put together these 'reusable bits and pieces' of ours!
3dot... wrote: in short.. we live in disappointing times..

LOFA
Posts: 3364
Joined: Mon Jan 10, 2005 7:10 pm

Re: Multiple instances of devices

Post by LOFA » Thu Apr 01, 2010 9:45 pm

pid wrote:i am currently pulling my hair out over this issue my old friends.

how far have i got? as good as nowhere. tried the id's thing too, and attempted unique name but my logic was sucky. at the moment i cannot use any pattrised devices more than once in a set without big mess.

we need to solve it! before we all put together these 'reusable bits and pieces' of ours!
And I thought you were the man for the job :wink:

Sounds like an interesting challenge. Once it's verified that my current project is wrapped-up I will put some thought into this as well. I have been meaning to cut my teeth on some more advanced pattr-based systems.

pukunui
Posts: 405
Joined: Thu Jan 29, 2009 10:26 pm
Location: Los Angeles

Re: Multiple instances of devices

Post by pukunui » Thu Apr 01, 2010 9:50 pm

The pattr system is restricted to devices, you can have multiples of the same device with the same pattrstorage name and pattr names and they will not conflict.Are you talking about writing state to disk?

-A

hoffman2k
Posts: 14718
Joined: Tue Jun 15, 2004 6:40 pm
Location: Belgium
Contact:

Re: Multiple instances of devices

Post by hoffman2k » Fri Apr 02, 2010 3:36 pm

pukunui wrote:The pattr system is restricted to devices, you can have multiples of the same device with the same pattrstorage name and pattr names and they will not conflict.
Now I'll be damned. You're right!
And now it hits me how you guys are using those pattr API abstractions all over the place, I feel even sillier.
Coming up with solutions for problems that don't exist.. Its a loss of time, but my max chops improve.

Thanks Andrew. For the answer and for how pattr works :)

pid
Posts: 354
Joined: Thu Nov 05, 2009 9:51 am

Re: Multiple instances of devices

Post by pid » Sun Apr 04, 2010 11:14 am

man!
3dot... wrote: in short.. we live in disappointing times..

cyclone975
Posts: 25
Joined: Sun May 31, 2015 7:22 am

Re: Multiple instances of devices

Post by cyclone975 » Tue Nov 24, 2015 4:34 am

Unpopular needs right here: Is there any way for pattrs to work more globally? I would really like to access values from one instance of a device through a second instance's interface.

RadioOnMars
Posts: 36
Joined: Tue Oct 13, 2015 9:06 am

Re: Multiple instances of devices

Post by RadioOnMars » Tue Nov 24, 2015 12:04 pm

in case it is useful, multiple device checker looked something like this:

<pre><code>
----------begin_max5_patcher----------
1971.3oc6b0ziaaCD8r2eEDBEnWbL3mhT4PAZZA5odpGJJRJVPaw0VoxRFRT
6lsA4+dIoj7Zu0VhdWaFilBjnHQJZM7wYdyvYHxmuYRz7xOopi.uE7dvjIe9
lISbMYaXR2yShVK+zhbYs60hJTOTN+iQSa6Rq9j10bp5NUUd4C8cTqeLW45o
ukhl0YE4Js6mA8TikM5m2ZaS5G2nZkrnHve100Fodwprhk2VoVna6kw3yfSA
Iw1qb28X7L31gjk5jCiT+FLMx11Wt4F6koutobd18pY5UY0op6yVnN9L+txB
cc1e6ZDAMxm2.B4X.xbYwxnofnrBc++LHDEisvBiNS.IBBwfSINbBdXbBIR1
U3KjqamQ+XUlLG7tx7zWBNtnb8ZkUfeFPZwPfSpUUfkkpZPVA3wxlJvZo4t9
dVTVTXlQpTvCY5UfmA+.YMndU4CE.y6p.8ej7LyXJaJbeI5qQ4Ddb3kxIyDI
wTrAXc.MhYWlAwGAdwjWB7MuQqKKtLFXN8ogzf3L6DR.EyXFSM2C1qGV44LZ
jMNuxdVW3Sw55kQ2fQwyR3IbRrwJhPb1UwCQ5fNtoz+oAJFDMizYUXt5APQN
uH0w3aRKK9dMnVUjBjEOBVWZ3KVqpqkKMTON1CCWhiTx7m4JyrBjpLSbU5AY
UHW.De.xFhwEmwFDgbL3HriogxOBjhChx2RoVAP.zqS4CeFU9HLTqpV7LbLU
jXc4wFR4i8MJPgLz3bbKcFF6rRGFnvgQkRClCfWBxLrOwTMrC.Gou.05oev.
NQIggRyQFALSz4l.kJuCzFST8A4qvgkuBiPyvcJXjV+kBg8p89CgYwmWHqiY
+eAY0J8UDckH1RpGm3vGbh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
3ze7Q8AEN0Gmlwn16IASdH9n9HBG+iOpOga0B4C6LJfrgn8LjOB4SXEmwfGR
3DGhOJO7vwEl3ypENrbgHObUDHpPeTdBGSH1GaKBKrxyn3Sb3jGe7jRBm0tO
F6giY1Vlows0SBF2CwGOW3.FmgWZyvvIO9n9vBn7v7AePgMtPjO6KkDF4w9o
vWMQ9P3WWjyDtGKWz.pN6iyBZ3Vunvqp8UPw9FoZXjGuHeBn33iyTT3B0vGi
cT37kx8QdBm3HDWWoLzqL97RoBaS3qbyl6sGuk1eSmjDsV9wxJ6i7otGyJZe
z8KFUotOq+8cE2NRVsXUlVsP2T0lD7O0Ubhn0kopphlrtiMiACtoKY4OKIyO
kOd6wn92zRcS8s+ppnoMs01i8urIWuOdMe4cY44KJyaEucOyN8YSOps2ocMu
8ceO.NCmPQHgA7lQPDNN1cm4FFaGS1twf5GDkQSfX6qRiwbJycm.SXD6cvmM
L7SeKHJo8K.SDPZ6cllrEtX2gIsGcbGzx2dtIMJLUkaJq5W4MCMY662nKWVI
Sy5xoObuCmzzN0sJSuOuFEQty2d+X1U8b6hQaMgdWdip++oEN7BgbwByGXOv
kf3wTtcZFuEwRrM0OgOiB3uToTEmrDBshDyVsM2RGJVXVPO+B2enxyKeXXoa
25j8dWkxXIPnXqQ8AjdAlgbvKWfDHmtGKgY0GegS.yX9xM+S0DlI3
-----------end_max5_patcher-----------
</code></pre>

ned rush
Posts: 402
Joined: Wed Sep 23, 2009 1:45 pm
Contact:

Re: Multiple instances of devices

Post by ned rush » Tue Nov 24, 2015 3:11 pm

#0 isn't it? I might be wrong.

cyclone975
Posts: 25
Joined: Sun May 31, 2015 7:22 am

Re: Multiple instances of devices

Post by cyclone975 » Wed Nov 25, 2015 8:10 am

OK RadioOnMars,
I've been working through your example patch you sent me. I understand everything except the final step, where live.object gets updated with either a 0 or a 1. I'm super new to the Live API, so forgive me that these are probably reallllly dumb questions, but:

1. live.object gets fed id 2, which is referring to

Code: Select all

path live_set tracks 1 devices 0 parameters 0
, right? How do I know what parameters 0 would be in the context of my patch?

2. Is 0 or 1 going into the live.object's first inlet simply going to set ... parameters 0 to 0 or 1? or is it a little more complicated than that?

Thanks for your patience!

dataf1ow
Posts: 230
Joined: Wed Oct 08, 2008 4:28 pm

Re: Multiple instances of devices

Post by dataf1ow » Wed Nov 25, 2015 3:37 pm

Parameter 0 is always (I'm almost positive of this) device ON for any given device.

Post Reply