• 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
Re: Hint and tips about audio/midi USB drivers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Hint and tips about audio/midi USB drivers


  • Subject: Re: Hint and tips about audio/midi USB drivers
  • From: Herbie Robinson <email@hidden>
  • Date: Mon, 29 Nov 2004 01:54:42 -0500

Hi all,

I will very soon have to work (professionally ) on a project that includes the writing of an audio/midi USB driver for Mac OS X. I'm looking for hint, tips, caveats etc that could prevent me to run into the wall :))

Some questions:

- Where do I need to start from? There's a sample code in the CoreAudio SDK called SampleUSBMidiDriver, it looks like a perfect candidate for the midi part.

Yes.

There are numerous samples in kernel/IOKit/audio and kernel/IOKit/usb. The PhantomAudioDriver looks like a very good candidate for the audio part. Any other sample codes I should have a look at?

- Do I need to write a single audio and midi driver or is it better to write two different drivers (if it makes sense as they both apply to the same device)?

MIDI drivers are user mode plug-ins that are loaded by the MIDIServer process. Audio drivers are kernel extensions.


- There's a point that comes back frequently on this list: it is kernel land driver versus user land driver. What is the recommended approach for midi, for audio, for a single audio and midi driver?

They cannot be the same driver. Your kernel driver may need to publish its own interface for the MIDI driver to use: Unless the hardware can appear as two different standard entities to the OS: In other words, a PCI card with a bridge on it or a multi-function USB device. If you are talking about a USB device, the device hardware could be implemented with an internal hub to avoid software drivers.


If you are talking a single USB device, you might be able to present a "configuration" with both MIDI and audio "interfaces". It might be possible to have the kernel (i.e., audio driver) reserve the entire MIDI device, set the configuration and reserve the audio interface and just reserve the MIDI interface from a user program. I can remember from debugging using a MIDI interface that you can't change the configuration of a device if something else has it open, but I never experimented with having more than one entity opening different interfaces on the same device. If this is possible, then you can probably get away with tweaking the sample drivers (which I believe implement the USB standard protocols for MIDI/Audio). If not, then you will need to write a kernel driver and interface for MIDI that communications with your official MIDI driver.

- There has recently been a discussion about latency added by the drivers (related to the safety offset). Periodic data such as audio are transported using the isochronous mode, while Aperiodic data - such as midi - are transported using the bulk mode. That's nearly all I know - for the moment - about USB protocol :)) Anything to take care of as far as latency is concerned? For instance, what happens when multiple devices send data "at the same time" using the isochronous 125us/1ms modes and the bulk mode?

Some MIDI controllers actually present an ischronous interface, but it would seem to be a bad idea because dropped characters are a major problem with MIDI. I would recommend bulk mode for output and maybe interrupt transfers for input data that isn't time stamped. Time stamping helps MIDI somewhat, but it isn't a total replacement for low latency.


The USB driver should be ensuring that there is always enough bandwidth available for all the open isochronous connections. Bulk and Interrupt mode get the rest.

Note that only the most recent Macs come with USB 2.0. From what I have seen, Firewire 400 MHz performs better (and it is more widely supported on Macs). [Just in case that is relevant.]

I have found USB to not be 100% reliable: Make sure you test your driver with a cheap six foot cable that is coiled tightly (a 4-6" loop will be quite revealing).

- I've downloaded the 9MByte+ USB 2 specs. I know that I will have to eat the whole cake someday, but in the meantime, does anyone know pointers to site where I could find something like 'USB for the dummy"?

Reading through the sample MIDI driver is actually very helpful (presumably the audio version is, too). You need to understand what "configurations" and "interfaces" are.
--
-*****************************************
** http://www.curbside-recording.com/ **
******************************************
_______________________________________________
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
References: 
 >Hint and tips about audio/midi USB drivers (From: Philippe Wicker <email@hidden>)

  • Prev by Date: Why do G5 optical inputs have more latency than analog?
  • Next by Date: Re: Why do G5 optical inputs have more latency than analog?
  • Previous by thread: Hint and tips about audio/midi USB drivers
  • Next by thread: Trouble with AudioDeviceGetCurrentTime....
  • Index(es):
    • Date
    • Thread