USB audio simplified
The rapid expansion of the universal serial bus (USB) standard in consumer electronics products has extended the use of USB connectivity to propagate and control digital audio. USB provides ample bandwidth to support high-quality audio; its ease of use has been well accepted by consumers and has made USB a popular audio interface. However, extracting the audio data from a USB port is not a simple task. USB itself is a complex protocol that requires considerable domain expertise.
In addition, other audio-related challenges, such as synchronization of data streams and programming codec and digital-to-analog converter (DAC) configurations, can challenge even the most experienced embedded and audio designers. USB bridge devices are now available that not only eliminate USB software development complexity but also provide a novel standard audio configuration interface and methods to synchronize audio data streams in a low-cost, highly-integrated single-chip solution.
USB is a versatile interface that provides many ways to propagate and control digital audio; however, it is important for the industry to follow a standardized mechanism for transporting audio over USB to secure interoperability, which has been the cornerstone for the adoption of USB. To respond to this fundamental request, the USB organization has developed the Audio Devices Class, which defines a very robust standardized mechanism for transporting audio over USB. The USB audio class specification is available to the public from the USB Implementers Forum (www.usb.org).
One of the major issues with streaming audio over USB is the synchronization of data streams from the host (source) to the device (sink); this has been addressed by developing a robust synchronization scheme on “isochronous transfers,” which has been incorporated into the USB specification.
The Audio Device Class definition adheres to this synchronization scheme to transport audio data reliably over the bus. However, the implementation of this synchronization mechanism is not a trivial task, and legacy implementations have required high-end embedded systems with complex data rate converters or expensive phase-locked loops (PLLs) to support the clock accuracy demanded by the system.
In a system with a sampling rate of 48 kHz, the host sends a frame containing 48 analog output samples every millisecond. The sink must buffer the audio output data so it can be sent to the DAC one sample at a time. Any clock mismatch between host and device (however slight) will result in an overrun or underrun condition. The USB specification defines several methods for accommodating host/device clock mismatch.
USB defines modes that govern the operation of sources and sinks according to Table 1. (For audio-out, the host is the source and the device is the sink. For audio-in, the device is the source and the host is the sink.)
For asynchronous operation, the sink provides explicit feedback to the source. Based on this feedback, the source adjusts the number of samples that it sends to the sink. Figure 1 illustrates asynchronous mode with an analog output device.
This feedback mechanism accommodates source/sink clock mismatch without requiring the sink device to implement PLL hardware to synchronize with the host clock.
Figure 2 shows a buffered system for a 48 kHz sampling rate. Initially, the host starts streaming data at 48 samples every USB start-of-frame (SOF) operation, which occurs each millisecond. However, if the device’s buffer begins to approach the full or empty condition due to clock mismatch, the device can request that the host send more (49) or fewer (47) samples so that buffer overrun or underrun does not occur.
This method is implemented in Silicon Labs’ CP2114 USB-to-I2S digital audio bridge device. The Audio Device Class is supported by the CP2114 device without any additional software development.