84

Results

I want to be able to walk from one room to another and hear the same song playing. Like you do if you were listening to the radio in all rooms.

I want that effect but I want to listen to my own music, can this be done?

Materials

  • Ubuntu laptop.
  • Mac computer.

First alternative

Alvar
  • 17,058

8 Answers8

50

Yes, with pulseaudio this can easily be done. You will need to install and run paprefs Install paprefs that makes your sound devices available over the network.

enter image description here

enter image description here

These settings allow both sound sources and sinks to be published over the network, ideally to another pulseaudio server.

In case you have your server setup without desktop manager you will need to install a sound system first (see this question). You can then edit /etc/pulse/default.pa uncommenting these lines in the Network access section:

load-module module-esound-protocol-tcp
load-module module-native-protocol-tcp
load-module module-zeroconf-publish

If you want to use RTP sender uncomment these lines the RTP sender module section:

load-module module-null-sink sink_name=rtp format=s16be channels=2 rate=44100 description="RTP Multicast Sink"
load-module module-rtp-send source=rtp.monitor

The pulseaudio server needs to be started as a daemon with pulseaudio -D in case it's not yet running. For optimizing sound qualitity settings in the /etc/pulse/daemon.conf may be adapted to personal needs.

An alternative method to stream audio in your network would be to setup an Icecast Server (see this question).

Takkat
  • 142,284
  • 16
    In case of a headless client (say, a Pi with speakers on my kitchen cupboards) it would be useful to know how to set this up completely via config files and/or shell commands. – Raphael Apr 10 '14 at 10:08
  • This guide is generic enough to follow it on Ubuntu CLI. https://wiki.archlinux.org/index.php/PulseAudio/Examples#PulseAudio_over_network – goetz Oct 15 '18 at 17:29
  • if you go headless you gonna need dbus-x11 as this fellow says: https://manurevah.com/blah/en/p/PulseAudio-Sound-over-the-network – greengold Mar 23 '20 at 20:06
12

I didnt have to do anything out of the ordinary. I have twin netbooks both with PulseAudio and fairly no name hardware from intel. How I set it up went a little something like this.

run paprefs on both your server and client. On the server, make sure you have have the multicast settings enabled, and the server bits checked. like so enter image description here

and the multicast bit enter image description here

On the client, enable the bit about finding network enabled devices enter image description here and set your output device to the virtual network device via pavucontrol enter image description here

viola you should have some magic now

lazyPower
  • 5,371
  • 2
    Except that this has nothing to do with RTP. – kirelagin Oct 24 '14 at 18:12
  • 1
    Thanks for this great tutorial. I checked all the boxes, except that I can’t "set my output device to the virtual network device via pavucontrol". As I understand it, this is done via the bit where in your screenshot there is written "Internal Audio Analog Stereo on charmes@nano". But on my system, there is no such button at all. What am I doing wrong? – user69748 May 27 '16 at 16:17
  • I haven't checked these instructions since 2011, so its entirely likely the pulse audio daemon settings have changed. – lazyPower May 27 '16 at 17:18
  • What I now have (after rebooting) is a seperate channel called "pulseaudio" which seems to be routed to my client. However, there is no audio flowing through it. And my Rhythmbox channel still has no mention of "user@client". – user69748 May 27 '16 at 17:28
11

Your best option is called Music Player Daemon (mpd).

https://secure.wikimedia.org/wikipedia/en/wiki/Music_Player_Daemon

It is a client server application. You store your music on the server, then connect with your clients (lots of people can do it at once) and control the server.

It is already in ubuntu, just apt-get install mpd

And also some good documentation: https://wiki.archlinux.org/index.php/Mpd

MPD can stream music, so you can have lots of clients (or speakers if you so wish to call them) to play the music.

But don't really expect any good quality. Streaming spoils sound badly (no matter if you use mpd or pulseaudio). It's a much better idea to connect real speakers to the server and use the laptops only to control it.

Alvar
  • 17,058
loxs
  • 495
  • 2
    Well my house is too big to use wires, that's why I want to stream the sound. – Alvar Feb 26 '11 at 18:29
  • You can stream, dont worry about quality, it wont matter much, Given your wireless connection is strong enough – Rahul Prasad Jun 17 '11 at 06:38
  • How does streaming spoil sound quality? WiFi is a digital transfer medium. Does MPD do lossless compression? I don't think that is needed for today's WiFi networks. – nvd Jun 02 '17 at 18:20
  • Wow, such an old answer. I don't even remember any more, as I haven't used MPD since around that time. – loxs Jun 04 '17 at 06:46
1

To add to lazyPower's answer I' would like to comment that the "pulseaudio server" is where the audio devices are located (in my case it's the bluetooth headphones connected to laptop) and the "pulseaudio client" is where the audio is played to the network selecting the audio sink device. I spent a few hours before realize that.

Jaime
  • 36
1

With this solution you can stream your system audio whereever you want..
the key here is the ALSA loopback capabilities. so first you need to enable loopback device in ALSA, which will appear in the PulseAudio Volume Control as an input device (and an output device as well).

sudo modprobe snd_aloop

this device then can be added to an mpd server:

mpc add alsa://hw:1,1

where hw:1,1 is the loopback input device can be listed with the command aplay -l

then you need to configure a http output plugin for the mpd. the following example would look like in /etc/mpd.conf

 audio_output {
    type            "httpd"
    name            "My HTTP Stream"
    encoder         "vorbis"          # optional, vorbis or lame
    port            "8000"
    bind_to_address "192.168.1.38"               # optional, IPv4 or IPv6
    quality         "5.0"                   # do not define if bitrate is d$
#   bitrate         "128"                   # do not define if quality is d$
    format          "44100:16:1"
    max_clients     "0"                     # optional 0=no limit
 }  

that is it. Select the looback device for your audio source in Volume Control Playback tab.
Finally, you can use VLC or any other stream renderer at the destination point using the httpd url address: http://192.168.1.38:8000
This answer is also available here

laplasz
  • 131
  • 2
  • 3
  • 11
0

I'm not sure if something like this can be achieved with DLNA/UPnP since I'm not familiar with it myself, but throwing some links here in case it helps:

Though a quick search result would suggest that it's not possible to sync...

0

There is no good solution(yet). There is AVB but its support for 802.11 is limited to time synchronization.

themihai
  • 101
-2

If you want to stream to an Android phone, you can use Foobar2000 on the server and BubbleUPnP (payware) on the client.

  1. get Wine
  2. get foobar_v1.2.5.exe
  3. $ wine foobar2000_v1.2.5.exe
  4. next, next, next... :)
  5. get foo_upnp
  6. extract in the components folder of foobar2000 (which probably is in ~/.wine/drive_c/Program Files/)
  7. launch foobar2000
  8. go to Library→Configure→Playback→Output→Device and select "Null output"
  9. make sure ufw is not blocking the relevant traffic
  10. in BubbleUPnP:
    1. go to Devices→Libraries and select the foobar2000 server
    2. in "Library", select "Playback Stream Capture"

The approach has the advantage that if you pause on the Android, it will accummulate a buffer (since the server is still sending).

Tested on Ubuntu (Wine version 1.5.28-0ubuntu1~ppa1) and Windows.