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 :) 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.
* 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.
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
/home/botmaster/music/
and every bot can acces this directory * The port for MPD is always
770<botid>
, for example 7701 for bot 1 * Every bot has one directory for the configuration files, the scheme is
/home/botmaster/mpd<botid>/
, for example
/home/botmaster/mpd1/
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
/home/botmaster/mpd1/mpd.fifo
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 │ ├── start-all-mpd.sh │ └── start-all-mumble-ruby-bots.sh ├── user_certificates │ └── bot1_test_cert […] </source>
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
/var/lib/mpd/tag_cache
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
/etc/default/mpd
as root or via sudo and change 'START_MPD
' to 'false
'. On the next system start it will not be started any more.
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 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
Create the directories for bot 1
mkdir -p /home/botmaster/mpd1/playlists
Download the configuration for bot 1 and save it: <source lang=„bash“>wget https://github.com/Natenom/mumble-ruby-related/raw/master/configs/mpd.conf -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 https://github.com/Natenom/mumble-ruby-related/raw/master/configs/mpd.conf.
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
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 https://github.com/Natenom/mumble-ruby-related/raw/master/scripts/mumble-ruby-mpd-bot.rb -O /home/botmaster/scripts/mumble-ruby-mpd-bot.rb</source>
You can view the script [https://github.com/Natenom/mumble-ruby-related/raw/master/scripts/mumble-ruby-mpd-bot.rb here]. This is a changed version of [https://github.com/SuperTux88/mumble-bots SuperTux's bots] which can use parameters.
'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 mumble.natenom.com 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.
Add all your MPD instances to the following file in order to start them…
Download the script and save it: <source lang=„bash“>wget https://github.com/Natenom/mumble-ruby-related/raw/master/scripts/start-all-mpd.sh -O /home/botmaster/scripts/start-all-mpd.sh</source>
Make it executable:
chmod u+x /home/botmaster/scripts/start-all-mpd.sh
The following Bash script is used to start all Mumble-Ruby bots.
Download the script and save it: <source lang=„bash“>wget https://github.com/Natenom/mumble-ruby-related/raw/master/scripts/start-all-mumble-ruby-bots.sh -O /home/botmaster/scripts/start-all-mumble-ruby-bots.sh</source>
Make it executable:
chmod u+x /home/botmaster/scripts/start-all-mumble-ruby-bots.sh
You can view the script [https://github.com/Natenom/mumble-ruby-related/raw/master/scripts/start-all-mumble-ruby-bots.sh here].
Without modification the scripts starts only bot 1, for every additional bot modify the script.
Now it is time to test your bots, start both scripts:
/home/botmaster/scripts/start-all-mpd.sh
/home/botmaster/scripts/start-all-mumble-ruby-bots.sh
Now there should be a new bot on your Mumble server playing the music from the web radio [http://theradio.cc/ TheRadio.cc].
Add the following lines to
/etc/rc.local
before the exit…
line to start your bot when your system starts:
su - botmaster -c "/home/botmaster/scripts/start-all-mpd.sh" & su - botmaster -c "/home/botmaster/scripts/start-all-mumble-ruby-bots.sh" &
* https://github.com/perrym5/mumble-ruby/issues/2
Change
context = OpenSSL::SSL::SSLContext.new
to
context = OpenSSL::SSL::SSLContext.new(:TLSv1)
<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:
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