Get Control Surface name please

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

Get Control Surface name please

Post by chapelier fou » Tue Jun 06, 2023 12:56 pm

I use the 'MaxforLive' control surface.
I wish there was a way to locate its position in the list of enabled control surfaces. For now, unless I'm mistaken, the only way to access it in Max API is to specify its position. So if I enable the Control Surface in the wrong slot, my patch will not work.
Am I missing something ?
MacBook Pro 13" Retina i7 2.8 GHz OS 10.13, L10.0.1, M4L.
MacStudio M1Max 32Go OS 12.3.1

[jur]
Site Admin
Posts: 5275
Joined: Mon Jun 01, 2015 3:04 pm
Location: Ableton

Re: Get Control Surface name please

Post by [jur] » Tue Jun 06, 2023 4:44 pm

There's an abstraction for this.
I'll check and get back with a more detailed answer if you don't find it in the meantime.
Ableton Forum Moderator

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

Re: Get Control Surface name please

Post by chapelier fou » Tue Jun 06, 2023 4:45 pm

Huh, thanks,
it must have been added recently, then...
I'll check.
MacBook Pro 13" Retina i7 2.8 GHz OS 10.13, L10.0.1, M4L.
MacStudio M1Max 32Go OS 12.3.1

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

Re: Get Control Surface name please

Post by chapelier fou » Tue Jun 06, 2023 5:02 pm

Well, I took another look and honestly, there seems to be no way to get control surface's names.
MacBook Pro 13" Retina i7 2.8 GHz OS 10.13, L10.0.1, M4L.
MacStudio M1Max 32Go OS 12.3.1

[jur]
Site Admin
Posts: 5275
Joined: Mon Jun 01, 2015 3:04 pm
Location: Ableton

Re: Get Control Surface name please

Post by [jur] » Tue Jun 06, 2023 5:38 pm

chapelier fou wrote:
Tue Jun 06, 2023 12:56 pm
I use the 'MaxforLive' control surface.
Oh, my bad I didn't read this important part of your post...
Forget my answer then, sorry :oops:
Ableton Forum Moderator

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

Re: Get Control Surface name please

Post by chapelier fou » Tue Jun 06, 2023 6:28 pm

Yeah, in the case of the MaxforLive control Surface, it would be useful to be able to locate its slot.
MacBook Pro 13" Retina i7 2.8 GHz OS 10.13, L10.0.1, M4L.
MacStudio M1Max 32Go OS 12.3.1

[jur]
Site Admin
Posts: 5275
Joined: Mon Jun 01, 2015 3:04 pm
Location: Ableton

Re: Get Control Surface name please

Post by [jur] » Tue Jun 06, 2023 6:46 pm

Yep, the MaxForLive control surface has never been documented near enough imo...
Ableton Forum Moderator

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

Re: Get Control Surface name please

Post by chapelier fou » Tue Jun 06, 2023 7:30 pm

Yes and it's the mirror for one of the greatest paradoxes of Ableton Live : (drum roll....)
You can't send MIDI to multiple channels from a MIDI track, even with MPE, but you CAN with the MaxForLive Control Surface. :?
MacBook Pro 13" Retina i7 2.8 GHz OS 10.13, L10.0.1, M4L.
MacStudio M1Max 32Go OS 12.3.1

TimChandler
Posts: 7
Joined: Thu Sep 08, 2022 8:50 am

Re: Get Control Surface name please

Post by TimChandler » Wed Jun 07, 2023 12:55 pm

If you are comfortable using the js object, you can iterate through each control surface slot, using the type member to identify the control surface name. Use an outlet to output the slot ID. Here's some rough code to get you started:

Code: Select all

inlets = 1;
outlets = 1;

var globals = new Global("globals");

function bang()
{
	globals.api = new LiveAPI("control_surfaces 0"); 

	globals.totalSlots = 6;

	outlet(0, globals.getM4lSurfaceSlotIdx());

}

globals.getM4lSurfaceSlotIdx = function()
{
	var slot = -1;
	
	for(slot=0; slot<globals.totalSlots; slot++) {
		globals.api.path = "control_surfaces "+slot;
	    if(parseInt(globals.api.id,10) !== 0 && globals.api.type === "MaxForLive") break;  
	}

	if (slot == globals.totalSlots) return -1;  

	return slot;

};
Note that this example only identifies the first MaxForLive control surface.

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

Re: Get Control Surface name please

Post by chapelier fou » Wed Jun 07, 2023 5:03 pm

Oh so that’s ‘type’ and not ‘name’ ?
We may have a solution !
Should work without js, I don’t see why not. Thanks !
MacBook Pro 13" Retina i7 2.8 GHz OS 10.13, L10.0.1, M4L.
MacStudio M1Max 32Go OS 12.3.1

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

Re: Get Control Surface name please

Post by chapelier fou » Fri Jun 09, 2023 1:40 pm

Just wanted to confirm, 'gettype' message to a control surface object will return the 'name'.
This solves my issue, thanks TimChandler !

The M4L version :

Code: Select all

<pre><code>
----------begin_max5_patcher----------
736.3ocuWttaaBCE.92jmBKz9YZD9Bzj8.res8DLMEYHdothXP1lrrT0284K
P51JDtDZTUcjMGNG+4yMyKKBBSKNwTgfOC9NHH3kEAAtkrKDTOOH7.8TVNU4
DKTv9UQ5ygK8ORyNocK+..1rVQkNmo0+tj40aHWXj4G0OkuyIuQGOfIMuhn5
.WXdImIP0KVR0YOwE62JYYZupvP7pnkfMOZGQaVEaFQqhtnbid7V2oHncwWW
rvNr71vq5LGjzIfoTw9vku8am.iGKvnMHKpID6HIxgc2.im.vGXJEcO6cDeN
OKmQkcxb6.hFKfDCTFuHFuwQHtGBmQW54bfjsua9V1AinjQG09H169b9OBoG
FQyGikRanXKLD2JCvqwPrayG69Ai5ggn4iAEKG7M5ouTH+J+Hq2bv18YSsRS
cb4ln6mOSZTKC3Ha7wlvoxYThqNC59woFjBxM+k1uKs9e271vFtdzgydrg9x
qPRROsRHyXkUy14IPVgPKKx2ppj+jlwTfOAGWoVX7Dc0PLwybzGPs1tXdeMP
iCQzDQDQ7EqVe+5ljapMsx7.6VYbPFMUH8cU5MksIKPQOx1s0uE2R0ZIO0Tn
QUiZMqAgaKYREWoYhL1kyH+gzXOpL5WWHtd5caGIWxlKoR5AllI2xDzzb2KF
MxL85aPU2whzLdmhHr45WuLdWkxSlZIM+cEiwi3thNQLaXw++o.NyXW+ewWU
TIyZnnISE7lk1wTZtfp4Fu+eITjWnVOhGrkhFfkrsAuYK0njqaIxbXIxPrTx
bb5YRs.ngXI3bXodiHPyESvgD6cqL03Bt9oW7bwDtGKgmiSOL5dE6Y+32di8
vyQ9zPB8b6la0PCIdnIQ31hGhGfklEmzPJEAeeHtuCBsr7n81CdocFwzp74B
oc55ktobgeZrapjcj2HO1sBUZZroMc0pjtMV3oD+GuEdnXGSJp308oM3YLoq
MrvbKAUI0Shqa8hWW7G.i+.TvB
-----------end_max5_patcher-----------
</code></pre>
MacBook Pro 13" Retina i7 2.8 GHz OS 10.13, L10.0.1, M4L.
MacStudio M1Max 32Go OS 12.3.1

Post Reply