Introduction to Computer Music: Volume One

7. Digital-to-Analog conversion

Samples can be stored in a wide variety of fashions—on computer hard disks, in the flash memory of an MP3 player or cell phone, as pits in a Compact Disc picked up by a laser (click here for details), or they can be generated in real time by either a computer or digital instrument such as a sampler, or streamed via online music services. No matter what the storage or creation method, digital samples must be converted back into analog voltage values to be amplified and reproduced as sound from a loudspeaker. The circuit required for such a feat is the Digital-to-Analog Converter or DAC as illustrated in the animation below (press play icon to view the animation, can be expanded to full screen). For the sake of simplicity, we have pictured a 4-bit DAC, while a professional audio interface could easily handle 24-bit up to 32-bit samples. A CD player would have a 16-bit DAC to correspond to the bit-depth of the samples.

Sample buffer: Almost all DACs have a buffer to store a large number of samples to avoid the risk of running out of data during sound production (that would be called a buffer underrun which can generate an error message or a glitch in the audio). The size of the buffer, usually a power of two, strikes a balance between keeping the DAC supplied with data and creating latency, a delay in sound production particularly troublesome when matching real-time audio say from a performer with prerecorded material from a DAW. The latency can be calculated by dividing the buffer size by the sample rate (latency in msec=buffer size/sample rate*1000). A typical buffer of 512 samples creates a latency of ~11 ms at 44.1k, yet a 4096-sample buffer creates a ~93 ms delay, which can be noticeable. Some DAWs provide the option for direct monitoring for realtime recording against tracks, which bypasses the large buffer and reduces latency.

Clock: Each sample is "clocked" into the DAC's sample register at the sample rate via a clock-controlled gate. If samples are clocked into the DAC at the rate they were sampled, then the original frequencies will be reproduced up to the Nyquist frequency. If the samples are clocked in at twice the rate, then the frequency will be doubled. In your audio software or hardware, you may be given a choice between an internal and external clock. An external clock is often used when syncing audio to another device, or in a high-end studio, there may be one master clock for all digital devices. A common studio mishap is to play back an audio file which was recorded at 48K at 44.1K, which lowers the pitch by about a whole step. In the early digital audio days, the clock speeds were not necessarily stable and the DAC output could suffer the same wow and flutter pitch instability as tape machines. There was also the issue of gate slop, as all the binary digits of a sample did not arrive in the sample register simultaneously--the solution was to wait until they were all in place and then take a digital snapshot to create the output (sampling the sample, as it were).

Switches: A '1' in a register place will add a voltage to the sum of that sample proportionate to its binary value by closing a switch (or another type of gate) and completing a circuit connection for its particular electronic value. In our hypothetical illustration above, if we have a sample whose value is decimal 9 mV (binary 1001), the gates or switches for the binary places of '8' and '1' are closed, and the value of 9 mvolts is sent out the DAC and held until the next sample is clocked into the register. The process of outputting a value until the next is clocked in is similar to a sample-and-hold module in synthesis. Should you have visions of 16 or 24 physical switches flopping open and shut at 44,100 times per second per channel of audio, DACs are now very compact and employ microscopic electronic switches on integrated circuit chips, small enough to make your digital watch beep.

Summed voltage: The circuit branches themselves mirror the binary-weighted values of a sample, be it 4-bits or 32-, via a resistor ladder that takes voltage from a single power source, and reduces it by the exponents of 2 for each place in the register. In our 4-bit DAC example, we then end up with paths of 8 mV, 4, mV, 2 mV and 1 mV. If all the switches are closed by a sample of 1111, then the output sums to 15 mV. If they are all open with a sample of 0000, then we get 0 mV's. A 4-bit DAC gives us 16 discreet output values, whereas a 24-bit DAC gives us 224 or +16 million values.

Smoothing filter: Because the output of a DAC creates a stairstep wave (as in the sampling rate diagram of the previous module) instead of a smoother analog one, a smoothing (lowpass) filter tuned to the sampling rate acts to reduce the discontinuity of those steps and the unwanted frequencies they can produce. Although the DAC is operating above twice the Nyquist frequency, in high-resolution audio, the sharp discontinuities of the stairstep wave cause high harmonic frequencies that can alias into the audio range, therefore the smoothing filter is required. What emerges from the final output is a more continuous analog voltage that can be connected to an amplification chain (mixer, amp, speakers, etc.).

| Jacobs School of Music | Center for Electronic and Computer Music | Contact Us | ©2017-18 Prof. Jeffrey Hass