ADC Home > Reference Library > Technical Notes > Hardware & Drivers > Audio >
Important: The information in this document is Not Recommended and should not be used for new development.
Current information on this Reference Library topic can be found here:
|
Background of the ChangesDevelopers have asked for faster, more flexible sound input drivers with more useful features. The new PCI sound input drivers are the first step towards addressing these requests. One request was for reduced latency between when the recording starts and when the application gets the first bit of recorded data. Another request was for an interrupt buffer that was an integer power of 2 so that algorithms such as fast Fourier transforms could work more efficiently. Users requested a simpler sound input model; existing drivers made it too hard to configure the Mac for simple audio tasks, such as listening to a CD or adjusting the computer's volume. Apple's support representatives frequently answered calls from users who were unable to listen to an audio CD. This problem is addressed by the new sound input drivers as well. The final change, the removal of the sound input driver's
interface (the
The ChangesLatency ReductionOne of the most common requests was for reduced interrupt latency in sound input and output (playback). This has been addressed by reducing the size of the hardware interrupt buffer from 1056 samples to 512 samples when virtual memory is off. When VM is on, the buffer size is 4096 samples, which is a reduction from its previous value of 4224 samples. The number 512 was chosen for two reasons. By reducing the size of the buffer by approximately 50%, interrupt latency was reduced by 50% as well. Now sound interrupts happen approximately every 11 milliseconds instead of every 22 milliseconds (for 44.1KHz sound). This allows recorded data to be given to the application with less latency and allows for sounds being played to start sooner. The second reason the buffer size was reduced to 512
samples is that 512 is a integer power of 2, which is
important to developers trying to do real time analysis of
the sound being recorded. The algorithms that are used to do
this type of analysis (i.e., fast Fourier transforms)
frequently require buffers that are an integer power of two.
By adjusting the sound driver's buffer size, the developer
no longer has to do any complicated buffering of data in
their interrupt callback routine. Use the
Options Dialog RemovedThe
It was felt that developers could provide a better
interface than the New Ways to Select an Input SourceDevelopers asked for a uniform way to select sound input
sources. This has been accomplished with the
Simpler Sound ModelAnother change which helps to simplify the sound model on the Macintosh is that separate volume controls for the headphones and internal speaker have been merged into one control. There is no longer support for setting the headphone volume independently of the internal speaker's volume (because users were often confused by which volume slider they needed to adjust to get the proper volume level), or for controlling the mute state of the internal speaker when headphones are plugged in. How to Cope With These Changes GracefullyLatency ReductionDealing with the driver's input buffer change should not
present any problems. For the most part, applications won't
notice that anything has changed. The few applications that
do care about the interrupt buffer size should already be
calling Options Dialog RemovedThe removal of the There seems to be a lot of confusion on the point of how to properly configure the sound input driver. Keep these simple rules in mind when designing your application:
Under these simple rules, it is clear that relying on the user to set the sound input source through Monitors & Sound or the Sound control panel is the wrong thing to do: it breaks the first three rules. The correct way to configure the sound input driver is to present an interface of your own creation, or QuickTime's SequenceGrabber interface, to the user. The minimum required interface must allow the user to select the desired input source and playthrough state. Once the input source and playthrough state (sample rate, sample size, number of channels, etc.) is set, do not close the input driver, as there is no guarantee that when the driver is reopened that the driver will default to the settings the user instructed your program to make. If you must close the input driver, reset it to the chosen configuration when you reopen it. New Ways to Select an Input SourceTo make it easier for application writers to choose the correct input source the new PCI sound input drivers implement two new selectors that work with OSTypes for selecting the input source. These new selectors are:
The
The For more information about how to use the
You can always attempt to use these selectors without doing any Sound Manager/Sound Input Manager version checking beforehand. If an error is returned when you attempt to use these selectors, the sound input driver doesn't support these new selectors and you will have to have a fallback plan (like putting up a dialog for the user to select an input source) for setting the sound input source. Simpler Sound ModelThe removal of independent volume controls for the headphones and internal speaker was done to give users an interface more consistent with other audio hardware, such as home stereos. In this audio model, when headphones are plugged in, the main unit's speakers are disabled and the volume control now controls the headphone volume. It's a simple concept, like the one button mouse: with only one volume control you always know which one to use. Any API calls which affect the volume of the internal speaker also set the volume of the headphones and vice versa. There is no way to adjust the volumes independently; that feature has been removed. This also allows the sound model to remain consistent with Macintoshes that physically don't allow for independent volume control of the headphones and internal speakers or which physically disconnect the internal speaker when headphones are plugged in. Sample CodeHere is some sample code showing how to access the
Here is a sample illustrating a basic technique to create
your own sound input options dialog. First, get the list of
sound input source names and turn that list into a menu (in
this case a pop-up menu), insert that menu into a dialog and
then display the dialog. Once the dialog has been dismissed,
if the user did not cancel it, you use
Additional Notes & CommentsAs always, QuickTime exists to make dealing with audio
(either playing or recording) easier. If your application
only requires simple recording, you may wish to use
QuickTime to do that recording. QuickTime supplies a
standard user interface that can be accessed via one simple
call, SummaryThe changes to the PCI sound input drivers do not have to mean pain and suffering for you and your users if your application allows the user to configure the sound input driver from your application. However, if your application relies on other software to configure the sound input driver for you, now is the time to update your application to correctly handle all sound configuration itself. ReferencesTechnote 1108: Unknown Sound Features Technote 1048: Some Sound Advice: Getting the Most Out of the Sound Manager Downloadables
|
|