• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
FW: User presentation of device names in Jaguar
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FW: User presentation of device names in Jaguar


  • Subject: FW: User presentation of device names in Jaguar
  • From: "Cianflone, Chris" <email@hidden>
  • Date: Fri, 2 May 2003 18:33:56 -0500

> I am going to forward this again since we've had some e-mail problems on
> our end (also cut some stuff out to get under the 8K limit of e-mail to
> this list). Sorry if you have already seen this:
>
> Thanks! I somehow missed that docu. However, this raises some questions:
>
> Which UniqueID should I be saving for the selection of an endpoint, the
> one given by the kMIDIPropertyUniqueID of the original MIDIEndpointRef, or
> the one given by kMIDIPropertyConnectionUniqueID of the external device?
> Here is an example to hopefully make this clear:
>
> Suppose I have the following setup:
>
> A "FastLane USB" MIDI interface, and then I create an external device on
> this called "JV-1000". Before I instituted the code below for "Display of
> endpoint names" I would get the following names I choices in our app:
> "Port A" and "Port B", and yes, I could have "fixed" this to show
> "FastLane USB Port A" and "FastLane USB Port B".
>
> Now, I replace my interface with another one I have, a "Super MPU64" and
> plug in the "JV-1000" to it. Now, if I am storing the UniqueID given by
> kMIDIPropertyUniqueID, presumably my "JV-1000" would not be found, because
> what I was really storing was the UniqueID of "FastLane USB Port A". But
> if I store the one given by kMIDIPropertyConnectionUniqueID, it would be
> found? Do I assume I store the later (which is of course complicated by
> the fact that there could be several IDs given by
> kMIDIPropertyConnectionUniqueID)? But are we supposed to be storing these
> UniqueIDs? Everything I have ever read has talked about saving
> kMIDIPropertyUniqueID.
>
> By the way: Could we please get back a "Test Studio" feature in Audio MIDI
> Setup? I hope no one has a problem with copying good features from the
> applications OMS Setup and FreeMIDI Setup :)
>
> Thanks,
> Chris
>
> ----------
> From: Pete Yandell
> Sent: Wednesday, April 30, 2003 8:48 PM
> To: Cianflone, Chris
> Cc: email@hidden
> Subject: Re: User presentation of device names in Jaguar
>
> From the official Apple documentation at
> file:///Developer/Documentation/CoreAudio/MIDI/Topics/appnotes.html :
>
> Display of endpoint names
>
> Here is the recommended algorithm for display of a MIDIEndpointRef 's
> name.
>
> Get the endpoint's kMIDIPropertyConnectionUniqueID property.
>
> If the endpoint has exactly one connected external device, display the
> external device's name.
>
> If the endpoint has multiple connected external devices, there are several
> possibilities depending on the context:
> - Attempt to choose exactly one device to display (e.g. if the context
> involves events on only one MIDI channel, and only one of the devices
> receives on that channel, it's clearly reasonable to display only that
> device)
> - Concatenate the names of all of the devices, separated by commas (some
> special characters such as slashes and dashes are common in device names)
>
> - Display the physical MIDI port's name (as below)
>
> If an endpoint has no connected external devices, display the endpoint's
> name, which will normally be inherited from its entity's name:
> - If the name obtained in this manner is an empty string, use
> MIDIEntityGetDevice to obtain the device and use the device's name. (This
> works around a bug in some versions of the AppleMIDIUSB driver.)
> - If the name obtained in this manner is not unique among the other
> sources or destinations in the system, or, if your application has
> sufficient screen space to display long names, prepend the device's name
> and a space to the endpoint's name.
>
>
> And here's the code from my PYMIDI framework (available at
> http://pete.yandell.com/software/) to do it. I go with sticking together
> all the external device names, and I also always prepend the device name
> to the endpoint name.
>
> CFStringRef deviceName = nil;
>
> MIDIEntityRef entityRef;
> result = MIDIEndpointGetEntity (midiEndpointRef, &entityRef);
> if (result == noErr) {
> MIDIDeviceRef deviceRef;
> result = MIDIEntityGetDevice (entityRef, &deviceRef);
>
> if (result == noErr) {
> result = MIDIObjectGetStringProperty (deviceRef,
> kMIDIPropertyName, &deviceName);
> }
> }
>
> CFStringRef endpointName;
> result = MIDIObjectGetStringProperty (midiEndpointRef,
> kMIDIPropertyName, &endpointName);
>
> if (deviceName != nil &&
> CFStringCompare (deviceName, endpointName,
> kCFCompareCaseInsensitive) != kCFCompareEqualTo)
> {
> name = [[NSString alloc] initWithFormat:@"%@ %@", deviceName,
> endpointName];
> }
> else {
> name = [[NSString alloc] initWithString:(NSString*)endpointName];
> }
>
> if (deviceName != nil) CFRelease (deviceName);
> CFRelease (endpointName);
>
> NSString* displayName;
> CFDataRef externalIDs;
> OSStatus result;
>
> NSMutableArray* names = [NSMutableArray arrayWithCapacity:0];
>
> // Pull in a list of external devices connected to our endpoint
> result = MIDIObjectGetDataProperty (
> midiEndpointRef, kMIDIPropertyConnectionUniqueID, &externalIDs
> );
>
> // If we do have external devices, grab all their names and glue them
> together
> if (result == noErr) {
> int i;
> for (i = 0; i < CFDataGetLength (externalIDs); i += 4) {
> SInt32 externalID;
> CFDataGetBytes (externalIDs, CFRangeMake (i, 4),
> (UInt8*)&externalID);
>
> if (externalID != 0) {
> MIDIObjectRef externalDevice;
> MIDIObjectType deviceType;
>
> result = MIDIObjectFindByUniqueID (externalID,
> &externalDevice, &deviceType);
>
> CFStringRef externalName;
> result = MIDIObjectGetStringProperty (externalDevice,
> kMIDIPropertyName, &externalName);
>
> [names addObject:[NSString
> stringWithString:(NSString*)externalName]];
>
> CFRelease (externalName);
> }
> }
>
> CFRelease (externalIDs);
> }
>
> if ([names count] > 0)
> displayName = [names componentsJoinedByString:@", "];
> else
> displayName = name;
>
> return displayName;
>
> Yes, there are places in here where I really should do a little more error
> checking.
>
> And can I just say what an incredible amount of pain is required to do
> something that just about every MIDI app needs to do. Why isn't there a
> CoreMIDI function that does all this hard work for us?
>
> Pete Yandell
> http://pete.yandell.com/
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: SDK Available
  • Next by Date: Re: CoreFoundation (was DigitalCDSound)
  • Previous by thread: RE: User presentation of device names in Jaguar
  • Next by thread: RE: User presentation of device names in Jaguar
  • Index(es):
    • Date
    • Thread