A Rapsberry-PI Juke Box


Created by: tarek

Published Mar. 13, 2013

In this tutorial you will learn how to make a Juke Box with your Raspberry-Pi

You need:

  • A Raspberry !
  • An SD card, like http://www.amazon.fr/dp/B000WQKOQM
  • An USB stick, like http://www.amazon.fr/dp/B0052QT6BQ
  • A wifi dongle, like: http://www.amazon.fr/gp/product/B003X26PMO
  • A speaker, like http://www.amazon.fr/gp/product/B001UEBN42


Related categories: Tutorial

Step 1: Setting up the SD card and the system

The Raspberry won't work with every SD card. It's not a matter of price or quality. Some work, some don't.

Make sure to pick one listed in  http://elinux.org/RPi_VerifiedPeripherals#SD_cards

Then you can download the latest Raspbian and unzip it. On my macbook:

cd /tmp
wget http://files.velocix.com/c1410/images/raspbian/2012-12-16-wheezy-raspbian/2012-12-16-wheezy-raspbian.zip
unzip 2012-12-16-wheezy-raspbian.zip

Make sure to get the freshest release at http://www.raspberrypi.org/downloads

Once you have the SD card plugged in and the image unzipped, you can use DD to prepare the disk.

Find out which disk your SD is on (by running diskutil list) for example and then run:


$ diskutil umountDisk /dev/disk3
Unmount of all volumes on disk3 was successful

$ sudo dd bs=1m if=/tmp/2012-10-28-wheezy-raspbian.img of=/dev/rdisk3
[... 5-10 minutes ...]
1850+0 records in
1850+0 records out
1939865600 bytes transferred in 388.257496 secs (4996338 bytes/sec)

$ diskutil eject /dev/disk3
Disk /dev/disk3 ejected

dd is pretty long to run, and on Mac OS X and all BSD-Like system, you can use /dev/rdiskX instead of /dev/diskX

Once it's over you can plug the SD in your Raspberry and start up!

Step 2: Basic settings, wifi & ssh

When the Raspbian starts for the first time, you will get a configuration screen. What I usually do is:

  • extend the partition to the whole SD with expand_rootds ,
  • overclock your R-PI with overclock  : I used medium
  • activate the SSH server in ssh
  • deactivate the desktop in boot_behavior

Once this is done, plug your wifi dongle and restart the R-PI with Finish

And logged back in (user: pi, password: raspberry), you have to edit the /etc/network/interfaces file so the wifi autoconnects

to your network. I plugged the dongle on the bottom USB port, so that's wlan0 according to iwconfig.

Here's my config

auto wlan0

iface wlan0 inet dhcp
    wpa-ssid Villa_Des_Mouches
    wpa-psk motdepasse

where I set up my SSID and my password.

Restart your network:

$ sudo /etc/init.d/networking restart

 you should get an IP and from there check that you can access to your R-PI via SSH

$ ssh pi@
Linux raspberrypi 3.2.27+ #250 PREEMPT Thu Oct 18 19:03:02 BST 2012 armv6l

Last login: Sun Oct 28 23:10:12 2012
pi@raspberrypi ~ $

From there, we can unplug the screen & keyboard and operate from a computer.

Step 3: Setting up the sound

Plug a speaker to the audio JACK and make sure the sound works by downloading a WAV file

$ wget http://www.freespecialeffects.co.uk/soundfx/sirens/police_s.wav
$ aplay police_s.wav
Playing WAVE 'police_s.wav' : Unsigned 8 bit, Rate 22000 Hz, Mono
^CAborted by signal Interrupt...

You should here something.

Now install mpg123 and check that you can hear some MP3 files. I added a USB key with mp3 files, 

mounted the SUB key and played them using mpg123

$ sudo apt-get install mpg123
$ sudo mkdir /media/usbstick $ sudo mount -t vfat -o uid=pi,gid=pi /dev/sda1 /media/usbstick $ mpg123 "/media/usbstick/01 Hidden Orchestra - Flight Mixtape.mp3" High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3 version 1.14.4; written and copyright by Michael Hipp and others free software (LGPL/GPL) without any warranty but with best wishes Directory: /media/usbstick/ Playing MPEG stream 1 of 1: 01 Hidden Orchestra - Flight Mixtape.mp3 ... MPEG 1.0 layer III, 320 kbit/s, 44100 Hz joint-stereo Title: Hidden Orchestra - Flight Mixtape Artist: Hidden Orchestra (Joe Acheson) Comment: Exclusive mix for http://www.parisdjs.com Album: Paris DJs Podcast Year: 2012 Genre: Podcast




Step 4: The JukeBox application

Jukebox is a Django app that provides a queue to play music and drives mpg123.

First, install all those packages:

$ sudo apt-get install python-virtualenv libshout3 libshout3-dev pkg-config python-dev

Then you can deploy Jukebox in a directory

$ virtualenv --no-site-packages jukebox
$ cd jukebox
$ bin/easy_install -U distribute
$ bin/pip install ez_setup
$ bin/pip install jukebox

Then read up this page to configure it https://github.com/lociii/jukebox#readme

The biggest issue of this tool is that it requires a Twitter account to log in. I did not have the time to code/plug a simple auth.

There are other software you can install, like Mopidy which will let you stream Spotify music

and drive it from an android tablet or phone.


comments powered by Disqus