Natenoms Wiki

Weil Teilen Spaß macht :)

User Tools

Site Tools


Translations of this page:


Lizenz dieses Wikis
Über dieses Wiki
Feed des Wikis

Was gerade in meinem Blog geschieht:


Mumble-Ruby music bot with MPD

This method is outdated, please use Mumble-Ruby-Pluginbot.

With this howto one can create one or several, independent Mumble audio bots based on Mumble-Ruby which send(s) music to a Mumble server.

type=warning While this bot is pretty stable it is not developed anymore. Please consider to use Mumble-Ruby-Pluginbot instead which is actively developed. box_end


For every bot there runs an instance of MPD and sends the music through a named pipe. Also there is one Mumble-Ruby bot, which sends the music to the server.

MPD can play music from a playlist or even forward internet radio stations.

toggle = left |title = Why MPD and not, for example, mplayer? |titlestyle = background:palegreen; fixme Habe auch mit mplayer experimentiert, was mit entsprechenden Einstellunen auch funktioniert; z. B.

mplayer -ao pcm:file=/tmp/play.fifo -af resample=48000,channels=1 http://streamadresse.tld.

Doch einzelne Stücke lassen sich damit nicht abspielen, weil sich anscheinend mumble-ruby nur solange Musik holt, wie auch aktiv in die Pipe geschrieben wird; jedoch haut mplayer das so schnell wie möglich dort hinein und ist bei einem 2 Minuten Lied nach 10 Sekunden fertig. Nach dieser Zeit stoppt auch die Übertragung von mumble-ruby. Habe zu wenig Wissen um das fachlich zu erklären/verstehen.

Ausserdem beginnt mumble-ruby erst mit der Übertragung, wenn auch Daten anliegen, d. h. man muss mplayer und den Bot jedes Mal neu anweisen, etwas zu senden/lesen.

MPD hat hier den Vorteil, dass es wohl auch “Stille” sendet, also immer etwas in der Pipe ist, man muss beides also nur einmalig starten und kann zwischendrin beliebig umschalten.

Wenn jemand weiss, wie man das mit mplayer oder einem anderen Programm besser machen kann, so möge er sich bitte melden :) — Natenom 2012/07/11 16:04 hidden_end

MPD can be controlled with mpc.

As an alternative one can use a web client like sammelsurium:software:audio:player:mpd:rompr|Rompr which has much more comfort than mpc.

Advantages of this solution compared to a solution with full Mumble clients

* No X server or fake X server needed like with mumble:audiobots:music_bot_mpd_mumble_jack|this solution * Less RAM usage * Less CPU usage because there is no PulseAudio or mumble:anleitungen:mumble-mit-jack|Jack server running * If MPD was killed it starts playing music after start at the position it stopped, even if it played a radio stream * Very easy to automate with scripts (works also with other solutions, but is more complicated there)


* If Ruby scripts are started in the background (with &), music is not running; so they must be started within a tmux session.

Environment for the bots

To be able to run several, independent bots every bot gets its own directory: * All bots run with the same user account named botmaster within the home directory of this user * The music is located in


and every bot can acces this directory * The port for MPD is always


, for example 7701 for bot 1 * Every bot has one directory for the configuration files, the scheme is


, for example


for bot 1 In this directory there is the configuration file mpd.conf and the named pipe (FiFo file), which must be set in the mpd.conf, is here, for example


for bot 1


This will be the structure when the howto is completed: <source lang=“text”> /home/botmaster/ ├── mpd1 │ ├── playlists │ ├── mpd1.log │ ├── mpd.conf │ ├── mpd.fifo │ ├── pid │ ├── state │ ├── sticker.sql │ └── tag_cache ├── mumble-ruby │ └── […] ├── music ├── scripts │ ├── mumble-ruby-mpd-bot.rb │ ├── │ └── ├── user_certificates │ └── bot1_test_cert […] </source>

Install dependencies

Install packages

On Debian the following packages must be installed as root or via sudo: <source lang=“bash”>apt-get install mpd mpc tmux</source>

The message about “no database


can be ignored. It will be created as soon as you start the server.

As we do not need the system wide MPD it can be disabled. To do this open the file


as root or via sudo and change 'START_MPD' to 'false'. On the next system start it will not be started any more.

Installation of Mumble-Ruby

Install needed Ruby libraries

Based on the previous step the following commands must be run: Login as botmaster (if you are not already logged in):

su - botmaster

Use RVM:

source ~/.rvm/scripts/rvm

Set ruby environment:

rvm use @bots

Now the needed Ruby libraries must be installed, so that Mumble-Ruby can control MPD:

rvm @bots do gem install ruby-mpd

toggle = left |title = Console output |titlestyle = background:palegreen; <source lang=“bash”> Fetching: ruby-mpd-0.3.1.gem (100%) Successfully installed ruby-mpd-0.3.1 Parsing documentation for ruby-mpd-0.3.1 Installing ri documentation for ruby-mpd-0.3.1 Done installing documentation for ruby-mpd after 1 seconds 1 gem installed</source> hidden_end

Create directories

Create a directory for the scripts:

mkdir /home/botmaster/scripts

Create a directory for the music:

mkdir /home/botmaster/music

Create a directory for the certificates

mkdir /home/botmaster/user_certificates
Setting up MPD - using the example of bot 1

Create directories

Create the directories for bot 1

mkdir -p /home/botmaster/mpd1/playlists
Configuration for MPD (bot 1)

Download the configuration for bot 1 and save it: <source lang=“bash”>wget -O /home/botmaster/mpd1/mpd.conf</source>

For bot 1 you don't need to change anything in this configuration file; for every additional bot you must substitude every occurence of 1 by 2, etc.

toggle = left |title = Explanation of the configuration file |titlestyle = background:palegreen; You can view the configuration file at

Instead of the default sample rate of 44100 this config uses 48000 which is the sample rate Mumble clients use. And we need a mono signal.

The mixer type is set to software so that the volume in MPD can be changed without the need of a real soundcard. hidden_end

Starting a bot with a ruby script (using the example of bot 1)

The following script is used to connect the bot to a Mumble servers and let it automatically play music from the MPD instance.

Download the script and save it: <source lang=“bash”>wget -O /home/botmaster/scripts/mumble-ruby-mpd-bot.rb</source>

You can view the script [ here]. This is a changed version of [ SuperTux's bots] which can use parameters.

To stop a bot press Ctrl + C.

'Syntax for the script': <source lang=“bash”>mumbleserver_host mumbleserver_port mumbleserver_username mumbleserver_userpassword mumbleserver_targetchannel quality_bitrate mpd_fifopath mpd_path mpd_host mpd_port</source>

'For bot 1': <source lang=“bash”>ruby /home/botmaster/scripts/mumble-ruby-mpd-bot.rb 64738 Bot1_Test ”“ “Sitzecke” 96000 /home/botmaster/mpd1/mpd.fifo localhost 7701</source>

For now this does not make sense as MPD is not yet running :)

type=warning If your target Mumble server has a limited bandwith (see mumble:benutzerhandbuch:murmur:servereinstellungen#a_bandwidth|bandwidth) you must not set a quality higher than the limit (+ the overhead) because Mumble-Ruby doesn't know anything about the limitation and sends more packets than allowed and after some time your bot starts to loose packets. box_end

'User certificates': For every started bot the Mumble-Ruby creates a new user certificates in the current working dir, named BOTNAME_cert. This directory can be used after a test.

Bash script to start all MPD instances

Add all your MPD instances to the following file in order to start them…

Download the script and save it: <source lang=“bash”>wget -O /home/botmaster/scripts/</source>

Make it executable:

chmod u+x /home/botmaster/scripts/
Bash script to start all Mumble-Ruby bots

The following Bash script is used to start all Mumble-Ruby bots.

Download the script and save it: <source lang=“bash”>wget -O /home/botmaster/scripts/</source>

Make it executable:

chmod u+x /home/botmaster/scripts/

You can view the script [ here].

Without modification the scripts starts only bot 1, for every additional bot modify the script.

Test it

Now it is time to test your bots, start both scripts:


Now there should be a new bot on your Mumble server playing the music from the web radio [].

Start everything automatically

Add the following lines to


before the exit… line to start your bot when your system starts:

su - botmaster -c "/home/botmaster/scripts/" &
su - botmaster -c "/home/botmaster/scripts/" &
Known problems

SSL error



context =


context =

Stream termination

<source lang=“bash”> #!/bin/bash for i in $(seq 1 9); do mpc -p 770${i} play; done </source>

Add the following line to your crontab:

  • /10 * * * * ./

Keine Sorge, der Stream wird nicht neu gestartet, wenn man play ausführt, während der MPD sendet.

Mumble-Ruby bots Mumble audio bots MPD Ruby Mumble audio bot

en/mumble/audiobots/musikbot_mit_mumble-ruby_mpd.txt · Last modified: 2017/03/15 00:53 by Natenom