Quantcast
Channel: Squeezebox : Community : Forums - DIY
Viewing all articles
Browse latest Browse all 123

DIY Squeeze house installation

$
0
0
Objectives:
  • low-cost multiroom system
  • Some rooms with single, some with double speakers
  • high sound quality is not a prioity
  • no additional (powered) devices in the rooms (besides the speakers)
  • no new cables to speakers, use of the given Cat5 cables
  • Linux as OS; use one of my already running boxes


Hardware:
5x USB sound-card with amp
(lsusb: ID 19a8:2036 Biforst Technology Inc)
1x USB-Hub
1x 8 Port Patch-panel
*x Speakers Dynavox TG-1000B 50W
[intent]http://www.amazon.de/Dynavox-TG-1000...dp/B002KX8RWI/[/intent]
*x Patch-cords


Used software:
Linux as OS; here I used my already runnning "mythbuntu" (Ubuntu server with Mythtv packages, no UI)
ALSA-Config to get the USB-cards up and running, no soundserver like Pulseaudio!
A Squeezeslave instance for every room (own init-script)
Of course the squeezebox server

UDEV config:
Because there are multiple amps, they must be uniquely identified.
The modeles used here don't have any serial-numer at which they can be separeted.
So I used the USB-Attr "devpath" wich is reladed to the physical ports an the USB-Hub.
To set a name to every amp, use the "ATTR{id}" field.
If anything on the USB-installation changes, just this configuration must be modified.

/etc/udev/rules.d/90-persistent-usbauio.rules
Code:

SUBSYSTEM!="sound", GOTO="usb_audio_end"
ACTION!="add", GOTO="usb_audio_end"

ATTRS{idVendor}=="19a8", ATTRS{idProduct}=="2036", ATTRS{devpath}=="1.1",  ATTR{id}="usbaudioHW1"
ATTRS{idVendor}=="19a8", ATTRS{idProduct}=="2036", ATTRS{devpath}=="1.2",  ATTR{id}="usbaudioHW2"

LABEL="usb_audio_end"

ALSA config:
Use the names set by UDEV for the PCM-DMIX destination.
The docs of ALSA was a good help wor that; http://alsa.opensrc.org/Udev#Identif..._audio_devices

You can check them with "cat /proc/asound/cards"
Code:

user@:~$ cat /proc/asound/cards
 0 [usbaudioHW2    ]: USB-Audio - USB Audio Device
                      USB Audio Device at usb-0000:00:1d.7-1.2, full speed
 1 [usbaudioHW1    ]: USB-Audio - USB Audio Device
                      USB Audio Device at usb-0000:00:1d.7-1.1, full speed

/etc/asound.conf
Code:

!for stereo rooms:
pcm.usbaudio1 {
        type plug
        slave {
                pcm "dmix:usbaudioHW1"
                rate 46875
                format S16_LE
        }
}

!for mono-rooms (left and right could be different rooms/instances of squeezeslave!):
pcm.usbaudio2left {
        type plug
        slave {
                pcm "dmix:usbaudioHW2"
                rate 46875
                format S16_LE
        }
        ttable.0.0 1
        ttable.1.0 1
}


pcm.usbaudio2right {
        type plug
        slave {
                pcm "dmix:usbaudioHW2"
                rate 46875
                format S16_LE
        }
        ttable.0.1 1
        ttable.1.1 1
}

Squeezeslave config:

/etc/default/squeezeslave
Code:

BIN="/opt/squeezeslave/squeezeslave"
PIDDIR=/var/run/
LOGDIR="/var/log/squeezeslave/"
SERVER="squeeze.box"

/etc/squeezeslave
Code:

INDEX=1
NAME[$INDEX]="Room1"
MAC[$INDEX]="19:21:16:83:01:71"
OUTPUT[$INDEX]="usbaudio1"
CUSTOM[$INDEX]="-R"

INDEX=2
NAME[$INDEX]="Room2"
MAC[$INDEX]="19:21:16:83:01:72"
OUTPUT[$INDEX]="usbaudio2left"
CUSTOM[$INDEX]="-R"

INDEX=3
NAME[$INDEX]="Room3"
MAC[$INDEX]="19:21:16:83:01:73"
OUTPUT[$INDEX]="usbaudio2right"
CUSTOM[$INDEX]="-R"

ACTIVESLAVES=(1 2 3)

/etc/init.d/queezeslave
Code:

#! /bin/bash

### BEGIN INIT INFO
# Provides:          squeezeslave
# Default-Start:    2 3 4 5
# Default-Stop:      1
# Short-Description: Squeezeslave daemon
# Description:      Squeezeslave connects to a squeezebox-server and
#                    enables this client to act as an audioplayer
### END INIT INFO

set -e

# /etc/init.d/squeezeslave: start and stop the squeezeslave daemon

BIN=""
PIDDIR=""
LOGDIR=""
SERVER=""
SQUEEZESLAVE_DEFAULTS_FILE=/etc/default/squeezeslave
SQUEEZESLAVE_CONFIG_FILE=/etc/squeezeslave

test -x $bin || exit 0

if [ -s $SQUEEZESLAVE_DEFAULTS_FILE ]; then
    . $SQUEEZESLAVE_DEFAULTS_FILE
else
    exit 0
fi

if [ -s $SQUEEZESLAVE_CONFIG_FILE ]; then
    . $SQUEEZESLAVE_CONFIG_FILE
else
    exit 0
fi


. /lib/lsb/init-functions

squeezeslave_start() {
        if [ -n "${OUTPUT[$INDEX]}"  ]; then
                AUDIO="$($BIN -L | grep -i "${OUTPUT[$INDEX]}" | awk -F ':' '{ print $1 }' | sed -e '1,$s/ //g' | sed -e '1,$s/*//g')"
                if [ -n "$AUDIO" ]; then
                        AUDIO="-o$AUDIO"
                fi
        fi
        PID="$PIDDIR/squeezeslave-${NAME[$INDEX]}.pid"
        LOG="-M $LOGDIR/${NAME[$INDEX]}.log"
        MAC="-m ${MAC[$INDEX]}"
        CUSTOM="${CUSTOM[$INDEX]}"
        OMIT=""
        for RUNSLAVE in $(/bin/pidof $BIN) ; do
                OMIT="$OMIT -o $RUNSLAVE"
        done
        /sbin/start-stop-daemon --start --chuid root --name squeezeslave --pidfile $PID --startas $BIN -- $LOG $MAC $CUSTOM $AUDIO $SERVER
        log_end_msg $?
        /bin/pidof $OMIT $BIN > $PID
        sleep 1

} # squeezeslave_start

squeezeslave_stop() {
  for PID in $(ls $PIDDIR/squeezeslave-*.pid) ; do
        start-stop-daemon --stop --quiet --oknodo --name squeezeslave --pidfile $PID
        log_end_msg $?

        if [ -a $PID ]; then
                rm $PID
        fi
  done
} # squeezeslave_stop

case "$1" in
  start)
       
        log_daemon_msg "Starting squeezeslave daemon" "squeezeslave"
        for SLAVE in ${ACTIVESLAVES[*]} ; do
                INDEX=$SLAVE
                squeezeslave_start
        done
        ;;
  stop)
        log_daemon_msg "Stopping squeezeslave daemon" "squeezeslave"
        squeezeslave_stop
        ;;

  reload|force-reload)
        log_warning_msg "Reloading squeezeslave daemon: not needed, use restart."
        ;;

  restart)
        set +e
       
        log_daemon_msg "Restarting squeezeslave daemon" "squeezeslave"
        squeezeslave_stop
        sleep 2
        for SLAVE in ${ACTIVESLAVES[*]} ; do
                INDEX=$SLAVE
                squeezeslave_start
        done
        ;;

  status)
        ;;
  *)
        echo "Usage: /etc/init.d/squeezeslave {start|stop|reload|force-reload|restart|status}"
        exit 1
esac

exit 0

Hardware installation:
All stuff is installed on a wooden-plate which lays in an IT-Cabinet (19"), the outputs of the amps are connected to a small patch-panel.
Always two lines of the installation-cabel (CAT5;used TIA-568A) is used for one line on the amp:

Pin--->Color---->Amp
----------------------------
1+2--->GrW+Gr--->left-Black
3+6--->RdW+Rd--->Left-Red
4+5--->Bl+BlW--->Right-Black
7+8--->BrW+Br--->Right-Red


In the top-left-corner is the USB-Hub, which is connected to the Linux-PC when the plate is in the rack.
Some of the amps are installed with stereo (top-left and top-middle on img), the others are splitted left and right to different panel-ports.
The spezial-one on the bottom right is to have a network-printer and the speaker on the same line.
Between Squeeze-Patch-Panel and House-Patch-Panel standard Patch-Cords are used.

Name:  Rack-Installation.jpg
Views: 207
Size:  20.8 KB


open issues:
  • somtimes instable ASLA-names to USB-Hardware bindings --> should be fixed with the use of UDEV-Names as added above; time will see
  • after some time the output of a mono-room hangs, direct play of sound (aplay) works, still investigation needed
  • after some time the sync of a mono-room get lost, still investigation needed
  • One time sync was lost completly and can't be resynced by stop and start different music, restart of squeezebox server was needed.
    Never had it again since then.



So I would feel happy about some feedback, tips for improvement and help for the open issues...

Cheers
Benno
Attached Images
 

Viewing all articles
Browse latest Browse all 123

Trending Articles