Listen Again!

Having set up a couple of Linux computers to play audio files I wanted to use them to listen to internet radio streams. In fact, this was my main interest in having the machines working! Broadly speaking, internet radio comes in two forms. The most common type is a stream of data you obtain from a URL (web address). Typically this is something like an mp3 format stream. However the BBC also provide their iPlayer, and that works differently.

I have always loved BBC radio – particularly Radio 3, Radio 4, and the World Service. Nowdays I also enjoy Radio 7. Having all these accessible via Digital Terrestrial TV (DTTV) is very handy. When the BBC started providing them as aac/aac+ streams via their iPlayer I became curious. Would the aac/aac+ iPlayer streams sound as good, or better, than via DTTV? I was also attracted by the ‘listen again’ facility that lets you listen as and when you like for up to a week after the live broadcast. I often find that I have missed a radio program I’d like to hear, and for one reason or another didn’t have a chance to record. So ‘listen again’ promised to be very useful for me.

Having got my Ubuntu/Xubuntu systems working I installed the ‘Flash’ plugin for FireFox and tried the iPlayer. I chose to install the Adobe version of Flash to ensure it was going to work. But alas, when I tried to listen using a Cambridge Audio DACMagic USB DAC, I heard nothing! I experimented with all the sound settings and controls. No success. The BBC iPlayer behaved as if it was working fine. The animation that indicates the stream is arriving and being decoded worked. The little slider that shows elapsed time moved along. I could even drag it with the mouse, and the time shown changed OK. The only flaw was that no sound emerged from the DAC! The symptoms indicated that the sound stream was being fetched, decoded, then flung down a black hole.

I spent a few days trawling the web and found a variety of diagnoses and suggested ‘fixes’ that didn’t solve the problem. Fortunately I then found a Ubuntu forum webpage[1] that explained the problem and gave instructions. I followed these, and could finally hear the iPlayer output emerging from the USB DAC! So if you are using Ubuntu or Xubuntu (9.04 or earlier) and have problems you might like to have a look at that page. In practice, the solution was to remove sound control from the default Linux ’ALSA’ setup and install the Pulse Audio sound system. Then to set all the relevant control levels to ‘100%’ for the required sound sources and the output ‘sound card’ (actually the USB DAC in my case). Also, mute or zero all other system sounds if you wish to avoid various computer events or activities adding their own accompaniment to your musical enjoyment!

Once Pulse Audio was in control I found it was fairly easy to get things working. Indeed, Pulse Audio allowed me to confirm that the problem was, indeed, that the ‘Flash’ plugin was insisting on sending its sound output to what it thought was my ‘default’ soundcard, ignoring the fact that I had setup the system so that my USB DAC was the default for everything else. Alas, the Flash system gave me no way to directly tell the iPlayer plugin where I wanted the sound to go. But Pulse Audio allowed me to easily ‘redirect’ the output to the USB DAC. Problem solved.

The BBC kindly gave me access to an engineering address which provides some test streams. I was able to use these to assess the behaviour of the transmission chain provided by the iPlayer, Flash plugin, etc. This let me check basic parameters like the nominal gain (volume setting) and distortion behaviour. Here I can show some of the results I obtained using a 320kbps aac stream that conveyed a 1 kHz sinusoid at the -24dBFS level. All of the results below were obtained using my Shuttle X11G5 computer running Ubuntu 9.04, with Pulse Audio directing the output to my Cambridge Audio DACMagic via USB. I then recorded the spdif emerging from the optical output of the DACMagic for analysis. This meant I could examine the actual digital data output stream produced without it being affected by any analogue stages in the playing system. Unless otherwise stated all relevant audio system gain/volume levels were set to ‘100%’ as I found this was optimum for playing other material. The output was at 44.1ksamples/sec as that is the sampling rate of the BBC aac/acc+ streams.

Fig1.gif - 38Kb

Figure 1

The Flash plugin for the BBC radio iPlayer has a slider that you can use to set the volume. This control displays a number from ‘11’ (maximum) down to ‘0’ (silence). Since this operates in the digital domain I wondered, does using this control to adjust the volume affect the distortion level? Comparing the two spectra shown in Figure 1 we can see that it does. The spectrum on the right is with the iPlayer volume set to ‘11’. If you look at the spectrum you can see two things. Firstly, the level of the 1 kHz tone was -24.1dBFS. This is close enough to the nominal level I was told to expect by the BBC that it establishes that for the iPlayer ‘11’ means ‘full volume, gain of unity’. The second point to note is that the distortion products are at the -110dBFS level and below. For a -24dBFS tone this corresponds to a percentage distortion of around 0·005%. This is very low, so is unlikely to have any audible significance.

However looking at the spectrum on the left of Figure 1 we can see that altering the iPlayer level to ‘10’ has two effects. One is what we’d expect. The signal level is reduced, by about 1·5dB. But we can also see that the levels of the distortion components have risen to almost -100dB. The percentage distortion is still small – around 0·01%, but this increase is a warning sign.

Fig2.gif - 35Kb

Figure 2

Figure 2 shows spectra for two other iPlayer level settings. Looking at these you can see that the size of the distortion components do vary with the iPlayer level setting. But in general the unwanted components reach up to the region between -100dBFS and -110dBFS even when we have reduced the volume level quite audibly. Since we are reducing the size of the wanted signals this means the percentage distortion is increasing as we turn down the volume. So if we change the volume from ‘11’ down to ‘2’ we increase the percentage distortion by around a factor of ten as we reduce the volume by about 15dB. Of course, this is still a very small amount of distortion, but the behaviour demonstrates that there is a general tendency for the percentage distortion to increase if we use the iPlayer level control to turn down the volume.

Behaviour like this is common for ‘digital’ level controls. It can be suppressed by careful use of methods like noise-shaping and dither. But the iPlayer Flash plugin code does not seem to employ such methods. Hence – although the effect is likely to be small – my preference is to always leave the iPlayer level set at ‘11’, ensure the digital systems in the computer are all set to ‘100%’ and then adjust the volume with the controls on the hi-fi system which is being fed by the DAC. This avoids any needless extra computations that can cause effects like the above. That said, you may need to be careful if you are taking output from an analogue ‘headphone’ or ‘line’ output on your computer. As I found on a previous occasion these may be overloaded by using ‘100%’ (0dB) gain settings. So my advice here is to use a digital output, and check if you can for any clipping or unintended level changes that your computer setup may be applying without your knowledge.

I find that the quality of the sound produced using the system I am using to be very good indeed. I now tend to prefer using the iPlayer to DTTV or FM. However for the reasons I discuss on this webpage, and on a previous page, you may need to take care to setup your computer/OS/hardware so as to avoid some snags and pitfalls. Otherwise you might conclude that the BBC aac/aac+ iPlayer sounds poor, when it might be your computer/audio setup that is degrading the sound! Alas, it can be very difficult to get useful information on the key points from most computer retailers. So choosing and setting up a system that works well is harder than it should be!

Jim Lesurf
1500 Words
20th Jul 2009


prev.gif - 2352 bytes  ambut.gif - 3891 bytes  next.gif - 2248 bytes