Using BUTT (Broadcast Using This Tool) with Rhythmbox 3

I have been doing a lot of work and research to get the Pirates in Teepees Radio station working. I am putting this together in hopes it helps someone else get their radio going.

I am running Ubuntu Linux 14.04.1 Trusty Thar

I have been able to set up BUTT to work in two ways:

1. Broadcast from JackD ( see my other post on this )
2. Broadcast from Rhythmbox 3 / Pulseaudio ( keep reading )

I am assuming you already have an icecast server to connect to and a pulse compatible media player that is shuffling your songs.

Open up BUTT and configure it to connect to your Icecast server.

Set the Audio Device to “pulse”. If you are unable to change the Audio Device via the menu or doing so causes BUTT to crash, do the following:
– Configure everything in BUTT except for the Audio Device ( don’t even touch this menu )
– Click on “Save Settings”
– Quit BUTT
– Open .buttrc in your home directory
– In the [Audio] section change the line “device = 0” to “device = 1”
– Save file and relaunch BUTT, you should now be able to select “pulse”

Install the program “pavucontrol” (sudo apt-get install pavucontrol)

Launch Rhythmbox

Launch pavucontrol ( this will launch a window called “Volume Control” )

In the Recording tab of Volume Control you will see “ALSA plug-in [butt]: ALSA Capture from” Change the select box to capture from the device Rhythmbox is playing through.

You should now see the indicator lights in BUTT going with your Rhythmbox music.

You can stream the audio like this, but your stream will not be updated with your currently playing song metadata. You need to write the current track name to a file and point BUTT to that file in your stream tab.

I googled forever to find a solution to this. How do I find out what song is currently playing in Rhythmbox and write that name to a file? All the solutions I found were for old versions of Rhthmbox which talks differently to D-BUS than Rhythmbox3 does. After bouncing around a few forums with people looking for this and similar solutions, I was able to come up with a python script that monitors Rhythmbox and when the song changes updates .now_playing file in your home directory. Copy the code to /usr/local/bin/now_playing, chmod it to 755 ( both these will need to be done as root ) and run it:

now_playing&

Go back to the BUTT settings window, stream tab and set the “Update song from file” value to be ~/.now_playing

You should be good to go.

/usr/local/bin/now_playing

#!/usr/bin/python

import dbus
import dbus.mainloop.glib
import glib

# This gets called whenever Rhythmbox sends the playingUriChanged signal
def playing_song_changed (Player,two,three):
    global iface
    global track
    global home
    track2 = iface.Get(Player,"Metadata").get(dbus.String(u'xesam:artist'))[0] + " - "+ iface.Get(Player,"Metadata").get(dbus.String(u'xesam:title'))

    if track != track2:
        track = iface.Get(Player,"Metadata").get(dbus.String(u'xesam:artist'))[0] + " - "+ iface.Get(Player,"Metadata").get(dbus.String(u'xesam:title'))
        f = open( home + '/.now_playing', 'w' )
        f.write( track + '\n' )
        f.close()


dbus.mainloop.glib.DBusGMainLoop (set_as_default = True)

bus = dbus.SessionBus ()
from os.path import expanduser
home = expanduser("~")
player = bus.get_object ("org.mpris.MediaPlayer2.rhythmbox", "/org/mpris/MediaPlayer2")
iface = dbus.Interface (player, "org.freedesktop.DBus.Properties")

track = iface.Get("org.mpris.MediaPlayer2.Player","Metadata").get(dbus.String(u'xesam:artist'))[0] + " - "+ iface.Get("org.mpris.MediaPlayer2.Player","Metadata").get(dbus.Strin$
f = open( home + "/.now_playing", 'w' )
f.write( track + '\n' )
f.close()

iface.connect_to_signal ("PropertiesChanged", playing_song_changed)

# Run the GLib event loop to process DBus signals as they arrive
mainloop = glib.MainLoop ()
mainloop.run ()

7 thoughts on “Using BUTT (Broadcast Using This Tool) with Rhythmbox 3”

  1. Hey there, this is awesome and just what I’m looking for, but it doesn’t work with the latest version of Rhythmbox, and I can’t realistically figure out what would need to be changed to get it working again. Is there any possibility you would be able to update it or point me in the right direction so I can try to get it going?

    I want to use it to capture now playing data from rhythmbox for my music stream at romp.pw/music

    Thanks so much for any consideration or reply

  2. Looking quickly over the article, I would recommend reading up on pulse control…

    Read the manpages for pulseaudio as well as Rhythmbox..

    Ask yourself these questions? Does my current OS use pulse? Does it use DBUS? These are crucial components to make this work.

    Thanks for your interest 🙂

  3. I got this going with a fresh install of Ubuntu 20.4 and Rhythmbox, was pretty clear and also broadcast the song metadata with the latest version of BUTT. The one thing I found difficult is that I couldn’t monitor what was being played. When the pulse output is captured this way, it doesn’t send it to my speakers. Probably a minor tweak?

    1. It is definitely possible. You will need to use a null sink and a loopback for every device you want to be able to mix together. This article explains how to do that: https://askubuntu.com/questions/868817/collecting-and-mixing-sound-input-from-different-microphones

      In your case you will make 2 loopbacks.

      One you have that done go into pavucontrol recording tab and set one of the loopbacks to record from the microphone and the other to record from rhythmbox. Then set BUTT to record from the null sink.

Leave a Reply

Your email address will not be published. Required fields are marked *

RoboPirates: DENIED! * Time limit is exhausted. Please reload the CAPTCHA.