Modality, multiple identical devices

Hello there,

i’ve been using Modality-toolkit with SuperCollider 3.12.0 on Linux and I’ve been enjoying it so much that I wanted to add even more immediate control to my patches. Now I’ve read the documentation about identical devices and it seemed to be pretty straightforward:

Now I’ve started to adapt my code to this format, like this:

m = MKtl('mm',"akai-midimix",multiIndex:0);
q = MKtl('sq',"akai-midimix",multiIndex:1);

The first one acts as expected and creates a new modal controller, the second one throws me an error with “ERROR: Message ‘at’ not understood.”

I’ve looked beforehand and both are recognized and even when I want to add them without giving the multiIndex on creation it shows both and gives them multiIndex 0 and 1:

Meta_MKtlDevice:open: multiple device candidates found, please disambiguate by providing a multiIndex!
The candidates are:

multiIndex 0: ( 'idInfo': ( 'destPortIndex': 0, 'srcPortIndex': 0, 'deviceName': "MIDI Mix" ), 'protocol': 'midi', 'destDevice': MIDIEndPoint("MIDI Mix", "MIDI Mix MIDI 1", 1310720), 'filenames': [  ], 
  'multiIndex': 0, 'srcDevice': MIDIEndPoint("MIDI Mix", "MIDI Mix MIDI 1", 1310720), 'deviceName': "MIDI Mix", 'descs': [  ], 'lookupName': 'midi_3_midi_mix_nr_1', 
  'deviceInfo': MIDIEndPoint("MIDI Mix", "MIDI Mix MIDI 1", 1310720) )

multiIndex 1: ( 'idInfo': ( 'destPortIndex': 1, 'srcPortIndex': 1, 'deviceName': "MIDI Mix" ), 'protocol': 'midi', 'destDevice': MIDIEndPoint("MIDI Mix", "MIDI Mix MIDI 1", 2097152), 'filenames': [  ], 
  'multiIndex': 1, 'srcDevice': MIDIEndPoint("MIDI Mix", "MIDI Mix MIDI 1", 2097152), 'deviceName': "MIDI Mix", 'descs': [  ], 'lookupName': 'midi_4_midi_mix_nr_2', 
  'deviceInfo': MIDIEndPoint("MIDI Mix", "MIDI Mix MIDI 1", 2097152) )

but even then:

MKtl(\sq).openDevice(true,1);

will return “ERROR: Message ‘at’ not understood.”

Anyone have experience using multiple identicals or run into something similar? Ideas where to look fixing this or how to do this differently?

best,
dormir

FIRST EDIT:

So it seems theoretically it works, when i instantiate both midimixes with their correct multi indices i still always get an error at the index 1, like i mentioned before, when i open the gui of both modal controllers, the one with multiindex=0 is correctly set up and the other one exists but is not connected, clicking then on the “device” button which probably runs “openDevice” in some fashion it seems to connect and also work… so something goes wrong when a new midimktl gets created with a multiindex>0. i’ve checked in MIDIMKtlDevice.sc

*new { |name, idInfo, parentMKtl, multiIndex|

		var lookupInfo = parentMKtl.lookupInfo;
		var foundInfo, foundSources, foundDestinations;
		var newDev;

		idInfo = idInfo ?? {
			parentMKtl.lookupInfo.idInfo ?? {
				parentMKtl.desc.idInfo
		} };

		if (idInfo.isNil) {
			inform("MIDIMKtlDevice.new: cannot create new without idInfo");
			^this;
		};

		// should not need to look again actually -
		// logic is still too loopy, but no time to simplify now.

		//	"%: %: %\n".postf(thisMethod, \multiIndex, multiIndex);
		foundInfo = MKtlLookup.findByIDInfo(idInfo)
		.at(multiIndex ? 0);

		foundInfo.postln; //TODO tmp

		foundSources = foundInfo[\srcDevice];
		foundDestinations = foundInfo[\destDevice];

		newDev = super.basicNew(name, lookupInfo.idInfo, parentMKtl );
		newDev.initMIDIMKtl(name, foundSources, foundDestinations );

		newDev.initElements;
		^newDev
	}

and foundInfo gives me the correct

  'multiIndex': 0, 'srcDevice': MIDIEndPoint("MIDI Mix", "MIDI Mix MIDI 1", 1310720), 'deviceName': MIDI Mix, 'descs': [  ], 'lookupName': midi_3_midi_mix_nr_1, 
  'deviceInfo': MIDIEndPoint("MIDI Mix", "MIDI Mix MIDI 1", 1310720) )

for multiIndex=0,
but only returns nil with the device with multiIndex=1…

SECOND EDIT:
(sorry for the big infodumps, just think that if someone knows about Modality innards it might be helpful)

I tried changing in MIDIMKtlDevice.sc:

foundInfo = MKtlLookup.findByIDInfo(idInfo)
		.at(multiIndex ? 0);

to

foundInfo = MKtlLookup.findByIDInfo(idInfo)[0];

since this is the line at MKtl creation that throws me the error from what I gathered so far. This leads to both devices working for MIDI inputs, but when I send a message to only one of the devices, either:

// MKtl(\mm).elAt(\bt,0,1,0).value_(127);

or

// MKtl(\sq).elAt(\bt,0,1,0).value_(127);

They will always be sent to both devices at once. Maybe i should start up an issue at the modality github.