squisher

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
Mar 242013
 

I couldn’t find a good guide for running teamspeak3 inside of a chroot. And that’s the only way I’d be running it, given that it is a binary blob… This guide is for a Debian system, should probably work for Ubuntu, but it shouldn’t be hard to adjust to other distributions.

  1. Install jailkit. It’s not in Debian, but it provides a working packaging script that you just have to use to build the package yourself:
    # USE REGULAR USER
    apt-get install build-essential fakeroot
    # download jailkit, see the link above. Extract it.
    cd jailkit-2.15
    dpkg-buildpackage -uc -uc -rfakeroot
    sudo dpkg -i ../jailkit*.deb
    
  2. Configure the chroot, and install teamspeak 3 in it. Note that I’m assuming amd64 here.
    # AS ROOT
    mkdir -p /var/chroot/ts3
    cd /var/chroot/ts3
    
    cat << EOF >> start.sh
    #!/bin/bash
    exec ./ts3server_startscript.sh start
    EOF
    chmod +x start.sh
    
    tar xavf $TEAMSPEAKTARGZ # Replace with where you stored the teamspeak download
    adduser --system --home /var/chroot/ts3/./teamspeak3-server_linux-amd64 \
            --disabled-password --group --shell /start.sh ts3
    mkdir teamspeak3-server_linux-amd64/logs
    chown ts3:ts3 teamspeak3-server_linux-amd64 teamspeak3-server_linux-amd64/logs
    
    jk_jailuser -j $PWD ts3
    cat << EOF >> /etc/jailkit/jk_init.ini
    [ts3]
    devices = /dev/null, /dev/random, /dev/urandom, /dev/zero
    paths = /usr/lib/libstdc++.so.6, /etc/localtime
    users = root
    groups = root
    includesections = uidbasics, netbasics, basicshell
    EOF
    jk-init -v -j $PWD ts3
    
  3. Boot script:

    cat << 'EOF' >> /etc/init.d/teamspeak3
    #!/bin/bash
    ### BEGIN INIT INFO
    # Provides:          teamspeak3
    # Required-Start:    $local_fs $remote_fs $network $named
    # Required-Stop:     $local_fs $remote_fs $network $named
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # X-Interactive:     false
    # Short-Description: Start/stop teamspeak 3 server
    ### END INIT INFO
    
    shm=/var/chroot/ts3/dev/shm
    pidfile=/var/chroot/ts3/teamspeak3-server_linux-amd64/ts3server.pid
    
    case "$1" in
    	start)
    		mount -t tmpfs tmpfs $shm
    		su ts3
    		;;
    	stop)
    		echo -n "Stopping the TeamSpeak 3 server"
    		if ( kill -TERM $(cat $pidfile) 2> /dev/null ); then
    			c=1
    			while [ "$c" -le 300 ]; do
    				if ( kill -0 $(cat $pidfile) 2> /dev/null ); then
    					echo -n "."
    					sleep 1
    				else
    					break
    				fi
    				c=$((++c)) 
    			done
    		fi
    		if ( kill -0 $(cat $pidfile) 2> /dev/null ); then
    			echo "Server is not shutting down cleanly - killing"
    			kill -KILL $(cat $pidfile)
    		else
    			echo "done"
    		fi
    		rm $pidfile
    		umount $shm
    		;;
    	*)
    		echo "Usage: $0 {start|stop}"
    		;;
    esac
    EOF
    chmod +x /etc/init.d/teamspeak3
    insserv teamspeak3
    
  4. Recommended: Block outside access to server query, since it’s a telnet based protocol (unencrypted)
    iptables -A INPUT -p tcp ! -s 127.0.0.1 --dport 10011 -j REJECT
    

The point of this guide is to never run the server outside of the chroot. Also I noticed that if the environment wasn’t set up correctly, and the server ran but had strange error messages in the log and didn’t actually work, I had to delete the database file (ts3server.sqlite) and start from scratch.

That’s it, you’re ready to go. Let me know if I missed something.

Mar 112013
 

I recently started using the awesome window manager again. Running into some issues, I wanted to try out the git master version, but not replace my stable installation.

The recipe is:

  1. Build it for installation in $HOME and install it.
    cmake -DCMAKE_INSTALL_PREFIX:PATH=$HOME/opt/awesome
    make install
    
  2. Create a testing wrapper script awesome-xephyr and put it into $PATH:
    #!/bin/bash
    
    if [ -z "$AWESOME" ]; then
    AWESOME=awesome
    fi
    
    $AWESOME -k "$@" || exit 1
    
    Xephyr :1 -ac -br -noreset -screen 1152x720 &
    xephyr_pid=$!
    
    sleep 1
    
    DISPLAY=:1.0 $AWESOME "$@" &
    awesome_pid=$!
    
    echo "Press ENTER to kill Xephyr"
    read a
    kill $awesome_pid
    kill $xephyr_pid
    
  3. Run it
    #!/bin/bash
    
    # ;; means the default lua search path
    export AWESOME_PREFIX=$HOME/opt/awesome
    export RC=$HOME/.config/awesome/git.lua  # copied from .build.../awesomerc.lua and adjust the beautiful.init theme path
    
    LUA_PATH=";;$AWESOME_PREFIX/share/awesome/lib/?.lua;$AWESOME_PREFIX/share/awesome/lib/?/init.lua" \
    AWESOME=$AWESOME_PREFIX/bin/awesome \
    exec awesome-xephyr -c $RC
    

P.S. You can possibly tweak this to work without the make install directly from the .build directory.

Dec 142012
 

Working on refraction: This is the first attempt which just scattered the ray randomly when leaving the object (image uses 500 samples);

Ok this is as far as I got by the deadline… which is kind of a sad state of affairs. When leaving the object I am doing the same refraction equation again with no randomness involved but unfortunately it still looks very wrong (50 samples):

I will render a higher sample picture over night:

Dec 032012
 

Putting another sphere into the scene revealed that sometimes the reflections were wrong because a negative cos was calculated. The issue was that the change of basis was done incorrectly for transforming the samples. Now it looks sane:

 

But you can still see a strange highlight at the top of the bottom sphere. My reflectance just based on the cos term, using a real material property, like stainless steel, results in a normal looking bottom sphere (1000 samples):

Nov 262012
 

Reducing the size of the light source resulted in an even darker image since now fewer rays found their way into the light source. Adding a back wall behind the camera did not seem to help much.

Now using the cos density sampling, and increasing samples to 100 it gets almost worse:

 

 

Nov 212012
 

In the picture above I am visualizing the normals of each hit. It is using multisampling and purely diffuse material so that some rays get scattered inte space (the box is missing one side). Note that the back wall is missing — the rectangle had the points stored in incorrect order so that the normal was pointing out the opposite side. The fixed back wall can be seen below.

Now that I can scatter and have material properties, I can do actual path tracing. The image below uses essential lambertian surfaces, hence the absorption is relative to $cos(\phi)$ and it uses only diffuse scattering. I increased the number of samples from 20 to 50 which turns out to make the image darker since more more rays end up in space without hits.