Number of LiveAPI control_surfaces

xanadu's icon

Does anyone know a simple way to get the number of LiveAPI control_surfaces? To use the getcount message we need some parent, but it appears control_surfaces is the root itself, so this doesn't work.

amounra's icon

There can only be six, so I use an iteration and check type usually (in js). But yeah, it would be much better if control_surfaces didn't just return the __class__ builtins.

xanadu's icon

Interestingly there can be a lot more than six control_surfaces, but only six can be seen in the Preferences window. When setting a control_surface to none and then to some other surface not all previous surfaces are deleted, due to bad disconnect functions and Ableton Live not always calling the disconnect function.

I found iterating until I get an 'id 0' is a good solution. I have to iterate all surfaces anyway.

amounra's icon

LOL yeah, now that I think about it I can confirm that. You're work around seems like a good idea, I think I'll implement the same.

a

xanadu's icon

I stumbled upon a way to get the control_surfaces count.

It's here.

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

But I like to iterate control_surfaces until I get an 'id 0' more.

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

2741.Iteratecontrolsurfaces.jpg
jpg