Category Archives: Linux Audio

Use Pulse Audio to Pipe Audio Streams Between Programs

Looking for a way to pipe audio from one program to another without using JACK? Pulse Audio, default sound system for Ubuntu can do this and it’s really not that hard.

1. Install pavucontrol

sudo apt install pavucontrol

2. Set up a null sink

pactl load-module module-null-sink sink_name=virtual-cable

3. Connect aps via the null sink

In this example I will use QSSTV to listen to the output of GQRX. You can use any programs you want.

Run Pulse Audio Volume Control (pavucontrol)

In the “output devices” tab, set the audio output for the program you want to monitor or record to Null Output.

In the “recording” tab, set the capture from for the “recording” program to Monitor of Null Output

And that’s about it! Enjoy!

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 ()