36

My problem is quite simple but I have been unable to find a satisfying solution.

Basically, I want my Raspberry Pi to be connected to my stereo and then play any audio output from my computer via wifi to the PI.

Is there any way to do this easily, without having to use special players? I.e. Is there anyway for the PC to just recognise the Pi as "speakers"?'

I would like to hear every sound on my PC on the stereo, ie. Gaming, music, system sounds, notifications, youtube videos etc.

Thanks very much!

23

If you are running Linux on your PC then this is perfectly doable, as long as you install and properly configure PulseAudio on both, your Raspberry Pi and your Linux PC.

If your PC is running Windows... Skip to the end of the post (which I have just updated).

Another option would be to use PulseAudio as an AirPlay receiver/client, but as far as I know, this is not possible.

But, if you are using Linux, then read on:

Note #1: PulseAudio over WiFi will work flawlessly on some routers but will fail on others.

Note #2: The following instructions are from a conversation several Raspberry Pi users (including myself) had on this very topic.

1) Install PulseAudio on your Raspberry Pi

sudo apt-get install pulseaudio pulseaudio-module-zeroconf avahi-daemon

2) Make sure PulseAudio starts automatically:

sudo nano /etc/default/pulseaudio

Look for the PULSEAUDIO_SYSTEM_START entry and change it to 1 so that looks like PULSEAUDIO_SYSTEM_START=1

3) Configure PulseAudio to work over the network:

sudo nano /etc/pulse/system.pa

Add the following lines:

load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;192.168.1.0/24

load-module module-zeroconf-publish

4) Reboot your Raspberry Pi:

sudo reboot

5) Now, on your Linux PC, install paprefs. If your Linux distro is based on Debian (such as Ubuntu, Mint, etc...) you can use this command:

sudo apt-get install paprefs

6) Run paprefs and under Network Access enable Make discoverable PulseAudio network sound devices available locally

7) Under Network Server enable Enable network access to local sound devices and tick both options (This is probably not necessary, unless you also want to use your Linux box as a server/sink)

8) Under Multicas/RTP enable both options

9) Check your available output devices (use your Linux distro Audio/Mixer Application). Your Raspberry Pi will (should) appear listed; select it and everything that's played on your Linux box will be redirected to the Raspberry Pi.

If your Raspberry Pi is still unavailable, try restarting your Linux PC.


UPDATE: Sending all audio from Windows to the Raspberry Pi

You will still need to follow the previous instructions to install and configure PulseAudio on your Raspberry Pi.

Now, this is what you will need to do for Windows:

1) Download the latest version of LineInCode

2) Unzip the downloaded file

2) Download PuTTY's Plink and place the plink.exe file in the same folder where you extracted LineInCode

3) Open Notepad and paste the following code:

linco.exe -B 16 -C 2 -R 44100 | plink 192.168.1.104 -l pi -pw raspberry "cat - | pacat --server 127.0.0.1 --playback"

Of course, change the IP address (192.168.1.104), user name (pi) and password (raspberry) to match your setup.

4) Save the file as audio2rpi.bat in the same folder where you extracted LineInCode

Now, whenever you want to stream your Windows' PC audio to your Raspberry Pi simply double click on the audio2rpi.bat file.


Credit for these instructions: http://ubuntuforums.org/showthread.php?t=1121603

  • Thanks- I shall give that a go! can I use pulseaudio to stream from a smartphone too? Thanks – Jerome Nov 16 '13 at 10:56
  • @Jerome That should be another question you ask on this website. – syb0rg Nov 16 '13 at 16:52
  • What OS are you running on your Pi? I am running a fresh install of Raspbmc and following these instructions appears to have bricked the device. Good thing a reformat is so easy... – gillonba Nov 25 '13 at 4:58
  • I have tried these instructions on several Raspbian releases. – xfx Nov 26 '13 at 16:22
  • Interested to know what IP address we're entering in the default config tcp module loading. I'm experiencing slightly glitchy playback over wireless but flawless over wired, interesting as nethogs reports only 13 KB/s used. – M1ke Jan 22 '14 at 0:48
4

I wrote a little blog entry about how I got this working with PulseAudio on the PC and Raspbmc on the Raspberry Pi - using DLNA/UPnP streaming. It's here: http://westmarch.sjsoft.com/2014/04/streaming-audio-linux-to-raspbmc/. Hope that helps. There is a little lag while XBMC buffers - so this probably won't be great for gaming or anything, but it works nicely for music.

It's quite a long set of instructions - hence the link here, but here's a summary of the option that worked for me, using DLNA/UPnP:

  • apt-get install rygel
  • Open PulseAudio Preferences and under Network Server tick Make local sound devices available as DLNA/UPnP Media Server and Create separate audio device for DLNA/UPnP streaming
  • Edit Rygel's config in /etc/rygel.conf or $HOME/.config/rygel.conf, and configure it to publish using GstLaunch (see config below)
  • Go to your XBMC File Manager, browse for a new source, select UPnP Devices, and you should see Gst Launch as an option
  • Then you should be able to tell XBMC to play audio from that stream

Here's the config for Rygel to use GstLaunch:

[GstLaunch]
enabled=true
launch-items=mypulseaudiosink
mypulseaudiosink-title=Audio on @HOSTNAME@
mypulseaudiosink-mime=audio/flac
mypulseaudiosink-launch=pulsesrc device=upnp.monitor ! flacenc
  • Could you include a simplified set of instructions from your blog post in case something happens to it in the future? – Fred Apr 14 '14 at 17:21
4

Wanted to do this myself from Windows7 -> RaspberryPi (OpenElec) and stumbled over your question. After quite some research I still did not find a satisfying solution for OpenElec but had enough info to come up with one that is very simple and really works with high quality and only about ~1sec delay!

You need:

  1. VLC Media Player (I used v2.1.3 Rincewind on my Win7 x64)
  2. A soundcard that provides a "Stereo Mix" recording device (I was fortunate enough to have one on-board)
  3. A Raspberry Pi (I use OpenElec 4.0.5, although it should work for XBMC in general)

Note: If you do not have a soundcard that supports this you could try to use VAC (http://www.virtualaudiocable.net/), although I am tellin' you it did not work properly for me, poor audio quality and buffer problems all the way...but maybe it's just me.

Step 1)

Create a batch file which starts a VLC http streaming service in background and captures audio from the "Stereo Mix" recording device:

@echo off

set vlc="C:\Program Files (x86)\VideoLAN\VLC\vlc.exe"
start "" %vlc% --qt-start-minimized dshow:// :dshow-vdev=none :dshow-adev="Stereo Mix (Realtek High Defini" :live-caching=10 :sout=#transcode{vcodec=none,acodec=vorb,ab=500,channels=2,samplerate=44100}:http{dst=:8080/audiostream.ogg} :sout-keep

Notes:

  1. You might have to change the recording device if yours has a different name, I used Audacity (http://audacity.sourceforge.net/) to check the names of my capture devices since I already had it installed
  2. Yes, the audio bitrate is very high (maximum for Vorbis), but the higher the bitrate the quicker the buffer is filled and hence the shorter the delay :-) (you cannot change the buffer size explicity for music on XBMC, I use 5MB buffer on mine in general)
  3. I tried FLAC, MP3 and even WAV and apart from the fact that only MP3 and Vorbis worked at all with my Pi, I had the quickest loading time on the Pi (basically instantly) and the least delay with Vorbis

Step 2)

Navigate to

\\rapsberrypi\Userdata\playlists\music

and create a .strm file with a name of your choice there (I called mine VLC.strm) which contains the plain link to your VLC stream: (change IP to IP of your PC :p)

http://192.168.0.1:8080/audiostream.ogg

Step 3)

You can now either set the audio device which is captured by "Stereo Mix" to default in the windows sound settings or open a player like VLC and manually use the non-default device to play music on your RaspberryPi:

Open your VLC (in addition to the one minimized in your tray which is streaming your "Stereo Mix") and perform the following steps:

  1. Tools -> Preferences
  2. Audio
  3. Output module: "WaveOut audio output"
  4. Device: - your (analog) device which is captured by the "Stereo Mix" recording device-
  5. Save
  6. Restart VLC
  7. Play Music

Step 4)

On your RaspberryPi:

  1. In XBMC navigate to Music -> Playlists
  2. Select VLC.strm (or whatever you called it)
  3. ENJOY MUSIC!

Troubleshooting

If you have troubles getting your "Stereo Mix" to work or capture, play around in Windows first by e.g. recording it with Audacity and trying some forum suggestions like:

this one:

http://www.howtogeek.com/howto/39532/how-to-enable-stereo-mix-in-windows-7-to-record-audio/

or this one:

http://www.sevenforums.com/sound-audio/104497-stereo-mix-enabled-but-no-sound.html

Right, enough typing for today, hope this was helpful to someone!

BR, Deads

3

The "LineInCode"-Solution described here works - but the sound is terrible over wifi. The VLC-Solution provided above works too - but it need a lot of clicking. I combined both in a batch-file which would start VLC as a streamer on my PC and mpg123 as a "listner" on the PI. It works like a charm for me. You need to have Plik in the same folder (we use it as ssh-client). I use this script from today on to listen to mp3s on my laptop, while the soundoutput is the pi:

            REM This is fischteich's start_sound.bat v 0.3
            @echo off

            set vlc="C:\Program Files (x86)\VideoLAN\VLC\vlc.exe"
            set ssh-login=YOURLOGIN
            set ssh-pw=YOURPW
            set this-machine-ip=192.168.XXX.XXX
            set pi-ip=192.168.XXX.XXX
            set use-port=5001

            set start-string= --sout-keep --sout=#transcode{vcodec=none,acodec=mp3,ab=192,channels=2,samplerate=44100}:http{mux=mp3,dst=:%use-port%/}

            REM Start VLC ready for files to play
            @start "vlc" %vlc% %start-string%
            REM Start playback via mpg123 on the Pi!
            plink %pi-ip% -l %ssh-login% -pw %ssh-pw% "mpg123 http://%this-machine-ip%:%use-port%"
1

One way to achieve this would be to install the Volumio OS on the Raspberry PI (https://volumio.org) follow instructions given there. This distribution includes an ShairPort receiver which allows Apple devices to stream audio to it. Alternatively I guess you could just install Shairport on the distribution of your choice.

On your Windows PC install tuneblade (http://tuneblade.com) the free version of which allows you to stream your computer's audio to the ShairPort on your raspberry pi. It also works well with vlc to eliminate the audio delay when viewing videos etc.

This works for me — I hope it might work for you too.

  • Welcome to Raspberry Pi Stack Exchange! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – RPiAwesomeness Feb 25 '14 at 16:37
  • Tuneblade also works with Pi MusicBox – input Nov 17 '14 at 23:41
0

As far as I know there is no solution(yet). There is a standard/technology named AVB but its support planned for 802.11 is limited to time synchronization.

-1

Have you tried simple bluetooth audio streaming using an A2DP adapter connected to your stereo? Using a Raspberry Pi to do that seems overkill, although I will admit to building an A2DP bluetooth audio streaming device with a Raspberry Pi and a cheap USB bluetooth adapter.

  • It's great that you've built a Raspi that can stream A2DP, but your answer doesn't help me to the same, so this answer is not an answer. – Mark Booth Aug 23 '15 at 0:39
  • No pi neeeded. Pair Your PC with a Bluetooth receiver, and send soound straight from your PC to your sterol. The Bluetooth receiver should show up asa sound output on your pc. – Christopher Biggs Apr 11 '17 at 20:20

protected by Ghanima Feb 20 '17 at 7:13

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.