Re: Apple USB MIDI driver & port names
Re: Apple USB MIDI driver & port names
- Subject: Re: Apple USB MIDI driver & port names
- From: Doug Wyatt <email@hidden>
- Date: Mon, 6 Mar 2006 09:40:36 -0800
On Mar 6, 2006, at 6:47, Nick wrote:
Thanks for the info Doug. I think we'll stick to not having a
driver (true plug-and-play is too cool)
To be more specific you could write a driver that doesn't grab the
device and do I/O, leaving that to the class driver. Your driver,
once installed, would look for instances of your hardware and set the
endpoint names on it. Or you could write a very minimal utility app
to do this. You can identify devices which are instances of your
hardware using:
#define kUSBVendorProductProperty CFSTR("USBVendorProduct")
which is an integer that comes from:
UInt32 vendorProduct = ((UInt32)USBToHostWord(devDesc->idVendor) <<
16) |
USBToHostWord(devDesc->idProduct);
e.g.
int idev, ndev = MIDIGetNumberOfDevices();
for (idev = 0; idev < ndev; ++idev) {
MIDIDeviceRef device = MIDIGetDevice(idev);
if (!device) continue;
UInt32 vendorProduct;
if (MIDIObjectGetIntegerProperty(device, kUSBVendorProductProperty,
&vendorProduct) == noErr) {
if (vendorProduct == kMyVendorProduct) {
// find the device's entities and/or endpoints and set names as
appropriate
int ient, nent = MIDIDeviceGetNumberOfEntities(device);
for (ient = 0; ient < nent; ++ient) {
MIDIEntityRef entity = MIDIDeviceGetEntity(device, ient);
if (!entity) continue;
if (nent < kNumberOfEntityNamesIKnowAbout) // safety check
MIDIObjectSetProperty(entity, kMIDIPropertyName, myEntityNames
[ient]);
}
}
}
}
but it would be nice to see support for this device port naming
scheme.
I agree about about prepending the device name.. It's a shame more
don't do it. Perhaps if there were an API call which builds a
string in the recommended way, more would?
CFStringRef displayName = NULL;
MIDIObjectGetStringProperty(theEndpoint, kMIDIPropertyDisplayName,
&displayName);
As I said this requires Tiger+; however the identical code to
accomplish this is in the SDK.
Doug
Nick
On 3 Mar 2006, at 19:06, Doug Wyatt wrote:
P.S. Apps really should be prepending the device name to the port
name, at least in the case where just using "Port 1" is non-
unique! If you have an example of one that's not, please let me
and the app developer know. The app developer should use
kMIDIPropertyDisplayName (on Tiger), or there's example code in
the SDK to accomplish the same thing.
Doug
On Mar 3, 2006, at 11:02, Doug Wyatt wrote:
The USB-MIDI class spec includes a way for a device to name its
own ports. The Tiger driver doesn't implement this, but I did
make some changes last month .....
In the meantime we're stuck with the "Port %d" behavior but it is
possible for you to write a little MIDI driver that doesn't grab
the device for I/O but does change its port names ... or you
could do this in a little setup app.
Doug
On Mar 3, 2006, at 7:07, Nick wrote:
Hi,
Does anyone know how Apple's class-compliant MIDI driver chooses
the names for ports on a device?
One of our devices has three ports, and these get named as "Port
1", "Port 2" and "Port 3".
This means the value of kMIDIPropertyName will be "Port 1" and
this gets displayed in most apps for selecting MIDI devices.
We'd like to change the port names to make it obvious to users
they are part of our device!
Regards,
Nick
--
Doug Wyatt
Core Audio, Apple
--
Doug Wyatt
Core Audio, Apple
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden