dheijl / swyh-rs

Stream What You Hear written in rust, inspired by SWYH.
MIT License
367 stars 15 forks source link

Streams garbled audio from Logitech PRO X Wireless Headset source #56

Open craftycorvid opened 2 years ago

craftycorvid commented 2 years ago

I'm running into an issue streaming when the Audio Source is my Logitech Pro X wireless headset. The audio coming through on my external speakers is garbled noise. Changing the audio source makes streaming work just fine.

The log isn't showing anything unusual, but let me know if there's anything else I can provide:

Configuration { server_port: Some(5901), auto_resume: false, sound_source: "Speakers (Logitech PRO X Wireless Gaming Headset)", log_level: Debug, ssdp_interval_mins: 1.0, auto_reconnect: false, disable_chunked: false, use_wave_format: true, bits_per_sample: Some(16), monitor_rms: false, last_renderer: "Sonos Beam Office Beam - Sonos Beam Media Renderer", last_network: "192.168.1.5", config_dir: "C:\\Users\\Corvid\\.swyh-rs" }
Setup audio sources
Now running at ABOVE_NORMAL_PRIORITY_CLASS
Capturing audio from: Speakers (Logitech PRO X Wireless Gaming Headset)
Default audio SupportedStreamConfig { channels: 8, sample_rate: SampleRate(48000), buffer_size: Unknown, sample_format: F32 }
Discover networks
Starting SSDP discovery
The streaming server is listening on http://192.168.1.5:5901/stream/swyh.wav
Sample rate: 48000, sample format: audio/L16 (PCM)
AV Stop playing on Bedroom Move - Sonos Move Media Renderer host=192.168.1.234 port=1400
AV Start playing on Bedroom Move - Sonos Move Media Renderer host=192.168.1.234 port=1400 from 192.168.1.5 using AvTransport Play
Received request /stream/swyh.wav from 192.168.1.234:48546
Streaming audio/wave;codec=1 (WAV), input sample format F32, channels=2, rate=48000, disable chunked=false to 192.168.1.234:48546
AV Stop playing on Bedroom Move - Sonos Move Media Renderer host=192.168.1.234 port=1400
Streaming to 192.168.1.234:48546 has ended
AV Stop playing on Office Beam - Sonos Beam Media Renderer host=192.168.1.243 port=1400
AV Start playing on Office Beam - Sonos Beam Media Renderer host=192.168.1.243 port=1400 from 192.168.1.5 using AvTransport Play
Received request /stream/swyh.wav from 192.168.1.243:58272
Streaming audio/wave;codec=1 (WAV), input sample format F32, channels=2, rate=48000, disable chunked=false to 192.168.1.243:58272
The wave_reader is now receiving samples

As an additional data point, I am able to stream from the Logitech Pro X audio source using the original Stream What You Hear with no issues.

dheijl commented 2 years ago

I suppose the problem is the number of channels (8) of the logitech audio source: swyh-rs can only handle 2 channels (stereo). That's why I advise the use of vb-audio hifi cable as the audio source on Windows: bit perfect stereo guaranteed if properly set up. If you capture from hardware nothing is guaranteed, not even the signal quality. Swyh (original) uses a sophisticated .net library (Naudio) for the audio and a buggy (memory leaks, unmaintained) Intel .net library for the upnp/dlna part. So Swyh (original) can handle audio transformation using naudio and can transcode to mp3 too if you wish.

Emstar commented 2 years ago

I suppose the problem is the number of channels (8) of the logitech audio source: swyh-rs can only handle 2 channels (stereo).

Ah this may explain my problem too. I just found this project when I went to report a bug in the original SWYH... Fired up this app and while it detected my devices and began streaming easily, the sound quality is mangled.

My Windows PC is plugged in to an HDMI receiver that then goes into the TV and speakers, so my Windows audio environment is not stereo.

Capturing audio from: SONY AVAMP (Intel(R) Display Audio)
Default audio SupportedStreamConfig { channels: 6, sample_rate: SampleRate(48000), buffer_size: Unknown, sample_format: F32 }

I installed vb-audio hifi cable and sure enough, that does the trick, but there's one substantial problem with this method... You need to select the virtual cable driver as the Windows sound output. That means that the Windows PC is no longer playing sound to its own speakers. For my application, that's a bust -- I use SWYH to add a speaker on my patio when the PC is playing music inside.

Hopefully I can find another virtual sound device that will leave the system 6-channel sound alone and add a stereo device that can drive swyh-rs.

Anyway, this is a cool project even if it didn't do exactly what I was looking for!

dheijl commented 2 years ago

You need to select the virtual cable driver as the Windows sound output.

That is not necessary. You can use the Windows soundmixer app to redirect any application to any sound output. In swyh-rs you select vb audio as the sound source, and in the soundmixer you let the app that plays the sound use vb audio as its output.