View RSS Feed

k-man

Configuring the Beaglebone Black to run Squeezelite

Rating: 1 votes, 4.00 average.
Getting the Beaglebone Black was only supposed to be a fun lesson in following a set of Linux instructions for audio playback, and assessing the merits of embedded systems with low power requirements. The results were convincing enough to share for the first blog, and this next set of instructions is an alternative configuration that will appeal to those who are finding MPD and network mounts to be too complex. With the Squeezebox Ecosystem, the NAS/PC/Mac runs Logitech Media Server and the Beaglebone Black is the client/renderer that runs Squeezelite, and is connected to the USB DAC. If all the hardware is connected according to the “Geek Speak” article, then it’s a simple case of installing the software.

Installing Logitech Media Server (LMS):

My Media - Welcome to mysqueezebox.com!

Some NAS like Synology have management software with the option to install LMS as an App. Run the software, and under Settings add your shared music library to the LMS Media Folder (browsing the folders makes this easy). Scanning the media files initially can be a rather lengthy process for big libraries, but the cached database is stored on the server’s side (instead of the Beaglebone), which is a lot more convenient on startup.

Installing Squeezelite on the Beaglebone Black:

If the instructions for installing MPD in the previous article were completed, then installing the squeezelite libraries won’t be necessary. Otherwise:
Code:
sudo apt-get install libasound2-dev libflac-dev libmad0-dev libvorbis-dev libvo-aacenc-dev libfaad-dev libmpg123-dev
Code:
wget http://squeezelite.googlecode.com/files/squeezelite-armv6hf
Code:
sudo mv squeezelite-armv6hf /usr/bin
Code:
cd /usr/bin
Code:
sudo chmod u+x squeezelite-armv6hf
Code:
./squeezelite-armv6hf –o hw:CARD=1,DEV=0
Now look for the Player in LMS under the Player tab and start browsing your music. For remote apps, Logitech’s own Squeezebox Controller App is free, but iPeng is well worth the premium for a more responsive and intuitive experience, especially those with huge libraries.

Squeezelite Startup

This will start up squeezelite on boot, to give the Beaglebone a 'Toaster' operation. The original script is from a Raspberry Pi thread: Raspberry Pi • View topic - Squeezelite up and running on Raspian Wheezy Hard Float

To create the startup script:
Code:
sudo nano /etc/init.d/squeezelite
Cut and paste this entry into /etc/init.d squeezelite
Code:
#! /bin/sh
### BEGIN INIT INFO
# Provides:          Squeezelite
# Required-Start:
# Required-Stop:
# Should-Start:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Squeezelite
# Description:       Light weight streaming audio player for Logitech's Squeezebox audio server
#                    See: squeezelite - lightweight headless squeezebox emulator - Google Project Hosting
#                    and: Announce: Squeezelite - a small headless squeezeplay emulator for linux (alsa only)
### END INIT INFO
 
# Uninstall Instructions :  update-rc.d squeezelitehf remove
 
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Squeezebox client"
NAME=squeezelite-armv6hf
DAEMON=/usr/bin/$NAME
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/squeezelite
 
# =========================================================
#              CHANGE THESE VALUES IF NEEDED
 
# the name for the squeezelite player (-n option):
SL_NAME="Squeezelite"
 
# Set the soundcard
SL_SOUNDCARD="hw:CARD=1,DEV=0"
 
# Uncomment the next line (remove hash) if you want to change the mac address (-m option):
#SL_MAC_ADDRESS="00:00:00:00:00:01"
#        Note: when left commented squeezelite will use the mac address of your ethernet card or 
#              wifi adapter, which is what you want. 
#              If you change it to something different, it will give problems is you use mysqueezebox.com .
 
# Uncomment the next line (remove hash) if you want to point squeezelite 
# at the IP address of your squeezebox server (-s option). And change the IP address of course..
#SB_SERVER_IP="192.168.2.4"
#        Note: if this is not set, Squeezelite will use auto discovery to find 
#              the LMS server, which works fine too.
 
# Uncomment the next line (remove hash) if you want to set ALSA parameters (-a option, set to buffer size 80):
#SL_ALSA_PARAMS="80"
 
# Uncomment the next TWO lines to turn on logging (-f and -d option):
#SL_LOGFILE=/var/log/squeezeslite.log
#SL_LOGLEVEL="all=debug"
 
 
# =========================================================
 
 
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
 
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
 
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
 
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions
 
#
# Function that starts the daemon/service
#
do_start()
{
 
    # Return
    #   0 if daemon has been started
    #   1 if daemon was already running
    #   2 if daemon could not be started
    start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null || return 1
 
 
    DAEMON_ARGS=""    
   
            # add souncard setting if set
    if [ ! -z "$SL_SOUNDCARD" ]; then
       DAEMON_ARGS="${DAEMON_ARGS} -o ${SL_SOUNDCARD}"    
    fi
 
            # add squeezelite name if set
    if [ ! -z "$SL_NAME" ]; then
       DAEMON_ARGS="${DAEMON_ARGS} -n ${SL_NAME}"    
    fi
           
    # add mac address if set
    if [ ! -z "$SL_MAC_ADDRESS" ]; then
       DAEMON_ARGS="${DAEMON_ARGS} -m ${SL_MAC_ADDRESS}"    
    fi
 
    # add squeezebox server ip address if set
    if [ ! -z "$SB_SERVER_IP" ]; then
       DAEMON_ARGS="${DAEMON_ARGS} -s ${SB_SERVER_IP}"    
    fi
           
    # set ALSA parameters if set
    if [ ! -z "$SL_ALSA_PARAMS" ]; then
       DAEMON_ARGS="${DAEMON_ARGS} -a ${SL_ALSA_PARAMS}"    
    fi
   
    # add logging if set
    if [ ! -z "$SL_LOGFILE" ]; then
       if [ -f ${SL_LOGFILE} ]; then
          rm ${SL_LOGFILE}
       fi
       DAEMON_ARGS="${DAEMON_ARGS} -f ${SL_LOGFILE}"    
    fi
 
    # add log level setting if set
    if [ ! -z "$SL_LOGLEVEL" ]; then
       DAEMON_ARGS="${DAEMON_ARGS} -d ${SL_LOGLEVEL}"    
    fi
           
    start-stop-daemon --start --quiet --make-pidfile --pidfile $PIDFILE --background --exec $DAEMON -- $DAEMON_ARGS || return 2 
 
}
 
#
# Function that stops the daemon/service
#
do_stop()
{
    # Return
    #   0 if daemon has been stopped
    #   1 if daemon was already stopped
    #   2 if daemon could not be stopped
    #   other if a failure occurred
    start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --exec $DAEMON
    RETVAL="$?"
    [ "$RETVAL" = 2 ] && return 2
    # Wait for children to finish too if this is a daemon that forks
    # and if the daemon is only ever run from this initscript.
    # If the above conditions are not satisfied then add some other code
    # that waits for the process to drop all resources that could be
    # needed by services started subsequently.  A last resort is to
    # sleep for some time.
    start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
    [ "$?" = 2 ] && return 2
    # Many daemons don't delete their pidfiles when they exit.
    rm -f $PIDFILE
    return "$RETVAL"
}
 
#
# Function that updates squeezelite
#
do_update()
{
    wget -P /tmp http://squeezelite.googlecode.com/fi...zelite-armv6hf
    sudo cp /usr/bin/squeezelite-armv6hf /tmp/squeezelite-armv6hf.old
    sudo mv /tmp/squeezelite-armv6hf /usr/bin
    sudo chmod u+x /usr/bin/squeezelite-armv6hf
}
 
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
    #
    # If the daemon can reload its configuration without
    # restarting (for example, when it is sent a SIGHUP),
    # then implement that here.
    #
    start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
    return 0
}
 
case "$1" in
  start)
    [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
    do_start
    case "$?" in
        0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
        2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
    esac
    ;;
  stop)
    [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
    do_stop
    case "$?" in
        0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
        2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
    esac
    ;;
  update)
    log_daemon_msg "Update Squeezelite to latest version"
    do_stop
    do_update
    do_start
    ;;
  status)
       status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
       ;;
  #reload|force-reload)
    #
    # If do_reload() is not implemented then leave this commented out
    # and leave 'force-reload' as an alias for 'restart'.
    #
    #log_daemon_msg "Reloading $DESC" "$NAME"
    #do_reload
    #log_end_msg $?
    #;;
  restart|force-reload)
    #
    # If the "reload" option is implemented then remove the
    # 'force-reload' alias
    #
    log_daemon_msg "Restarting $DESC" "$NAME"
    do_stop
    case "$?" in
      0|1)
        do_start
        case "$?" in
            0) log_end_msg 0 ;;
            1) log_end_msg 1 ;; # Old process is still running
            *) log_end_msg 1 ;; # Failed to start
        esac
        ;;
      *)
          # Failed to stop
        log_end_msg 1
        ;;
    esac
    ;;
  *)
    #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
    echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
    exit 3
    ;;
esac
 
:
Save and close the script. To make squeezelite executeable:
Code:
chmod +X /etc/init.d/squeezelite
Test it.
Code:
sudo ./squeezelite restart
To check if squeezelite is running:
Code:
ps -A |grep squeeze
This adds the script to boot.
Code:
insserv squeezelite

Comments

  1. Threeek's Avatar
    Hi, this is very useful thanks, got my BBB up and running squeezelite very quickly.

    Just one comment - the chmod command needs a lower case 'x', i.e it should read:


    chmod +x /etc/init.d/squeezelite
  2. jambam's Avatar
    Question , I already have the beaglebone running mpd , does installing squeezelite to my functional mpd client cause any resource conflict e.g. the usb dac ?

    Can you pls make a script to switch between mpd and Squeezelite , so that we could compare if there is any sonic advantage between mpd and Squeezelite
  3. k-man's Avatar
    Appreciate the feedback :-)

    Just one comment - the chmod command needs a lower case 'x'
    Threeek, thanks for the correction!

    Question , I already have the beaglebone running mpd , does installing squeezelite to my functional mpd client cause any resource conflict e.g. the usb dac ?
    jambam,

    Both squeezelite and mpd require the same ALSA configuration, so either one has to be stopped in order for the other to run. Otherwise it's fine to install squeezelite.

    Can you pls make a script to switch between mpd and Squeezelite , so that we could compare if there is any sonic advantage between mpd and Squeezelite
    I've typed a lot of linux commands, but I still wouldn't know how to build a script for your purpose, sorry! :-(
    I still believe it's convenient enough to make switching just with a few command line entries:

    i.e. From mpd to squeezelite:

    Code:
    /etc/init.d/mpd stop
    Code:
    ./squeezelite-armv6hf –o hw:CARD=1,DEV=0
    And to switch back:
    Hold <ctrl> + <c> to stop squeezelite, then:
    Code:
    /etc/init.d/mpd start
    I've been a mpd+MPoD/MPaD user since 2011, and while the functionality is acceptable, the squeezebox-style environment has its advantages (auto-detection between server and client, auto cover art display). iPeng is a joy to use and I don't have to constantly wait for mpd to 'update database' and 'refresh cache' on start-up. But I couldn't detect a significant sonic advantage between the 2 though (I may lean towards squeezelite ;-) ).
  4. jambam's Avatar
    Thank you for the detailed response ...sorry as i am really a unix newbie ..

    Which file is the startup script that i edit such that i can hardcode bbb boots up with lms or with MPD as my renderer/player.?
  5. JayV's Avatar
    I recently got a BBB with the intent to run Squeezelite in place of my current SB Duet as I would like to play hi-res files. I followed the instructions Chris posted on the build up until the OS setup section. I'm using terminal on my mac to access the BBB, but this is my first time working with Linux. I really have no idea what I'm doing - just following the instructions exactly. When I get to this command:

    ./squeezelite-armv6hf –o hw:CARD=1,DEV=0

    I get the following response:

    root@arm:~# /usr/bin/squeezelite-armv6hf
    [01:46:01.030873] alsa_open:319 unable to set period count Invalid argument
    [01:46:06.040700] alsa_open:319 unable to set period count Invalid argument
    [01:46:11.049763] alsa_open:319 unable to set period count Invalid argument
    [01:46:16.058805] alsa_open:319 unable to set period count Invalid argument

    I can see "Squeezlite" in my LMS, but if I try to play a song, nothing comes out. My dac seems to be getting a signal, though, as it doesn't say "unlocked". Here is the setup:

    Vortexbox Appliance > Ethernet to Router > BBB Ethernet to Router > USB to Marantz SA8004

    Any guidance would be appreciated. Thanks!
  6. ChrisMmm's Avatar
    JayV,

    Try ./squeezelite-armv6hf -l

    This will give a list of the output devices Squeezelite sees. There will be a couple "onbard" devices but the rest should be your USB DAC. I use the "sysdefault" one in the -o startup string, that seems to work best but it will vary depending on your DAC.

    Strangely results can vary depending which device string you use but typically the default, sysdefault and front string work for people. The issue here is within Squeezelite I think rather than the setup within Debian.

    Hope that helps and I haven't put you wrong!

    k-man,

    Thanks for this blog. Had fun getting it working but sounds good now. However I left the setup running (not playing music) overnight and got no sound in the morning even tho "
    ps -A |grep squeeze" reported Squeezelite running. Had to poweroff and restart. Have you had any similar problems?

    Cheers
  7. JayV's Avatar
    Hi Chris,
    Thanks for responding. Unfortunately, I still can't get it to work right. I tried
    ./squeezelite-armv6hf –o hw:CARD=Audio
    and
    ./squeezelite-armv6hf –o hw:CARD=Audio,DEV=0

    but it still proceeds into a loop displaying the below every 5 seconds.

    [01:46:01.030873] alsa_open:319 unable to set period count Invalid argument

    I don't know how to make it stop, so I just close the terminal and start over again. Thoughts?
  8. ChrisMmm's Avatar
    JayV,

    Does ./squeezelite-armv6hf -l give you any output? If so maybe paste it here.

    But I think its primarily a Squeezelite issue so maybe go look/ask at the Squeezelite forum Announce: Squeezelite - a small headless squeezeplay emulator for linux (alsa only)

    Cheers
  9. ChrisMmm's Avatar
    k-man,

    Hi again. Re my issue posted yesterday, recurred today after a few hours (not playing music). I manager to do a restart:

    debian@arm:/etc/init.d$ sudo ./squeezelite restart
    [ ok ] Restarting Squeezebox client: squeezelite-armv6hf.

    Following that music was playing again. Any thoughts on this? I have it running as part of the startup script you provided running a a daemon so maybe an issue with the script?

    Any thoughts appreciated.

    Cheers
  10. k-man's Avatar
    Quote Originally Posted by ChrisMmm
    Following that music was playing again. Any thoughts on this? I have it running as part of the startup script you provided running a a daemon so maybe an issue with the script?
    I haven't experienced the above, since I run the board on battery so only have it on for playback. I can recall some mpd users have their playback stopped due the the log entries being filled after longer sessions. This was remedied by modifying 'alsa-base.conf':

    Instructions from the Geek Speak article:
    - Type -> nano /etc/modprobe.d/alsa-base.conf
    - Arrow to the bottom of the file and add the following text -> options snd-usb-audio nrpacks=1
    - After entering this information press Control O (Control key plus the letter O) then his enter to save the file.
    - Hit Control X (Control key plus the letter X) to close the file.
    I also find restarting squeezelite from iPeng cuts a lot of the hassle (the ON/OFF sign on the top left).

    Thanks for your contributions above!
  11. ChrisMmm's Avatar
    Thanks.

    Having played around with the "-o" string on squeezelite startup what happens now, after a period of time, is that I get a kind of static along with the music rather than no music as before. This is actually similar to a problem I had with my RaspberryPi/Picoreplayer/Squeezelite setup, that was fixed by using -o iec958:CARD=Audio,DEV=0 tho I never understood why, that was a different DAC. Unfortunately does not work in this case tho.

    I notice an ON/OFF button on the Android SB client I use (Orange Squeeze) so I will try that next time I get the noise.

    Again thanks for the blog, I think the Beaglebone has great potential as a Squeezebox player.
    Updated 10-20-2013 at 01:12 AM by ChrisMmm
  12. k-man's Avatar
    The most important tweak I had to make to get it all working perfectly was setting the CPU at its maximum (1GHz).
    From my previous blog entry:
    Changing the CPU frequency governor:

    Code:
    sudo nano /etc/default/cpufrequtils
    Add this line in:

    Code:
    GOVERNOR="performance"

    Note it's a blank page to begin with
    Save the page and reboot. Check it is now running at 1GHz with this command:

    Code:
    cpufreq-info
    I don't think it will be necessary for such tweaks to be implemented for future ARM-based boards, but low power requirements remains the key to get the best performance out of a USB DAC.
  13. ChrisMmm's Avatar
    OK, thanks. Have done this and CPU reporting 100%, lets see if that makes any difference.

    BTW, the "static" noise was there this morning so I did an off/on via Orange Squeeze and this cleared it. so Its not a big deal to reset and get rid of the noise.
  14. JayV's Avatar
    Quote Originally Posted by ChrisMmm
    JayV,

    Does ./squeezelite-armv6hf -l give you any output? If so maybe paste it here.

    But I think its primarily a Squeezelite issue so maybe go look/ask at the Squeezelite forum Announce: Squeezelite - a small headless squeezeplay emulator for linux (alsa only)

    Cheers
    I wasn't around for a couple of days, but here is the output I get from the above command:

    root@arm:/usr/bin# ./squeezelite-armv6hf -l
    Output devices:
    null - Discard all samples (playback) or generate zero samples (capture)
    default:CARD=Black - TI BeagleBone Black, - Default Audio Device
    sysdefault:CARD=Black - TI BeagleBone Black, - Default Audio Device
    default:CARD=Audio - DigiHug USB Audio, USB Audio - Default Audio Device
    sysdefault:CARD=Audio - DigiHug USB Audio, USB Audio - Default Audio Device
    front:CARD=Audio,DEV=0 - DigiHug USB Audio, USB Audio - Front speakers
    surround40:CARD=Audio,DEV=0 - DigiHug USB Audio, USB Audio - 4.0 Surround output to Front and Rear speakers
    surround41:CARD=Audio,DEV=0 - DigiHug USB Audio, USB Audio - 4.1 Surround output to Front, Rear and Subwoofer speakers
    surround50:CARD=Audio,DEV=0 - DigiHug USB Audio, USB Audio - 5.0 Surround output to Front, Center and Rear speakers
    surround51:CARD=Audio,DEV=0 - DigiHug USB Audio, USB Audio - 5.1 Surround output to Front, Center, Rear and Subwoofer speakers
    surround71:CARD=Audio,DEV=0 - DigiHug USB Audio, USB Audio - 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
    iec958:CARD=Audio,DEV=0 - DigiHug USB Audio, USB Audio - IEC958 (S/PDIF) Digital Audio Output

    I'll check out the squeezelite forum as well. Thanks again for the help.
  15. ChrisMmm's Avatar
    I would try "-o sysdefault:CARD=Audio", see how that goes.
  16. syklab's Avatar
    Will I2S output module available and supported ? I really want to do away with UBS. I read about someone had integrated a DAC with I2S with BBB.
  17. k-man's Avatar
    syklab,

    It's worth checking out Oystein's super DIY project integrating his DAC with a BBB.
    http://www.computeraudiophile.com/f1...ct-page-17181/

    However it's still using the USB protocol. The only other CA member who might be able to get I2S out of the BBB would be Miska. So far I've only seen I2S out of a Raspberry Pi on the DIYAudio forum.
  18. ChrisMmm's Avatar
    I am also looking to get my BBB working via I2S.

    Volumio claims to have support and I can get music out using that however there is distortion in one channel I cannot get rid of. I ultimately want to run Squeezelite on the BBB via I2S - the search continues. I am trying to locate drivers and/or somebody who has successfuly achieved it.

    Chris
  19. hottub's Avatar
    Hi all, Followed, the guide above to get squeezelite working on a BBB with a USB sound card, but as with some other users, I ran into a problem with "alsa_open:303 unable to set period count Invalid argument." I found the solution here:

    http://www.diyaudio.com/forums/twisted-pear/250583-building-open-embedded-audio-applicance-36.html

    By taking the paras from speaker-test, I was able to get squeezelite running using the following:

    ./squeezelite-armv6hf -o hw:CARD=AUDIO -a 16384:1024::

    Where AUDIO is the name of the soundcard from aplay -L.

    I also found an interesting article on how to disable the on-board hdmi sound card, but couldn't get it to work for me:

    https://groups.google.com/forum/#!ms...A/maEd2Byzu-sJ

    Hope this helps someone else.
  20. joelha's Avatar
    I'm trying to get my BBB running on squeezelite but am having trouble getting it to talk to my Berkeley Alpha USB converter.

    As an aside, that device runs fine on Daphile on my pc.

    When I enter: "squeezelite-armv6hf" at /usr/bin# on the BBB, I get this in response: "alsa_open:273 unable to set period count Invalid argument"

    I tried using hottub's suggestion and entered: "./squeezelite-armv6hf -o hw:CARD=Output,DEV=0 -a 16384:1024::" but that command just causes the device to hang. Nothing happens until I hit Ctrl-C to stop the process.

    I've tried variations on the above command with no success.

    Given the number of hours I've put into this process and my almost total lack of experience with Linux, I'll greatly appreciate any help anyone has to offer.

    Thanks in advance.

    Joel