Raspberry Pi vs USB vs Mac Audio

 

The audio hardware of Raspberry Pi is known to produce relatively poor sound quality. I bought a cheap USB sound card to try as an alternative. Here is what I found.

This is how the USB card was identified by the Raspberry Pi kernel.

usb 1-1.4: new full-speed USB device number 21 using dwc_otg
usb 1-1.4: New USB device found, idVendor=0d8c, idProduct=013a
usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1.4: Product: USB PnP Sound Device
usb 1-1.4: Manufacturer: C-Media Electronics Inc.
input: C-Media Electronics Inc.       USB PnP Sound Device as /devices/platform/bcm2708_usb/
usb1/1-1/1-1.4/1-1.4:1.3/0003:0D8C:013A.0007/input/input6
hid-generic 0003:0D8C:013A.0007: input,hidraw0: USB HID v1.00 Device [C-Media Electronics
Inc.       USB PnP Sound Device] on usb-bcm2708_usb-1.4/input3

USB audio card I listened to some music pieces both with the Raspberry Pi audio output and with the USB device, but I could not discern a big difference. I therefore recruited a volunteer to conduct a series of simple a/b tests. Again, the test results were inconclusive, so we decided to look at produced waveforms with an oscilloscope.

The first measurement was of an A440 tone (440 Hz, musical note A above middle C). I produced that on the Pi with the following commands.

speaker-test -t sine -f 14080 -Ddefault:CARD=ALSA
speaker-test -t sine -c 2 -f 14080 -Dfront:CARD=Device,DEV=0
The two outputs looked roughly the same; in fact the output from the USB card appeared to come from a worse filter than that of the Pi. Therefore, I also measured the sound output of a Apple MacBook Pro laptop. I produced the corresponding tone with Audacity's Generate - Tone command. Here is the output of the three audio outputs playing an A440 tone. (You can click on each image to view it in greater detail.)
440 Hz tone from a Raspberry Pi 440 Hz tone from a USB device 440 Hz tone from a MacBook Pro
Raspberry Pi USB device MacBook Pro

After more careful reading, I found that the problem with the Raspberry Pi PWM output was apparent at higher frequencies. Therefore, I moved five octaves higher, and looked at the output at 14080 Hz. Here are the results.
14080 Hz tone from a Raspberry Pi 14080 Hz tone from a USB device 14080 Hz tone from a MacBook Pro
Raspberry Pi USB device MacBook Pro
The results look again sine-wave-like, with the Raspberry Pi and the USB audio device exhibiting some notches along each wave. My first interpretation of the results was that these notches demonstrated the problem I had read regarding the Raspberry Pi sound quality. I then noticed that the Mac appeared to be outputting a higher frequency that the other two audio outputs. I checked whether I had set a different timescale when I measured the Mac, but the X axis was the same, 1 ms, for all three measurements. My next thought was that I had bungled Audacity's tone generation. By counting the cycles, it became apparent that the Mac was in fact outputting a tone of about 14 kHz (as expected), but the other two devices were in fact producing a tone of about 5 kHz. I verified this by listening to both tones; in retrospect I could have done that without resorting to oscilloscope measurements.

The moral of the story is that the Raspberry Pi output isn't great, but it's not worse than what you get from a cheap USB audio card. Will this affect my use of the Raspberry Pi as a media player? I'm not sure. While reading on the topic I found the following great quote.

A music lover listens to music with his sound system.
An audiophile listens to his sound system with music.

Comments   Toot! Share


Last modified: Sunday, December 13, 2015 12:02 am

Creative Commons Licence BY NC

Unless otherwise expressly stated, all original material on this page created by Diomidis Spinellis is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.