Please consider a donation to the Higher Intellect project. See or the Donate to Higher Intellect page for more info.

Sound Input Manager

From Higher Intellect Vintage Wiki
Jump to navigation Jump to search

The Sound Input Manager uses sound input device drivers to allow applications to access sound input hardware in a device-independent way. A sound input device driver is a standard Macintosh device driver used to interface to an audio digitizer or other recording hardware. If you use the Sound Input Manager’s high-level routines, the Sound Input Manager handles all communication with a sound input device driver for you. If, however, you need to use the Sound Input Manager’s low-level routines, you must open a sound input device driver yourself. You might also need to get information about certain attributes of a sound input device. Sound input device drivers allow your application to query a device about such attributes.

Sound Recording Without the Standard Interface

The Sound Input Manager provides your application with the ability to record and digitally store sounds in a device-independent manner even if your application does not use the standard sound recording interface. In cases where you need very fine control over the recording process, you can call various low-level sound input routines.

Your application can obtain control over sound recording in two different ways. First, if your application uses the sound recording dialog box, you can modify the dialog box’s features by defining a custom filter procedure, as explained in detail in the chapter “Dialog Manager” in Inside Macintosh: Macintosh Toolbox Essentials. Second, if your application needs to fine tune the sound recording process itself (or if your application does not use the standard sound recording dialog box), then the application must use the Sound Input Manager’s low-level routines.

In instances where you need to gain greater control over the recording process, you can use a set of routines that manipulate the incoming sound data by using sound parameter blocks. The parameter blocks contain information about the current recording device, the length recorded, a routine to call on completion of the recording, and so forth. You can call the SPBRecord function (or the SPBRecordToFile function) to begin a recording. Then you can use the functions SPBPauseRecording, SPBResumeRecording, and SPBStopRecording to control the recording. Note that you need to open a device (using the SPBOpenDevice function) before you can record from it. On completion of the recording, you should close the device (using the SPBCloseDevice function).

If you do record sounds using the Sound Input Manager’s low-level routines, you also need to set up your own sound resource headers or sound files, because the Sound Input Manager’s low-level routines return raw sampled-sound data to your application. The Sound Input Manager provides two functions, SetupSndHeader and SetupAIFFHeader, that allow you to set up your own sound resource headers or sound files.

Interaction With Sound Input Devices

The Sound Input Manager provides routines that allow your application to request information about a sound input device or to change a sound input device’s settings. The types of information you can obtain about a sound input device include

  • the name, icon, and icon mask of the device driver
  • whether the device driver supports asynchronous recording
  • the device’s settings, such as the number of channels the device is to record, the compression type, the number of bytes per sample at the current compression setting, and the sample rate to be produced by the device
  • the range of compression types, sample rates, and sample sizes that the device supports

You can also use the Sound Input Manager to change some of a sound input device’s settings and to turn features on and off. For example, you can turn on and off automatic gain control on some device drivers. Automatic gain control moderates sound recording to give a consistent signal level. Second, you can turn on and off the playthrough feature, which allows the user to hear through the Macintosh speaker the sound being recorded. Third, you can turn on and off VOX recording, or voice-activated recording, which allows your application to record only when the amplitude of sound input exceeds a certain level. You can use VOX recording either to prevent recording from starting until sound is at least a certain amplitude or to automatically stop recording when sound falls below a certain amplitude. This latter capability is called VOX stopping.

An important feature of sound input devices is continuous recording. All sound input devices that support asynchronous recording should support continuous recording as well. Continuous recording allows your application to make several consecutive calls to the SPBRecord function without losing data between calls. For example, you might need to record a lengthy sound to disk but not be able to fit the entire sound into RAM. Thus, it’s important to be able to save a buffer of data to disk while the sound input device driver continues to collect recorded data. The Sound Input Manager’s SndRecordToFile function relies on continuous recording.

To get information about a device or to turn features on and off, you can use the SPBGetDeviceInfo and SPBSetDeviceInfo functions. These functions allow you to use sound input device information selectors to specify what type of information you need to know about the device or what settings you wish to change.

Sound Input Device Drivers

The Sound Input Manager also provides several routines intended for use only by sound input device drivers. Sound input device drivers need to register themselves with the Sound Input Manager by calling the SPBSignInDevice function. This makes that device visible in the Sound In control panel for possible selection as the current input device. You can remove a device from that panel by calling the SPBSignOutDevice function.

For Macintosh computers with built-in sound recording hardware, the system software includes a sound input device driver. This driver automatically calls SPBSignInDevice when the computer starts up. If you are creating a sound input device driver for some other sound recording hardware, your device driver must register itself at startup time. Once your driver is registered, it must respond to Status, Control, and Read calls issued by the Sound Input Manager. The Sound Input Manager issues Status calls to get information about a device, Control calls to set device settings, and Read calls to initiate recording.

See Also