Hi - finally got a chance to test midi in on iPad -iOS 4.3.5, with a USB keyboard (powered separately) using the iPad Camera Connector. It's working but there are a few things that may be odd. I'm using the code below (cobbled together from the OSX midi demo) and logging some of the info. The method is called through a button press - so everything has been loaded.
found device: 2
flags: 1
id: 1639062281
Bass Error: 23
name: USB Keystation 49e
Bass Init Success device: 1
Bass Init Success Error: 0
--I get the BASS_DEVICE_ERROR (23) whether or not the keyboard is attached. Is this correct?
--the keyboard is found at device index 1 - but the docs seem to indicate that device indexes start at 0?
--if I comment out the 'BASS_MIDI_InInit' code section below, it will recognize the keyboard (as expected) but if I then detach the keyboard and call the method again, it is still reporting the keyboard as found. That seems wrong.
Hope these details are useful. Other than my confusion (or wrong implementation) @ the above - midi in works just fine!
-(void) checkForInputDevice
{
BASS_MIDI_DEVICEINFO di;
int d;
int err;
for (d=0; BASS_MIDI_InGetDeviceInfo(d, &di); d++)
{
// nothing
}
if (d) {
NSLog([NSString stringWithFormat:@"found device: %d", d]);
NSLog([NSString stringWithFormat:@"flags: %d", di.flags]);
NSLog([NSString stringWithFormat:@"id: %d", di.id]);
err = BASS_ErrorGetCode();
NSLog([NSString stringWithFormat:@"Bass Error: %d", err]);
[owner setConnectionStatusResult:[NSString stringWithFormat:@"found device: %d", d]];
[owner setConnectionStatusResult:[NSString stringWithFormat:@"flags: %d", di.flags]];
[owner setConnectionStatusResult:[NSString stringWithFormat:@"id: %d", di.id]];
[owner setConnectionStatusResult:[NSString stringWithFormat:@"Bass Error: %d", err]];
CFStringRef cs=CFStringCreateWithCString(0,di.name,0);
[owner setConnectionStatusResult:[NSString stringWithFormat:@"name: %@", cs]];
CFRelease(cs);
int a;
for (a=1;a<d;a++) {
// for (a=0;a<d;a++) { //***********NOTE CHANGE
if (BASS_MIDI_InInit(a, RPMidiInProc, self)) {
BassMidiInput=a;
BASS_MIDI_InStart(BassMidiInput);
[owner setConnectionStatusResult:[NSString stringWithFormat:@"Bass Init Success device: %d", a]];
err = BASS_ErrorGetCode();
[owner setConnectionStatusResult:[NSString stringWithFormat:@"Bass Init Success Error: %d", err]];
break;
} else {
err = BASS_ErrorGetCode();
[owner setConnectionStatusResult:[NSString stringWithFormat:@"Bass Init error: %d", err]];
}
}
} else {
[owner setConnectionStatusResult:[NSString stringWithFormat:@"no device"]];
NSLog([NSString stringWithFormat:@"no device"]);
}
}