mixedinkey-opensource / MIKMIDI

MIDI Library for Swift and Objective-C Mac and iOS apps.
Other
492 stars 95 forks source link

MIKMIDIConnectionManager.avaliableDevices with virtual devices enabled #143

Open ghost opened 8 years ago

ghost commented 8 years ago

Mac OSX 10.11.3 If run deviceManager.virtualSources / virtualDestinations I get the following list:

Virtual Sources

Session 1
iConnectMIDI1
Port 1
Port 2
Daemon Input 0
Daemon Input 1
Daemon Input 2
Daemon Input 3
Daemon Input 4
Daemon Input 5
Daemon Input 6
Daemon Input 7 

Virtual Destinations

Session 1
iConnectMIDI1
Port 1
Port 2
Daemon Output 0
Daemon Output 1
Daemon Output 2
Daemon Output 3
Daemon Output 4
Daemon Output 5
Daemon Output 6
Daemon Output 7 

This is correct and I am happily using them.

But if run this code:

        self.connectionManager = MIKMIDIConnectionManager.init(name: "MKConnect", delegate: self, eventHandler: receiveMessageHandler)
        self.connectionManager?.includesVirtualDevices = true
        let devices = self.connectionManager?.availableDevices
        for device in devices! {
            print("\(device)")
        }
        for device in devices! {
            print("\(device.name)")

        }

I get this output:

2016-03-16 15:38:50.900 MIDI Kinetics Connect[47413:38100101] Unable to connect to MIDI device <MIKMIDIDevice: 0x60800006adc0> Bluetooth:
        Entities: {
        }: Error Domain=MIKMIDIErrorDomain Code=4 "MIDI Device has no sources." UserInfo={NSLocalizedDescription=MIDI Device has no sources.}
<MIKMIDIDevice: 0x60800006adc0> Bluetooth:
        Entities: {
        }
<MIKMIDIDevice: 0x60000006f380> Network:
        Entities: {
            <MIKMIDIEntity: 0x60800006ccc0> Session 1:
        Sources: {
            <MIKMIDISourceEndpoint: 0x600000042070> Network Session 1,
        }
        Destinations: {
            <MIKMIDIDestinationEndpoint: 0x600000042430> Network Session 1,
        },
        }
<MIKMIDIDevice: 0x60800006cec0> ipMIDI:
        Entities: {
            <MIKMIDIEntity: 0x60800006cbc0> Port 1:
        Sources: {
            <MIKMIDISourceEndpoint: 0x600000048820> ipMIDI Port 1,
        }
        Destinations: {
            <MIKMIDIDestinationEndpoint: 0x600000048850> ipMIDI Port 1,
        },
            <MIKMIDIEntity: 0x60000006f340> Port 2:
        Sources: {
            <MIKMIDISourceEndpoint: 0x600000048880> ipMIDI Port 2,
        }
        Destinations: {
            <MIKMIDIDestinationEndpoint: 0x608000044c80> ipMIDI Port 2,
        },
        }
<MIKMIDIDevice: 0x60000006f300> iConnectMIDI1:
        Entities: {
            <MIKMIDIEntity: 0x60000006f180> iConnectMIDI1:
        Sources: {
            <MIKMIDISourceEndpoint: 0x608000044ad0> iConnectMIDI1,
        }
        Destinations: {
            <MIKMIDIDestinationEndpoint: 0x6000000488e0> iConnectMIDI1,
        },
        }
<MIKMIDIDevice: 0x610000070180> Daemon Input 5:
        Entities: {
            <MIKMIDIEntity: 0x6100000701c0> Daemon Input 5:
        Sources: {
            <MIKMIDISourceEndpoint: 0x610000044e60> Daemon Input 5,
        }
        Destinations: {
        },
        }
<MIKMIDIDevice: 0x610000070200> Daemon Input 6:
        Entities: {
            <MIKMIDIEntity: 0x610000070240> Daemon Input 6:
        Sources: {
            <MIKMIDISourceEndpoint: 0x610000044e00> Daemon Input 6,
        }
        Destinations: {
        },
        }
<MIKMIDIDevice: 0x610000070280> Daemon Input 1:
        Entities: {
            <MIKMIDIEntity: 0x6100000702c0> Daemon Input 1:
        Sources: {
            <MIKMIDISourceEndpoint: 0x608000044d40> Daemon Input 1,
        }
        Destinations: {
        },
        }
<MIKMIDIDevice: 0x610000070300> Daemon Input 2:
        Entities: {
            <MIKMIDIEntity: 0x610000070340> Daemon Input 2:
        Sources: {
            <MIKMIDISourceEndpoint: 0x608000044d70> Daemon Input 2,
        }
        Destinations: {
        },
        }
<MIKMIDIDevice: 0x610000070380> Daemon Input 0:
        Entities: {
            <MIKMIDIEntity: 0x6100000703c0> Daemon Input 0:
        Sources: {
            <MIKMIDISourceEndpoint: 0x610000044ec0> Daemon Input 0,
        }
        Destinations: {
        },
        }
<MIKMIDIDevice: 0x610000070400> Daemon Input 4:
        Entities: {
            <MIKMIDIEntity: 0x610000070440> Daemon Input 4:
        Sources: {
            <MIKMIDISourceEndpoint: 0x600000048940> Daemon Input 4,
        }
        Destinations: {
        },
        }
<MIKMIDIDevice: 0x610000070480> Daemon Input 3:
        Entities: {
            <MIKMIDIEntity: 0x6100000704c0> Daemon Input 3:
        Sources: {
            <MIKMIDISourceEndpoint: 0x610000044e90> Daemon Input 3,
        }
        Destinations: {
        },
        }
<MIKMIDIDevice: 0x610000070500> Daemon Input 7:
        Entities: {
            <MIKMIDIEntity: 0x610000070540> Daemon Input 7:
        Sources: {
            <MIKMIDISourceEndpoint: 0x600000048970> Daemon Input 7,
        }
        Destinations: {
        },
        }
<MIKMIDIDevice: 0x610000070580> Daemon Input 5:
        Entities: {
            <MIKMIDIEntity: 0x6100000705c0> Daemon Input 5:
        Sources: {
            <MIKMIDISourceEndpoint: 0x610000044e60> Daemon Input 5,
        }
        Destinations: {
        },
        }
<MIKMIDIDevice: 0x610000070600> Daemon Input 6:
        Entities: {
            <MIKMIDIEntity: 0x610000070640> Daemon Input 6:
        Sources: {
            <MIKMIDISourceEndpoint: 0x610000044e00> Daemon Input 6,
        }
        Destinations: {
        },
        }
<MIKMIDIDevice: 0x610000070680> Daemon Input 1:
        Entities: {
            <MIKMIDIEntity: 0x6100000706c0> Daemon Input 1:
        Sources: {
            <MIKMIDISourceEndpoint: 0x608000044d40> Daemon Input 1,
        }
        Destinations: {
        },
        }
<MIKMIDIDevice: 0x610000070700> Daemon Input 2:
        Entities: {
            <MIKMIDIEntity: 0x610000070740> Daemon Input 2:
        Sources: {
            <MIKMIDISourceEndpoint: 0x608000044d70> Daemon Input 2,
        }
        Destinations: {
        },
        }
<MIKMIDIDevice: 0x610000070780> Daemon Input 0:
        Entities: {
            <MIKMIDIEntity: 0x6100000707c0> Daemon Input 0:
        Sources: {
            <MIKMIDISourceEndpoint: 0x610000044ec0> Daemon Input 0,
        }
        Destinations: {
        },
        }
<MIKMIDIDevice: 0x610000070800> Daemon Input 4:
        Entities: {
            <MIKMIDIEntity: 0x610000070840> Daemon Input 4:
        Sources: {
            <MIKMIDISourceEndpoint: 0x600000048940> Daemon Input 4,
        }
        Destinations: {
        },
        }
<MIKMIDIDevice: 0x610000070880> Daemon Input 3:
        Entities: {
            <MIKMIDIEntity: 0x6100000708c0> Daemon Input 3:
        Sources: {
            <MIKMIDISourceEndpoint: 0x610000044e90> Daemon Input 3,
        }
        Destinations: {
        },
        }
<MIKMIDIDevice: 0x610000070900> Daemon Input 7:
        Entities: {
            <MIKMIDIEntity: 0x610000070940> Daemon Input 7:
        Sources: {
            <MIKMIDISourceEndpoint: 0x600000048970> Daemon Input 7,
        }
        Destinations: {
        },
        }
Bluetooth
Network
ipMIDI
iConnectMIDI1
Daemon Input 5
Daemon Input 6
Daemon Input 1
Daemon Input 2
Daemon Input 0
Daemon Input 4
Daemon Input 3
Daemon Input 7
Daemon Input 5
Daemon Input 6
Daemon Input 1
Daemon Input 2
Daemon Input 0
Daemon Input 4
Daemon Input 3
Daemon Input 7

If appears to be at least duplicating the inputs for the outputs for the "Daemon" virtual endpoints. I assume it can't match source and destination due to the different names for "Deamon" endpoints.

The Daemon Input / Output virtual endpoints are created by the Lemur Line Daemon.

armadsen commented 8 years ago

This does sound like a bug/weakness in the code that associates virtual sources with virtual endpoints to create (virtual) devices. That code was written and tested mostly against Native Instruments DJ controllers, so it's not too surprising that it doesn't work for some other set ups.

Are you interested in trying to fix this? If not, I'll take a shot at it when I have time, but it might be a while.