Machine Tongues XIII: Real-Time Audio Conversion under a Time-Sharing Operating System

Time-critical processing of data is a necessary part of many applications written for UNIX and other time-sharing system environments. Although it is known that standard UNIX is not a real-time operating system in any sense, applications that run under UNIX may achieve a measure of time-critical performance by exploiting or bypassing certain aspects of the operating system. Digital-to-analog conversion of sound data is a process by which a numerical representation of a sound wave is translated into the corresponding sound signal by specialized hardware. It is an example of an application in which hardware and software must cooperate closely to meet hard deadlines for data availability. A steady stream of sound data samples must reach the sound-conversion hardware from some storage medium interfaced to the host system, and this must occur at a rate sufficient to sustain playback of the sound signal at the desired rate. Failure to meet these requirements can result in a sound stream full of clicks, skips, or silences. Digital representation and processing of sound requires considerable space for data as well as system speed. According to the Nyquist theorem, a complex sound wave must be sampled at-at least-twice its greatest frequency, in order to be accurately reproduced. Quality recording and playback of sound generally means a sample rate on the order of 48 kHz, each sample having at least 16 bits of precision. Stereo sound requires twice as many samples as mono. So, in these terms, a stereo recording 5 minutes in duration would occupy almost 60 MBytes of disk storage. A 20-minute piece of music would require about 236 MBytes of disk storage. Delivery of these data to the convertor hardware at a rate necessary to maintain continuous playback of sound can depend on several factors, including the speed of access to sound data stored on a disk, the effective bandwidth of the bus on which data are delivered to the convertors, the hardware design of the device that controls the transfer of data from host memory to convertors, and the software design of its device driver. If the convertor hardware is able to store 48,000 samples (i.e., 96,000 bytes) of sound data, for example, 250 msec of stereo sound can be buffered at the 48-kHz sampling rate. Once audio playback begins, there would be less than 250 msec in which to make the next buffer of sound data available to the convertors before the current buffer empties. This is an example of a hard deadline. A hypothetical bus with disk subsystem attached might have the ability to transfer data to the convertors at a rate of 1 MByte/sec, a conservative bandwidth by today's standards. Transferring 48,000 bytes of data in 250 msec would be well within the abilities of such an I/O path as judged by transfer rate specifications alone. However, in a multiuser, multitasking environment, concurrent system activities take bus bandwidth, disk cycles, and processor time away from the audio playback process, interfering with sustained throughput. It is throughput, rather than maximum burst rate of an I/O path, which determines whether playback of high-quality stereo sound will be continuous or broken. It takes only one late sample to produce a gap in the sound as it is heard, no matter how many previous samples might have arrived on time. At the Center for Music Experiment (CME) of the University of California, San Diego, I have had the opportunity to work with three commercially available sound-conversion systems running under the UNIX operating system. All three systems claim to deliver 16-bit, 48-kHz stereo playback of sound in a regular multiuser UNIX environment. One system Computer Music Journal, Vol. 15, No. 3, Fall 1991, ? 1991 Massachusetts Institute of Technology.