User avatar
Snoop05
Posts: 14
Joined: Mon Mar 30, 2015 8:45 pm

How to stream sound from Windows to Raspberry Pi?

Wed Aug 05, 2015 8:53 am

My onboard soundcard stopped working, and two discrete soundcards i have are incompatible.
However, i have my RPi 2 laying around, so i can use it as my soundcard
I want to stream all sound from Windows (not just music streaming)
RPi will be connected directly to my 2nd ethernet card
Ideal case will be if the software on Windows will create virtual audio device so it act as real soundcard.
Less latency is better

Any ideas? Im searching for such software for hours and nothing. (Damn PulseAudio not working on Windows)
Raspberry Pi 3, Raspberry Pi 2
32GB Samsung EVO Class 10 UHS-I
Arch Linux ARM, LibreELEC, RuneAudio

P4d0uch
Posts: 47
Joined: Sun Sep 16, 2012 5:01 pm

Re: How to stream sound from Windows to Raspberry Pi?

Sat Aug 08, 2015 7:09 pm

Hi I have the same problem. My notebook is working only with headphones.
I'm using Shairport and it is working well. The latency is around 1.5 - 2s over WiFi (Ethernet could be better), but if you are using VLC player you can set up audio synchronization to match up and then video plays without any problem.
Have a look here: http://drewlustro.com/hi-fi-audio-via-a ... pberry-pi/ And for the Windows side try TuneBlade - it is free to use with shairport.

akira4m
Posts: 1
Joined: Tue Aug 11, 2015 12:04 am

Re: How to stream sound from Windows to Raspberry Pi?

Tue Aug 11, 2015 12:17 am

For the virtual sound device, install VB-cable or HiFi cable http://vb-audio.pagesperso-orange.fr/Cable/ , and then configure TuneBlade to capture audio as mentioned here: http://tuneblade.com/support/Documentat ... aptureMode

Install ShairPort on the Pi, or just flash Volumio's image (https://volumio.org/) on the SD card. Volumio has shairport.

Only issue is the latency of about 1-2 seconds. There should be a way to reduce this latency by configuring ShairPort. You can offset the latency by pressing 'J' and 'K' keys while playing a video on VLC.

timdw
Posts: 1
Joined: Sun Mar 03, 2019 1:40 pm

Re: How to stream sound from Windows to Raspberry Pi?

Sun Mar 03, 2019 5:08 pm

I think I have a way to do this using GStreamer. Seeing as this thread is one of the top search results I thought I would post it here, hope that's OK! It's not thoroughly tested - I haven't used it for an extended period of time - but it seems ok so far. Comments are welcome! This is just the outline so any questions, please ask and I'll edit this post to include the answers.

The Pi had just had a fresh install of Raspbian Stretch, it's a Pi 1 Model B 256MB with a generic USB sound card.

On the Raspberry Pi
Install:

Code: Select all

sudo apt-get install gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer1.0-alsa gstreamer1.0-plugins-good
Start a server:

Code: Select all

gst-launch-1.0 -v udpsrc port=5555 caps='application/x-rtp, media=(string)audio, clock-rate=(int)48000, encoding-name=(string)L16, encoding-params=(string)2, channels=(int)2, payload=(int)96' ! rtpL16depay ! audioconvert ! queue ! autoaudiosink sync=true
Adjust sound level, get the mixer control name:

Code: Select all

pi@raspberrypi:~ $ amixer
Simple mixer control 'Speaker',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 30
  Mono:
  Front Left: Playback 30 [100%] [0.00dB] [on]
  Front Right: Playback 30 [100%] [0.00dB] [on]
Simple mixer control 'Mic',0
  Capabilities: pvolume pvolume-joined cvolume cvolume-joined pswitch pswitch-joined cswitch cswitch-joined
  Playback channels: Mono
  Capture channels: Mono
  Limits: Playback 0 - 14 Capture 0 - 30
  Mono: Playback 1 [7%] [-10.50dB] [off] Capture 26 [87%] [27.00dB] [on]
Simple mixer control 'Auto Gain Control',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [off]
Set volume to 100% - mixer name was Speaker from the previous amixer output.

Code: Select all

 amixer set Speaker 100%
For USB audio, if there's no sound output then:

Code: Select all

sudo nano /usr/share/alsa/alsa.conf
Change the following lines:

Code: Select all

defaults.ctl.card 1
defaults.pcm.card 1
On Windows
Install Gstreamer (currently https://gstreamer.freedesktop.org/data/pkg/windows/)
Create a PowerShell script SendAudio.ps1:

Code: Select all

$gstDir="C:\gstreamer\1.0\x86\bin"
$gstlaunch=Join-Path -Path $gstDir -ChildPath "gst-launch-1.0.exe"
$hostIP='<IP address of Pi>'
$port='5555'
$parms='-v wasapisrc loopback=true low-latency=true ! queue ! audioconvert ! rtpL16pay ! udpsink ' + "host=$hostIP port=$port"
$process=Start-Process -FilePath $gstlaunch -ArgumentList $parms -WorkingDirectory $gstDir -WindowStyle Minimized -PassThru
$process.PriorityClass="RealTime"
Start a PowerShell session. If necessary, change PowerShell execution policy:

Code: Select all

Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
Run the script:

Code: Select all

Cd <folder where you saved it>
.\SendAudio.ps1

Return to “Graphics, sound and multimedia”