pancakelizard

turn your raspberry pi into a virtual DJ streaming device for a second room PA system

Posted on February 6, 2013

I finally found a great use for my #raspberrypi, i used it to provide a technological answer to a problem i faced as a DJ, when asked to run the audio i'm playing into the bar downstairs, so they can hear it in both rooms. the easy fix would have been run a 30m audio cable out of the window, downstairs, and into the bar. but thats a messy solution, involving a lot of effort and gaffa tape. This uses homeplugs (or wifi access points if that doesnt work) to do the same sort of thing. youll need virtualDJ and set it up in broadcast mode to stream the audio via the LAN.

heres my proof of concept version of it up and running:

raspberry pi test rig

you will need:

model B pi
a case (although this is optional and you could always make your own out of lego/cardboard/etc!
a microUSB PSU. my ipad charger works fine for this along with a normal microusb cable
a 4gb SD card (or bigger) although a 2gb will probably work ok too...
a couple of RJ45 cat5/6 ethernet cables
a pair of powerline ethernet "homeplug" devices - http://www.hotukdeals.com/search?action=search&keywords=homeplug - ive got a piar of 500mbit ones, but 100mbps plugs should in theory be enough for for job.

then, with the pi, set it up as follows:

this assumes you are partially familiar with TCP/IP networking, comfortable with a command-line interface, and using an ssh client on your pc, but all of which is pretty easy to pick up. its just a case of doing a bit of background reading.

download raspbian wheezy and "burn" to your SD card.

http://downloads.raspberrypi.org/images/raspbian/2012-12-16-wheezy-raspbian/2012-12-16-wheezy-raspbian.zip

if you havent done this before, use the guide at http://elinux.org/RPi_Easy_SD_Card_Setup

on your raspberry pi, plug into a hdmi screen with a usb keyboard and network cable into your switch/router:

run the raspi config and set it up accordingly (ie password, etc) then set up networking:
sudo raspi-config
cp /etc/network/interfaces /etc/network/interfaces.sav
sudo cp /etc/network/interfaces /etc/network/interfaces.sav
sudo pico /etc/network/interfaces

add the following (if not using wifi, the second bit for wlan0 isn't needed) to /etc/network/interfaces:

auto lo

iface lo inet loopback
#\iface eth0 inet dhcp

auto eth0
iface eth0 inet static
#your static IP
address 192.168.1.20
#your gateway IP
gateway 192.168.1.1
netmask 255.255.255.0
#your network address "family"
network 192.168.1.0
broadcast 192.168.1.255

allow-hotplug wlan0
iface wlan0 inet static
address 192.168.1.21
netmask 255.255.255.0
gateway 192.168.1.1
wireless-essid nottsdjdotcodotuk
# wpa-psk "<password of wireless network>"
# wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
# iface default inet dhcp
reboot, and check everything comes up ok:

sudo reboot

after the reboot, see if you can access if via your main desktop PC via the ethernet:

ssh pi@192.168.1.20
(or use puTTY if you are on a windows system)

assuming this works, you can do everything else from your main pc now, but dont unplug that hdmi/keyboard just yet in case something goes wrong!

install mpg123, sound card utils and update the firmware and OS:

sudo apt-get install alsa-utils
sudo apt-get install mpg123
sudo amixer cset numid=3 1sudo apt-get update
sudo apt-get upgrade
sudo apt-get install git-core
sudo wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update && sudo chmod +x /usr/bin/rpi-update
sudo rpi-update
sudo reboot

run update once more after the reboot just to confirm you are on the latest firmware:

sudo rpi-update

check /etc/asound.conf exists and contains something like (this depends on the results of lsmod):

lsmod
sudo pico /etc/asound.conf

#pcm.mmap0 {
# type mmap_emul;
# slave {
# pcm "hw:0,0";
# }
#}
#
#pcm.!default {
# type plug;
# slave {
# pcm mmap0;
# }
#}
pcm.!default {
type hw
card 0
}

ctl.!default {
type hw
card 0
}
fire up virtualdj from your laptop/desktop, setting your ip address to 192.168.1.100 (or whatever your computer's IP address is) and making sure your firewall is either disabled of there is an appropriate hole for port 8000. play some music in vdj.

run mpg123 and test it streams ok from virtualdj:

mpg123 -ol http://192.168.1.100:8000/VirtualDJ.mp3

assuming this works ok, create a script to run it from boot:

sudo pico /etc/init.d/playaudiostart.sh

add in the following lines:

### BEGIN INIT INFO
# Provides: scriptname
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
#!/bin/bash
amixer cset numid=3 1
mpg123 -ol http://192.168.1.100:8000/VirtualDJ.mp3

make your script executable and bootable:

sudo chmod +x /etc/init.d/playaudiostart.sh
sudo insserv playaudiostart.sh

reboot the device, and test it autoboots and plays music from vDJ.

once all configured and tested, try it in a different room using your homeplug (or wifi) devices. once all tested at home, I went to the venue last week and made sure it all ran ok. it worked first time using the homeplugs, so i didnt even need to set up the wifi. RESULT! I'll post an update once i've actually gigged with it next month.

 

Filed under: geek, HOWTO Leave a comment
Comments (1) Trackbacks (0)
  1. Nice work fella, it’s worth noting that homeplugs won’t work if the two ends of the link are on different mains circuits (or different phases). In larger buildings this is likely to be the case so be sure to have a backup plan!


Leave a comment

No trackbacks yet.