Jun 222013
 

My friends had often asked about adding music to mumble, but all guides that I could find used a virtual sound card under Windows. I wanted a solution that runs on my Linux server, so that my friends can all upload music and selecting the music is open to everyone.

The gist: music player daemon connected via pulseaudio to a regular mumble running in a VNC session.

This guide is for Debian, but other distributions should work similarly.

Ingredients: Pulseaudio

apt-get install pulseaudio pulseaudio-utils pavucontrol

Ingredients: VNC Server

I didn’t have any X on my server, so here are some basics to get a working vnc session, in which we can run mumble:

apt-get install tightvncserver jwm xfonts-base rxvt-unicode-256color

Ingredients: Mumble, mpd

Of course we need a mumble client and mpd:

apt-get install mumble mpd

The key is to start a pulseaudio session for the mpd user on a special sink, then open up a vnc server for the same user and in it connect mumble to that sink. The specially nice part is that you now have all of mpd’s clients as possible front ends to this setup.

PulseAudio

Ok, first let’s create the pulseaudio setup: First edit /etc/pulse/default.pa and comment out the suspend-on-idle module:

# load-module module-suspend-on-idle

Since there isn’t an instance of pulseaudio yet, there is no need to restart anything.

Then edit /etc/mpd.conf, add this section and comment out any other audio_output sections:

audio_output {
        type            "pulse"
        name            "pulse mumble"
        #sink            "mpdmumble"
}

Now restart mpd:

/etc/init.d/mpd restart

, you should now see an instance of pulseaudio for the mpd user:

$ ps aux | grep pulse | grep mpd
mpd       4476  4.5  0.2 372704  5200 ?        Sl   Jun19 190:24 /usr/bin/pulseaudio --start --log-target=syslog

My server doesn’t have any audio hardware (a VM), so I create two sinks: One for mumble as an output device, and an extra sink where the music will flow from the mpd output to the mumble input. We don’t care about the mumble output, but it needs to go somewhere.

$ su -s /bin/bash mpd
$ pactl load-module module-null-sink sink_name=mumble_null sink_properties=device.description="mumble_null_sink"
$ pactl load-module module-null-sink sink_name=mpdmumble sink_properties=device.description="mpdmumble_sink"
$ exit

Now that the sink is available, edit /etc/mpd.conf again, remove the comment from the sink, and restart mpd another time to use it.

Connect mumble

$ vncserver -name mpdmumble -depth 16 -geometry 1024x768

And connect from my Linux desktop:

$ vncviewer -via SERVER :1

Open up two shells, run

$ mumble

in one, and

$ pavucontrol

in the other. In mumble you can just abort the audio wizard and then configure it by hand. Make sure that the Advanced checkbox on the bottom left is checked. The important settings are:

  • Audio Input Select pulseaudio. I wasn’t able to select the sink here, but that’s fine, we can do that using the pulseaudio tools later. Other useful settings: Echo: Disabled, Transmit: Voice Activity, select the sliders so that you have a very small red section, followed by a small yellow section, and finally a large green. This makes mumble transmit when there is any input, but be silence otherwise, so that mumble’s red mouth indicates whether the music is playing or not. Under Compression, move the quality slider all the way to the right to get decent sound quality. Under Audio Processing, move both sliders all the way to the left to disable as much processing as possible.
  • Audio Output Select pulseaudio and the mumble_null_sink.

In the pulseaudio Volume Control we can check that the sinks are set up correctly (if not, just click on the sink name and you can select the one mentioned here):

  • On the Playback tab there should be Music Player Daemon entry using the mpdmumble sink.
  • On the Recording tab the Mumble: Microphone should be using Monitor of mpdmumble. I had to move the volume control for the microphone down to 77%, otherwise there was a horrible clipping sound when playing the music.

Now just add some music to the mpd music directory, and install a mpd client to control the playback. I chose rompr, a web (PHP) client, put up a http-password and now any of my friends can play DJ.

Done, and enjoy the music!

P.S. I don’t have a nice start-up script which will automatically start mumble, so that is an exercise left for the reader.

Resources:

  • http://mpd.wikia.com/wiki/PulseAudio
  • http://askubuntu.com/questions/191203/12-04-sound-keeps-auto-muting-when-idle
  • http://askubuntu.com/questions/85007/pulseaudio-can-not-create-sink-with-specific-name-anymore
Jun 172008
 

Last updated: 2008-06-17

Trying to do play around with some static analysis? Here a review of software that helps to create an abstract syntax tree for C:

  • styx, a scanner and parser software that says it is easier to use than lex/yacc (with some small limitations). It is supposed to automatically generate an abstract syntax tree.
    Problem: I was unable to find any grammars for it except the ones on the download page (they do have a grammar for php there), and the documentation about writing one is not really complete.
  • elsa/elkhound, generates an abstract syntax tree for C++, but lacks documentation for how to write a context sensitive analysis that can process the tree. It is complicated without documentation, because meta programming is used for the ast.
  • olmar is an ocaml wrapper for elsa and adds a nice program to generate graphs of the AST. This would be my option if I had been able to use ocaml.
  • Open C++ core, the core of the Open C++ project, which introduces aspect oriented / meta object programming to C++. Almost no documentation exists though.
  • oink is a Collaboration of C++ Static Analysis Tools, which sounds like a nice middle-ware (it uses elsa as a backend). It lists as one of its goals extensible for ease in adding backends, yet I could not find much information about how to actually do that.

elsa seems to be the standard tool for the task, but understanding its internals was too complicated for my small project, so I ended up printing the AST as XML and reading that back in from my program.