Audio System

From Whitespace (Hackerspace Gent)
Revision as of 22:57, 4 April 2011 by Fs111 (Talk | contribs)

Jump to: navigation, search


Audio System
WhitespaceLogo.gif
What:
Creating a network controlled integrated music system for the entire space.
Participants:
Koen
Locations:
Whitespace
Events:
Audio system hacking
Cornify


Current Configuration

  • Two channel amplifier placed in the rack
  • Stereo also placed in rack connected to TUNER input
  • Extra analog audio line from main room to amplifier connected (CD input)
  • PC connected to VIDEO/AUX input, see Software section below for more info
  • Small stereo used as rear amplifier

Usage

Hey-turn-music-down.jpg
  • Playing files/web-streams:
    • Power-up the main amplifier
      • Make sure at least one zone is selected (A = Front room / B = Back room)
      • Make sure the volume isn't all the way turned down (or up ;-))
      • Select VIDEO/AUX
    • Boot the Audio server
    • Use any MPD client you like to connect to audio:6600
    • note there is now a playlist provided which has the streams for a selection of popular Belgian radio stations.
  • Playing audio from another laptop/music player
    • Power-up the main amplifier
      • Make sure at least one zone is selected (A = Front room / B = Back room)
      • Make sure the volume isn't all the way turned down (or up ;-))
      • Select CD
    • Connect audio source to analog line in the main room and turn it on
  • Playing plain old FM radio
    • Power-up the main amplifier
      • Make sure at least one zone is selected (A = Front room / B = Back room)
      • Make sure the volume isn't all the way turned down (or up ;-))
      • Select TUNER
    • Power-up the stereo and use it as before
    • note volume is controlled by amplifier

Ideas:

  • Fixed amp sound level at max we'll allow
  • Volume controlled with software
  • Software: The silent guy, MPD, Play Airwolf at due time --> combined using Jack (some people suggest pulseaudio can also be used for this purpose)
  • FM? Transmitter of receiver?
  • Make all use cases configurable via the network, proposed solutions:
    • Hack the main amplifier
    • Hack the main amplifiers remote
    • Do a full software solution
      • connect extra audio line to the PC's line-in
      • use a analog capture card to get FM input, and make these streams configurable by MPD (The Medion used as table-PC seems to have a capture card)
  • use djmount to automatically mount uPNP shares enabling easy access to media files on other devices

Hardware:

What we have available

  • A two channel amplifier. (Bert)
  • Two big speakers (Bert)
  • An average sized stereo (Kurt)
  • A small stereo (Impy)
  • A desktop with surround sound-card (Tom)
  • Jack to cinch cables
  • Cinch to cinch cables

Thanks to all who have contributed hardware!

What we need

  • The small stereo currently used as aft amplifier could use an update.

Todo

  • Hang all speakers
  • Connect all speakers to there amplifiers (Only one left todo, rear left)
  • Rack mount the amplifier
  • Connect the amplifiers to the PC
  • Give the Audio System a fixed IP

Optional

  • Figure out what the s-control port does on the main amplifier.
  • Make the amplifier for the aft speakers powered only when music is played in that room.

Software:

This configuration was made on (K)Ubuntu 10.10.

Jack

We will try to use Jack to make smooth combination of the audio sources. Jack was installed from the repositories. It's currently working however audio quality is horrible and now unusable. After some further investigation led me to the conclusion that Pulse-audio can also be used for this purpose. Since Pulse-audio is the default sound back-end for Ubuntu these days that option has proven to be easier to implement.

Pulseaudio

In Ubuntu 10.10 Pulse-audio is normally started on a per user basis when you log in to you gnome session. As we would like to run MPD even if nobody is logged in we also need to run Pulse-audio system-wide. This can easily be done by putting the following line in /etc/default/pulseaudio:

PULSEAUDIO_SYSTEM_START=1

Now we can start Pulse-audio system-wide:

sudo killall pulseaudio
sudo /etc/init.d/pulseaudio start

After this only users in the pulse-access group can use the audio device. So we need to add both our regular user and the user running MPD (default mpd) to this group. This can be done using the following command:

sudo usermod -a -G pulse-access whitespace

MPD Server

MPD or Music player Deamon. Installed from repositories. By default MPD is configured to run system wide and use Alsa as a sound back-end. Because we want to blend several audio streams together we cannot use Alsa but Pulse-audio. To make MPD use Pulse-audio the Alsa section in /etc/mpd.conf needs to be commented out and the Pulse-Audio section needs to be uncommented.

#audio_output {
#	type		"alsa"
#	name		"My ALSA Device"
#	device		"hw:0,0"	# optional
#	format		"44100:16:2"	# optional
#	mixer_device	"default"	# optional
#	mixer_control	"PCM"		# optional
#	mixer_index	"0"		# optional
#}

audio_output {
	type		"pulse"
	name		"My Pulse Output"
#	server		"remote_server"		# optional
#	sink		"remote_server_sink"	# optional
}

After this we can restart MPD.

sudo /etc/init.d/mpd restart

To make MPD control not only it's own volume but the machines master volume we must change the Alsa audio_output type again to the following:

audio_output {
	type		"alsa"
	name		"My ALSA Device"
	device		"pulse"		# optional
#	format		"44100:16:2"	# optional
#	mixer_device	"default"	# optional
	mixer_control	"Master"	# optional
#	mixer_index	"0"		# optional
}

Make sure these things are all commented out:

#mixer_type		"hardware"
#mixer_type		"software"
#mixer_type		"disabled"

Then restart Pulse-audio and MPD again. note For some reason my volume was muted after this step.

To make MPD accessible from every PC on the local network make sure the following line is in you mpd.conf.

bind_to_address         "any"

MPD sound Menu

To allow the locally logged in user on the audio server easy control over the MPD daemon we installed mpd-sound-menu. This a small applet for the Gnome sound menu in the top menu bar. Installation instructions:

sudo add-apt-repository ppa:torkvemada/torkvemada
sudo apt-get update
sudo apt-get install mpd-sound-menu

This application was configured to automatically start when the user whitespace logs in.

djmount

We will use djmount to make all UPNP shares on the local network available to MPD. Like most software djmount can be installed straight from the repositories. The next commands allow you to mount and umount all UPNP servers on your network.

sudo djmount -o allow_other /var/lib/mpd/music
sudo fusermount -u /var/lib/mpd/music

To start djmount automatically every time the system is booted the following needs to be added to the /etc/rc.local file.

djmount -o allow_other /var/lib/mpd/music

To set up a UPNP server see here.

If you quickly want to share your music in the space w/o setting up a lot, install ushare (apt-get install ushare || yum install ushare) and do a

ushare -c /some/directory/with/music -i wlan0/eth0/whatever -n $HOSTNAME

The last parameter gives your server a unique name and it will show up in the djmount. In case you use a packet filter, please open UPNP, while you are sharing your music. That's all.

MPD Clients

There are a wide range of MPD clients available for a wide range of platforms. Feel free to add you experiences here:

Cross-platform

Linux

  • Ario (has avahi a.k.a zeroconf support and finds the server automatically)
  • GMPC
  • Sonata
  • MPC (CLI) usage mpc --host=audio --port=6600 (play/stop/toggle/pause/next/prev/volume +xx/-xx/xx)
  • Xfmpc

Windows

Mac OS X

iPhone

Android

Web client

Ampache (No longer active)

A web interface to stream one's media library and control an MPD server. The debian install package seems to have a bug so it is necessary to create an extra symlink before configuration can begin. This web interface is available at http://audio/ampache. Try it using user root and password ****** (the one we often use)

Ampache requires a MySQL database. It was installed from repositories with as root password the one we use too often. The ampache user in the MySQL db is ampache, the password is """"

MPDplayer

A very simple and straight forward PHP application. Make sure Apache, PHP and the Apache PHP module are all installed properly. Download the tar file from this site http://www.renedegroot.nl/mpd.xml. Then all you have to do is untar it to your www directory and make sure user rights are set up properly. When you're in the space you can access it by simple visiting http://audio.

Silent Guy

Playing Airwolf

The Airwolf theme should be played on midnight Thursday and Friday. The file will come straight from YouTube, so we are not storing copyrighted information on our server. Play Airwolf from command line straight from YouTube ignoring video:

vlc -I dummy --vout null  http://www.youtube.com/watch?v=nr_CJL1YQRc

with additions for running in crontab

DISPLAY=:0.0 /usr/bin/vlc -I dummy --play-and-exit --vout null  http://www.youtube.com/watch?v=nr_CJL1YQRc

full crontab line for now (still running more frequent to allow testing):

*/2 * * * * DISPLAY=:0.0 /usr/bin/vlc -I dummy --play-and-exit --vout null  http://www.youtube.com/watch?v=nr_CJL1YQRc

finally use this line in /etc/crontab do NOT use sudo crontab -e. I thought this had the same effect but it doesn't.

0 0 * * 5,6   whitespace DISPLAY=:0.0 /usr/bin/vlc -I dummy --play-and-exit --vout null  http://www.youtube.com/watch?v=nr_CJL1YQRc 
Doctor Who
http://www.youtube.com/watch?v=2CYDgezeQas (recent)
http://www.youtube.com/watch?v=L0TEmJEjUSY (80's)

Links

A list of some links that where useful setting up this system: