CFPropertyListRef properties = nil;
OSStatus s = MIDIObjectGetProperties(entity, &properties, true);
if (s)
{
string = @"Unknown name";
}
else
{
NSDictionary *dictionary = (NSDictionary*)properties;
string = [NSString stringWithFormat:@"%@", [dictionary
valueForKey:@"name"]];
CFRelease(properties);
}
That's all well and good, but any property call for a virtual port
returns -50, and thus his code gives me "Unknown Name." I tried
swapping his dictionary call and OSSError thing out with something
like this:
CFStringRef pname;
MIDIObjectGetStringProperty(entity, kMIDIPropertyDisplayName, &pname);
string = (NSString *)pname;
And all I get for my efforts is (null) if I use
kMIDIPropertyDisplayName (even the network session returns this) or
"Session 1" plus a "(null)" for every background port if I use
kMIDIPropertyName.
What on earth am I doing wrong here? Thanks in advance for the helps.
On Nov 25, 6:23 pm, "Support (One Red Dog)" <supp...@onereddog.com.au>
wrote:
> Here's a function that will get you all the details, you'd probably want to store this in a data structure like std::map or something
Thanks, but that's really just a verbose way of doing what I'm already
doing. It's still the same basic call (kMIDIPropertyDisplayName) and
is going to return "(null)". The OSSStatus result is -50.
For what it's worth, the ports work fine; I'm able to send to and read
from all of them. I just can't seem to get the damn names. I tried out
a modified version of Apple's code from here:
http://developer.apple.com/library/mac/#qa/qa1374/_index.html and it
returns a much better name for the hardware and network stuff (I have
a feeling this is the code that Genome runs, since the names are
identical) but the virtual ports still return NULL.
The -50 is a paramErr, so it's possible you have something wrong with the arguments you are passing, e.g. something is null when it shouldn't be.
Chris Randall
Audio Damage, Inc.
http://www.audiodamage.com
Ergo, the virtual ports all return -50.
Not sure what to do about this, exactly, but at least I know _why_ it
is happening. Pulling the name off the virtual ports' endpoints
directly works, so I just have to figure out how to get that in to the
cycle.
Times like these, I think it might have just been easier to write my
own MIDI class. I've been dicking with this for two days.
--
static
NSString *NameOfEndpoint(MIDIEndpointRef ref)
{
NSString *string = nil;
CFStringRef str;
str = NULL;
MIDIObjectGetStringProperty(ref, kMIDIPropertyName, &str);
if (str != NULL)
{
string = [NSString stringWithString:(NSString *)str];
CFRelease(str);
}
/*
MIDIEntityRef entity = 0;
MIDIEndpointGetEntity(ref, &entity);
CFPropertyListRef properties = nil;
OSStatus s = MIDIObjectGetProperties(entity, &properties, true);
if (s)
{
string = @"Unknown name";
}
else
{
//NSLog(@"Properties = %@", properties);
NSDictionary *dictionary = (NSDictionary*)properties;
string = [NSString stringWithFormat:@"%@", [dictionary
valueForKey:@"name"]];
CFRelease(properties);
}
*/
return string;
}
--
Haven't looked at it in half a year so I don't remember the whats or
whys, but my apps can see the virtual MIDI port names fine so I dunno.
This was also compiled under iOS 4 so there's a small chance something
changed with 5.
Debugging this stuff sucks, no doubt.
Device -> Entitity - Endpoint
Each of these have a name attribute which may/may not have data
in it. The PGMidi method is to look at the entity name which works
for physical ports but not virtual ones. Network MIDI has a Device
and Entity name and hardware is all over the place.
In the end you probably need to look at all three and decide
how to identify the port. One Red Dog's code posting is
doing this. My own apps do something similar but have
extra logic to handle device/entity dupe information and
a 'kludge map' to map known 3rd party app ports that
don't conform to OMAC into something reasonable.
With all respect to Pete, PGMidi is a fantastic resource
and starting point, but to use it 'as is' in an app is
(IMNSHO) not recommended since it only implements
part of the picture.
--
You received this message because you are subscribed to a topic in the Google Groups "Open Music App Collaboration" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/open-music-app-collaboration/LgMyw0tDVEQ/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to open-music-app-colla...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.