Page 1 of 1

Get Control Surface name please

Posted: Tue Jun 06, 2023 12:56 pm
by chapelier fou
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 ?

Re: Get Control Surface name please

Posted: Tue Jun 06, 2023 4:44 pm
by [jur]
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.

Re: Get Control Surface name please

Posted: Tue Jun 06, 2023 4:45 pm
by chapelier fou
Huh, thanks,
it must have been added recently, then...
I'll check.

Re: Get Control Surface name please

Posted: Tue Jun 06, 2023 5:02 pm
by chapelier fou
Well, I took another look and honestly, there seems to be no way to get control surface's names.

Re: Get Control Surface name please

Posted: Tue Jun 06, 2023 5:38 pm
by [jur]
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:

Re: Get Control Surface name please

Posted: Tue Jun 06, 2023 6:28 pm
by chapelier fou
Yeah, in the case of the MaxforLive control Surface, it would be useful to be able to locate its slot.

Re: Get Control Surface name please

Posted: Tue Jun 06, 2023 6:46 pm
by [jur]
Yep, the MaxForLive control surface has never been documented near enough imo...

Re: Get Control Surface name please

Posted: Tue Jun 06, 2023 7:30 pm
by chapelier fou
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. :?

Re: Get Control Surface name please

Posted: Wed Jun 07, 2023 12:55 pm
by TimChandler
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.

Re: Get Control Surface name please

Posted: Wed Jun 07, 2023 5:03 pm
by chapelier fou
Oh so that’s ‘type’ and not ‘name’ ?
We may have a solution !
Should work without js, I don’t see why not. Thanks !

Re: Get Control Surface name please

Posted: Fri Jun 09, 2023 1:40 pm
by chapelier fou
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>