Is it possible to use Multiple Midi Controllers - assigning a midi function independently (e.g. not MIDIIn.addFuncTo)

Hi! Hopefully a simple question.

I have two midi controllers. I’ve created a connection to each of them using a custom script I wrote to get the endpoint details:

MIDIHelpers {

    /* Helper Method to Find the Endpoint Details for the nth occurence of a given regex.
       Returns an Endpoint Details Object.
       Note that the current Endpoint is set to -2 because the first two MIDI Endpoints are System->Timer and System->Announce and neither of those are considered when deriving the output device number increment, but do appear in the sources list. */

    *findEndpointDetails { |regex, deviceNumber|
        var sources = MIDIClient.sources, deviceCount = 1, currentEndPoint = -2, endPointDetails =,-1);
        ("Looking for [" ++ regex ++ "] device Number: " ++ deviceNumber).postln; { |source|
            if (source.device.matchRegexp(regex)) {
                if (deviceNumber == deviceCount) {
                    endPointDetails.uid = source.uid;
                    endPointDetails.endPoint = currentEndPoint;
                deviceCount = deviceCount + 1;
            currentEndPoint = currentEndPoint + 1;
        if (endPointDetails.uid == -1) {
            Error("Could not find device number " ++ deviceNumber ++ " matching regex [" ++ regex ++ "]").throw;

EndPointDetails {

    var <>uid, <>endPoint;

    *new {|uid, endPoint|

This means I can get a midi device using:

 connection = MIDIHelpers.findEndpointDetails(name_, deviceNumber_);

and then get a MidIn and MidiOut by running

        // Double Check if the First Argument is going to cause problems - it
        // references the port, so it'll potentially cause a collision.
        in = MIDIIn(0, connection.uid);
        out = MIDIOut(0, connection.uid);

Now that I have a MidiIn that’s attached directly to the specific device, how in the world do I add a function to it ? It seems completely obvious that I should be able to do something like

control = { arg src, chan, num, val;    ["CONTROL", chan,num,val].postln; };
in.addFuncTo(\control, control);

but it doesn’t like that. Is there something I’m missing, or is there a way to do this ? I really don’t want to have to register functions into the MIDIIn with a switch because that’ll destroy the object hierarchy that I’m creating.

It looks like this doesn’t exist from what I can tell. I’m going to write a class that handles this - it’s much more natural to write a callback that’s specific to a device than to write a callback that’s universal among midi controllers or to manage the logic within the MIDIIn class.

This’ll probably be for the best, as the callback registry I’m building needs to be generic as I’m planning to introduce some osc controllers down the line.