how to observe the state of all the clip slots ?

Learn about building and using Max for Live devices.
Post Reply
chapelier fou
Posts: 6012
Joined: Mon May 15, 2006 12:15 pm

how to observe the state of all the clip slots ?

Post by chapelier fou » Sat Nov 02, 2013 9:47 pm

i want to observe 'has_clip' property for each clip slot. But obviously i'd like to avoid using like 100 observers for this.
i am basically re-writing the launchpad session mode and i'd like to know how to light on pads when there is a clip in it.
I know how to do to get all the 'has_clip' with one live.object per track, but it won't automatically update if i record a new clip or manually create one, for instance.
Thanks for your help !
MacBook Pro 13" Retina i7 2.8 GHz OS 10.13, L10.0.1, M4L.
MacStudio M1Max 32Go OS 12.3.1

broc
Posts: 1151
Joined: Mon Jul 26, 2004 8:37 am

Re: how to observe the state of all the clip slots ?

Post by broc » Sun Nov 03, 2013 10:15 am

You can use [poly~] to generate multiple observers.

chapelier fou
Posts: 6012
Joined: Mon May 15, 2006 12:15 pm

Re: how to observe the state of all the clip slots ?

Post by chapelier fou » Sun Nov 03, 2013 10:24 am

can you ?
i am not familiar with ploy~ but i'll give it at try.
if by chance you wouldn't mind sharing an example that would be great.
thank you !
MacBook Pro 13" Retina i7 2.8 GHz OS 10.13, L10.0.1, M4L.
MacStudio M1Max 32Go OS 12.3.1

broc
Posts: 1151
Joined: Mon Jul 26, 2004 8:37 am

Re: how to observe the state of all the clip slots ?

Post by broc » Sun Nov 03, 2013 12:53 pm

The only limitation is that the number of observers (voices) can't be changed dynamically.

See this thread for related discussion.

http://cycling74.com/forums/topic/live- ... side-poly/

Below is a poly~ patcher for observing 8 tracks x 8 slots (ie. 64 observer instances).
It outputs the list <track index, slot index, new state> if a clip is added or removed.

<pre><code>
----------begin_max5_patcher----------
720.3ocyXtsbaCBDF9Z4mBFMs243JPm6csuFcxnAKQhoUBzHvoIMS5yd4fcq
cSbiDUFmarFVXz9yG6trxOtHHbM+dhHD7QvW.AAOtHHvXRaHX23fvN780sXg
YYgLx24q+Z3R6TRx8Ri4db82.T.c+D2vYRFtiXl7SCTbK3y71l8Sy11QYsDo
4ch1YrGKq2PY2VMPpkVMAihVEsD.KLORRrCVEAt9.+Hn+v3GndQVyzFiiUJ8
JXzANkuUt2qvcVsljOzSrtLLDbsdlmVrP+yx+Ot7dPwbijDKRRx0OhQqRmLR
RlHQnL4rBkOL+PYWbRRgyPI9BCkVNtYMlcqKjA9pjwl5jl4RBDbhjwrKlSzb
E.dlhWhJMwKwNfkxKc7B8NxJ9ZAY3NxvLim7LcBTbFRykbjCzI+koC5jEcWZ
J7taZA9NRSk58nTTEVJGnq2Js2SE7aJEDV0SFDTgjvpsRwX2f2oB4NhPfuk7
760F3JmHe.rAKppao8yLoUgdZRGaXbYpgzYShzEWxq2jf0f14thEzTkBUV3b
tILahge1BuyLbLYnpM3lySIcTlIbIE5BfNQTS7+L+zY.cxrKEb.ZLUIHRfbP
0Do.7NHPmnUIZ4R0Hz4ozOJFdPmkSLmKM9Rlz0OP5IrFfhYybjEpLwxFCTxJ
bHxJ6M.YNOTIIJ247szKZQ5MTQOu8geddpCk6dqknIVlV2C0x4uUJkebqCyQ
DzjXtYON0khzuLchlVSR5Ypp4ccDlc2F97tjLhRceE6u+u.LaLs8igpfucnd
+gx9OxF7m8VCQHoLrjxYGrnriVyFZSCgc3Fpi1zyUms6zvINgGqjRFghLxF5
MIMJJouawiXJdrXxeRpbDRJ4Mmh76wl9ixeUIg7pjRGSjjWUDZDJpzuLZToa
EdUSYionjeCtKNpr7InjeuNANFLU3eI8ZXJ2q2vULBHk6UHkelitUCdZwufC
dYsV
-----------end_max5_patcher-----------
</code></pre>

Myralfur
Posts: 114
Joined: Wed Feb 18, 2009 4:53 am
Location: London, England
Contact:

Re: how to observe the state of all the clip slots ?

Post by Myralfur » Mon Nov 04, 2013 3:42 am

using a poly~, as brock has shown, works well. the max voice number for poly~ is 1023 though i think. i'm also not sure what the cpu usage would be like with that many observers.

the other option is to only get the ids of clips, rather than observe them, and try to update your stored array of clip ids depending on what part of the session view you are focused on.

so you could observe the ids of all tracks and scenes, you can observe them all as a list as they are children of the live_set. then whenever either the tracks or scenes ids change you iterate through all of the tracks getting all of their clip_slots ids. clip_slots ids can be got or observed as a list, they're a child of the track. when you have all the clip_slots ids for every track you then iterate through all the clip_slots on each track getting the clip id, clip being a child of the clip_slot.

obviously there are no observers on the clip_slots in the example above so if you move clips around or record new clips the stored array of clip ids won't be updated automatically. but it does allow you to get the clip ids of all clips in the set with no limit to the amount of poly~ voices.

to get around the no observer problem i have built in ways to get the clip ids within individual tracks, scenes, or clip_slots, and have these update the master stored array of clip ids.

so when i'm using a clip launcher app on a launchpad or monome whenever i move where the clip grid is focused it gets all the clip ids within that clip launchers clip grid and updates the main array of clip ids, in case anything has changed.

i also built in that whenever a clip slot starts playing it quickly checks to see if the master array has a clip id stored for it, if it doesn't it will check if there is a clip in the clip slot and update the master array. this way if you record any clips they will instantly update in your clip id array and appear on the launchpad.

Myralfur
Posts: 114
Joined: Wed Feb 18, 2009 4:53 am
Location: London, England
Contact:

Re: how to observe the state of all the clip slots ?

Post by Myralfur » Mon Nov 04, 2013 4:00 am

also, i've been working on a max for live device to simplify and centralise communication with the live api within a live set. you might be interested in it.

basically it's a device that on initialisation gets all of the ids and properties of objects within the live object model. it stores all the ids and values of properties in a master dictionary named "m4lc-hub" which you can access from other m4l devices. the ids and values are all stored in a dictionary hierarchy exactly the same as the live object model hierarchy.

for example, if you want to get the id of a clip slot in m4l you send a [live.path] the message "path live_set tracks 0 clip_slots 0". to do the same with the "m4lc-hub" dictionary you send the message "get live_set::tracks::0::clip_slots::0::id". so quite similar. it has "id" on the end as "m4lc-hub" dictionary stores more than just ids and you might want to get the value of a property, such as "get live_set::tracks::0::mute" to get if the track is muted.

it observes as many of the properties as it can without using up to many resources... it would be possible to build a device that observes every clip slot for clips, and every device parameter value in the entire set, but would it be practical, i'm not so sure.

it's currently going through a refresh to use the awesome new dictionaries in max 6, instead of lots of coll and var objects, as it did before. but i previously used it to make clip launchers and other max for live devices that do a lot of api stuff much simpler and quicker to build.

have a look around if you like, let me know what you think and if you have any questions. i'm interested to see if other m4l programmers would be interested in it, and if i should make a brief tutorial video and documentation.

Download for the device, the current version and a tester version with comments and examples in the user interface:

Version 11:
https://www.dropbox.com/s/ynfuejqa6j2bs ... 20v11.amxd

Tester Example:
https://www.dropbox.com/s/66pgm4fiv2a0e ... %20v1.amxd

chapelier fou
Posts: 6012
Joined: Mon May 15, 2006 12:15 pm

Re: how to observe the state of all the clip slots ?

Post by chapelier fou » Mon Nov 04, 2013 7:54 am

@Myr, i've seen your m4lc-hub from the monome forum and it looks great.
As for your suggestion to update the array of clips whenever some change happens in focusing, adding a track or whatever, this was my first idea.

@broc, thanks for pasting the patch.

i'll give it a go and come back here if needed. That's really valuable help, guys.
MacBook Pro 13" Retina i7 2.8 GHz OS 10.13, L10.0.1, M4L.
MacStudio M1Max 32Go OS 12.3.1

broc
Posts: 1151
Joined: Mon Jul 26, 2004 8:37 am

Re: how to observe the state of all the clip slots ?

Post by broc » Mon Nov 04, 2013 10:27 am

Myralfur wrote:using a poly~, as broc has shown, works well. the max voice number for poly~ is 1023 though i think. i'm also not sure what the cpu usage would be like with that many observers.
I've just checked that the cpu usage of poly~ with 64 clip slot observers is about 1% (on Mac mini 2CD 2GHz).

Myralfur
Posts: 114
Joined: Wed Feb 18, 2009 4:53 am
Location: London, England
Contact:

Re: how to observe the state of all the clip slots ?

Post by Myralfur » Mon Nov 04, 2013 7:20 pm

yeah, i can't really complain about cpu usage too much, it's being pretty reasonable.

the M4LC Hub patch i posted above has well over a hundred observers, and in this test version it's only observing the ids and properties of 32 tracks and 64 scenes, all in poly~ objects. will probably increase the voices in the poly~ objects for bigger sets maybe 64 tracks and 128 scenes. would be a lot more observers but i'm hoping live can handle it.

also the poly~ 8x8 clip observer is great for a clip launcher. you could maintain a master array of clips for all tracks and scenes by getting the ids, then in the clip launcher create an 8x8 clip grid observing the ids, and have the observers update the master array of clips for whatever area the 8x8 clip launcher is focused on.

Post Reply