Raspberry Pi used as a Squeezebox server

rpi-squeezebox-server

[Jacken] loves his lossless audio and because of that he’s long been a fan of Squeezebox. It makes streaming the high-bitrate files possible. But after Logitech acquired the company he feels they’ve made some choices which has driven the platform into the ground. But there is hope. He figured out how to use a Raspberry Pi as a Squeezebox server so that he can keep on using his client devices and posted details about the RPi’s performance while serving high-quality audio.

First the bad news: the RPi board doesn’t have the horsepower necessary to downsample on the fly. He even tried overclocking but that didn’t really help. The good news is that this issue only affects older Squeezebox clients (he had the issue with V3) and only when playing tracks that are much higher quality than a CD (24-bit at 88.2Khz). He has no problem streaming those files to devices that can play them, and can even stream multiple files at once without any issues.

You can install the Sqeezebox server on your own Raspberry Pi by following this guide.

Comments

  1. “the RPi board doesn’t have the horsepower necessary to downsample on the fly”

    I truly do not believe I’ve ever seen a statement so false in my life. Downsampling audio is a well-understood problem, that does *NOT* require hundreds of MIPS to perform. Sorry. The tools you may be using may be terrible, or they are being misused, or a hundred other reasons. One things it is not: not enough CPU power.

  2. Gimnazjalny Socjalizm says:

    Who needs sampling faster than 44,1 kHz? No seriously, those audiophiles are uneducated.

    • CopperMaze says:

      Well I’m a sound engineer and by experience I can say that a 15kHz sine wave (audible) sounds like crap at 44.1kHz (you only have 3 sample per period). It sounds much much better at 96kHz. Sure, if you don’t have monitors speakers or a rather good stereo system, and if you don’t have comparison points, you will never figure out what’s the difference, so stay at 128kbps wma. In studio, the recording sample rate for me cannot be less than 192kHz @ 24bits depth, except for some specials takes.

      • grapsus says:

        I don’t know about your magic audio equipement, but I know the math : 15 kHz harmonic sampled at 44 kHz then converted back to analog and filtered with a low pass filter gives you the original 15 kHz sine wave. The whole point of Fourier analysis and the Nyquist theorem is that you need to sample at two times the fastest harmonic in order not to loose information, that’s it. Passed that point, sampling faster doesn’t make the information “better”.

        • CopperMaze says:

          Well in fact the Nyquist frequency is the minimum sampling frequency you need to determine the original frequency of a signal. It’s not the frequency you need to shape the signal.
          If you sample a 22k wave at 44k, in some cases you get only zeros. 44k sampling freq means that you only get 2 sample per period. So if your sampling start when the wave is at 0, you only get zeros all the way. Your 22k simply disappeared.

          • grapsus says:

            At 15 kHz, if your signal isn’t a sine, it must have higher order harmonics (30 kHz, 45 kHZ and so on). The human ear acts as a low pass filter with a cut-off frequency around 20 kHz (and it lowers with age). Therefore whatever the shape of your 15 kHz signal, the ear can only get a 15 kHz fundamental sine wave.
            Any recording equipement filters everyting to at least half the sampling frequency in order to avoid aliasing. Thus every signal with a fundamental above 10 kHz can only be a sine wave, and that’s the whole point of the Nyquist theorem : you need at least two points per period to get the phase and the amplitude of a sine wave. “Two points” in the sense “stricly greater than two points per period”, that’s why we use 44 kHz and not 40 kHz as lossless sampling rate. The Nyquist theorem garanties that any sine harmonic inside the band will get more than two sampling points and this is all you need. With 44 kHz sampling error will only be induced by the precision of the sampling, not the sampling rate itself.

            I have studied signal processing for several years and I can proove everything I state by precise math. Your answer shows clearly that you don’t understand the Fourier analysis at all and the only arguments you provide is audio technician chat-chat.

  3. dominic says:

    Sorry guys; as much as I hate the unhappy comments, installing some packaged software onto a computer is NOT a hack!

  4. grombeestje says:

    NEON? Afaik, NEON is ARMv7, so NEON wouldn’t run on the RPi since it’s ARMv6

  5. Heisreal says:

    802.11n wifi: ~40MBps (dual-150Mbps channels)
    USB 2.0 theoretical bitrate: 35MBps
    10/100 Ethernet max bitrate: ~10MBps

    The processor runs at 700Mhz, as fast as the first AMD rig I built using slot-A cartridges, and possibly faster than the 700Mhz Celeron the first XBox’s had.

    Setup a USB NAS using FreeNAS, and just stream your ridiculously huge audio files using an 802.11n dongle over wifi. No need to downsample, and who wants to downample anyway? CD quality is only 320KBps, crap compared to raw audio files. Your ears have forgotten that tinny, empty sound of mp3s suck compared to good analog.

    • Steve says:

      He needs to down sample because the older squeezebox hardware doesn’t support the higher bit rates.

      • rasz says:

        No. He needs to downsample because he swallowed bucked load of snake oil and thinks he can hear 44KHz.

        • Scott McCain says:

          The higher your sample rate the less aliases you will get. This is called the Nyquist rate. The Nyquist rate is double the frequency being sampled, so a 15khz sine wave will have a Nyquist rate of 30khz. Or, to put it differently, a 44.1khz sample frequency (CD sample rate) will fold any frequency above 22.05khz and create aliases (which you might hear, especially if the sample rate is below any audible frequencies). Keep in mind that at the minimum you will still get aliases and higher order harmonics from folding, so it’s always better to sample at higher rates.

          • grapsus says:

            1. You never get aliases, because any sampling equipement uses a low pass filter before sampling. If the sampling frequency is 44 kHz, there is a 22 kHz low pass filter before.
            2. What higher order harmonics ? When we say that a human ear in good shape can hear up to 20 kHz we talk about the fastest harmonic it can sense. If your signal is a 15 kHz square wave, all the ear is getting is the first 15 kHz sine harmonic, the second one cannot be heard.

          • CopperMaze says:

            If you sample a 22k sine at 44k, and filter it after, you get a minimum of 6dbu loss, without even counting the distortions factors.

            In fact the input of ADCs are at 1/2 the frequency rate (yes Nyquist) to avoid input signal to create lower frequency components.
            http://www.ni.com/white-paper/3016/en#toc4

            If you want to preserve the SHAPE of a signal, your sampling frequency MUST be way higher than the Nyquist 1/2 crap frequency.

            I’ll write an article…….

        • Look, I’m 47 years old and can’t hear zilch above 16.000hz. I fixed the problem by writing a Python script that downsampled all files above 48Khz to 24-bit, 48Khz (Yay, a new article that includes a hack). Problem solved. But for me, high res files is like a Rolex. Sure, a Timex probably will hold the time as well, or maybe even better than a Rolex. But it’s a Rolex!
          The main good thing about high res files are the mixing. It’s usually better done by people who care about sound quality and not affected by the Loudness War as much…

    • Blue Footed Booby says:

      Totally ignoring the digital vs analog canard, where do you get these better-than-CD audio files?

  6. CopperMaze says:

    Here’s a rather good documentation about ‘digitizing’ in the NI site.
    http://www.ni.com/white-paper/3016/en

    For the reproduction of sound, CD quality is ok. But if you have high quality wave to reproduce, and the sound system which go along, try to improve the DAC quality rather than downsample the stream.

    Same deal for the analog chain. Don’t be afraid to open the amp and change the value of any input low pass filter you can found on the path of sound. If a DSP handle the process (like in Bose crap), you’re screwed.

    “There came a point when we realized that the
    magical octave above 20kHz was as important as
    that below it. Extended frequency response became
    the aim, together with better noise and always with
    very low Total Harmonic Distortion. That meant new
    transformers. A lot of work went into designing these
    and we achieved a full response to over 200kHz.”
    Rupert Neve.

    And here’s a paper about hypersonic effect on listeners:
    http://www.icad.org/Proceedings/2002/YagiNishina2002.pdf

    Cheers.

    • grapsus says:

      What next ?

      1. Build a photo camera capable of sampling UV and IR in addition to the visible light
      2. Build displays capable of displaying UV and IR data
      3. Claim it changes everything in the brain citing some experimental neuroscience data
      4. Sell the equipement over 9000$
      5. Profit

      • CopperMaze says:

        Hey, I’m not here to make you buy $10k B&W loudspeaker, but you cannot process music by looking at a spectrum. And I know the math too, but keep talking technical please.

        I’ve totally agreed to the arguments you’ve pointed out. Mathematically and theoretically. We don’t need sample rate higher than 44.1k for reproducing music, as the hearing limit is 20k. This is well known and I’m ok with that. And I agree with the fact that nobody needs bandwidth 5 times better than the max frequency to run a Fourier or a Laplace transform.

        In studio it’s not the same deal. Keeping the bandwidth high during recording and mixing prevents sounds above 10k to just sound like noise, especially when mixing more than 10 tracks. As you know, when getting closer to the Nyquist Shannon limit, you loose highers harmonics (those inaudible bastards). But the thing you didn’t understood is that when mixing down a bunch of these non well formed waveforms, you just get noise were you should still have emphasis and clarity. The highs seems blurred. But again, this is only a recording studio concern.

        This is why I’m saying that CD quality is OK, because the conversion to lower sample rate is made only at one time and after the mixing and mastering process (loudering process).

        Now, at home, why better DAC and HQ sources ? Well if you can put your hand on a HD sound file, convert it to 44.1, and do the comparison (winAmp do the trick). If you hear no difference on a good system, it doesn’t worth it.

        Also, about the aliasing, I think Scott McCain is right but I’m not sure. As long as we didn’t invented the analog brick-wall filter, even if we filter the input of a 44.1 ADC at 20kHz, a 40kHz signal will still fold. We only have 15 or 27dBm attenuation for a good active filter. And given the 124dBfs S/N for good 24 bits ADC, it’s non negligible. I’ve never thinked about that before. And also higher order filters or Chebychev will overshoot, screw the highs and generate harmonics.
        Somebody measured aliases in this case ?? Paper on it ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 92,354 other followers