Send MIDI to iOS Simulator

I found information about creating a network session in Audio&Midi utility and click connect once the iOS Simulator appears in Directory. Il left the port unchanged (5004).

In my App code I created an input port and linked it to the default network session :

Code Block
MIDIPortRef inPort = 0;
MIDIInputPortCreate(client, CFSTR("Input port"), MyMIDIReadProc, (bridge void * _Nullable) player, &inPort);
MIDINetworkSession* session = [MIDINetworkSession defaultSession];
session.enabled = YES;
session.connectionPolicy = MIDINetworkConnectionPolicy_Anyone;
MIDIPortConnectSource(inPort, session.sourceEndpoint, (bridge void * _Nullable) player);


When I send midi messages (fom Logic using Network session 1 as Port) the ios app midi handler is not called.

Some say we have to create an ouput port however I don't think it is related
I also added MIDI services discovery :

Code Block
browser = [[NSNetServiceBrowser alloc] init];
browser.delegate = self;
browser searchForServicesOfType:MIDINetworkBonjourServiceType /* i.e. @"_apple-midi._udp"*/
inDomain:@""];


I then implemented some NSNetServiceDelegate and NSNetServiceBrowserDelegate methods

Code Block
-(void)netServiceDidResolveAddress:(NSNetService *)service {
if (![[service name] isEqualToString:[[UIDevice currentDevice] name]]) {
[service setDelegate:nil];
NSLog(@"Resolved service name: %@ host name: %@", [service name], [service hostName]);
MIDINetworkHost* host = [MIDINetworkHost hostWithName:[service name] netService:service];
MIDINetworkConnection* newConnection = [MIDINetworkConnection connectionWithHost:host];
[session addConnection:newConnection];
NSLog(@"Connected to %@", [service name]);
}
}
- (void)netServiceBrowser:(NSNetServiceBrowser *)aBrowser didFindService:(NSNetService *)aService {
NSLog(@"Found service %@ on %@", [aService name], [aService hostName]);
if (![[service name] isEqualToString:[[UIDevice currentDevice] name]]) {
[service setDelegate:nil];
NSLog(@"Resolved service name: %@ host name: %@", [service name], [service hostName]);
MIDINetworkHost* host = [MIDINetworkHost hostWithName:[service name] netService:service];
MIDINetworkConnection* newConnection = [MIDINetworkConnection connectionWithHost:host];
[networkSession addConnection:newConnection];
NSLog(@"Connected to %@", [service name]);
}


The two delegate methods didn't get called.
Also when I send midi messages (fom Logic using Network session 1 as Port) the ios app midi handler is not called.

By creating the network connection manually (without discovering), passing the Bonjour name and IP Adresss displayed in Audio&Midi utility

Code Block
MIDINetworkHost *host = [MIDINetworkHost hostWithName:@"Mac mini ***" address:@"***.***.0.10" port:5004];
MIDINetworkConnection *connection = [MIDINetworkConnection connectionWithHost:host];
[networkSession addConnection:connection];


The MyMIDIReadProc handler was called once in debug mode, the first note started playing, however it was cut shortly thereafter, and subsequent MIDI messages were ignored. Also there was a low buzz sound.


Send MIDI to iOS Simulator
 
 
Q