I keep running into a strange issue when running AKMIDI on IOS. I also think it may be an IOS problem and not necessarily from Audiokit. I can connect a MIDI controller to IPad and receive messages as expected using the MIDI listener protocol after I open the input. If I disconnect the MIDI controller by cycling the power or unplugging it from the IPad and then reconnect it, I then start receiving two identical messages at each event. If I cycle the power again I start getting three messages, etc. I should also mention that when I detect the device is removed I close the input and clear the listeners. When I detect the new connection I open the input and start over. Does anyone know what can cause this to happen?
Asked
Active
Viewed 68 times
0
-
Can you post an example project? – Kurt Arnlund Jan 13 '20 at 01:41
-
The project is too large to post. Maybe this will help. When I detect my particular controller has connected over USB I do the following: midi.openInput(uid: inID!) midi.addListener(self) midi.openOutput() If I detect that it has disconnected I do the following: midi.clearListeners() midi.closeOutput() midi.closeInput(uid: inID!) – Uncle Kenny Jan 14 '20 at 03:33
1 Answers
0
I think I have found a workaround for this: If I only open the midi in and midi out one time, when my device is first detected, it seems to work correctly. I now only close the in and out when the app is terminated. You can cycle the power on the midi controller and it will still communicate with the app when it reconnects. I am also now using the more generic calls openInput(), addListener(self), openOutput().

Uncle Kenny
- 79
- 5
-
That's sound perfectly sufficient. Also, when you have a port that you want to persist through runs, you can keep around the ports unique id and open it up when your app starts up the next time. – Kurt Arnlund Jan 15 '20 at 00:50