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.
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