veldenb / plugin.program.moonlight-qt

A launcher and updater for running Moonlight-qt on LibreELEC.
GNU General Public License v3.0
86 stars 11 forks source link

Surround 7.1 channel mapping #37

Closed kurac338 closed 10 months ago

kurac338 commented 10 months ago

Hello, I see that this plugin has a configuration file asoundrc used for surround sound channel mapping.

Is this configuration tested and verified that it works as is? I am asking since I have an issue with 7.1 surround channel mapping, and was wondering if you can help me diagnose the issue.

Specifically, when I toggle Moonlight-QT GUI config to use 7.1 the sound is distorted and generally broken. I have also added a comment in this issue HERE to discuss and further steps, but I am not sure if the issue is on the Moonlight-QT side or due to this plugin's default asoundrc.

Maybe my configuration requires different channel indexes for asoundrc's ttable? I have newer had to alter ALSA configs, as OSMC (distro that I use) has worked out-of-the-box for 7.1, so the issue is present only when using Moonlight.

Any feedback would be appreciated.

veldenb commented 10 months ago

Hi,

I own a 5.1 system myself and don't have access to a 7.1 system. So the current 7.1 configuration is a well estimated guess and I have not been able to test it. The asoundrc file is needed on LibreELEC because the channels on the host-pc do not correspond with the correct speakers in Moonlight, so they need to be re-mapped. I'm note sure for OSMC.

You could try to alter the template file resources/template/asoundrc on OSMC to see if it makes a difference. Possibly altering the mappings or removing the whole 7.1 section fixes your problem.

kurac338 commented 10 months ago

Ok thanks for the info. Can you please tell me how you found the initial channel mappings for asoundrc? By trial and error or is there some debian package where I can query the current setup (from OSMC or Kodi)?

veldenb commented 10 months ago

Unfortunately by trail and error. I used the channel testing tool in Windows (this one) while streaming with Moonlight and checked if the channels matched my speaker setup. Every time altering the configuration, re-starting Moonlight and testing the channels again until all channels matched.

I tried finding a tool for testing this on LibreELEC but found none that matches the same behaviour as the channel usage while streaming. There might be better tools available for testing this on OSMC.

kurac338 commented 10 months ago

Ok thanks, I presumed that was the case. I will spend some time over the weekend to try and untangle this on 7.1 systems. If I get it working I will report back so we create an MR and close the issue 🤞

veldenb commented 10 months ago

That would be great, then I can update the template for a working default configuration for 7.1 as well.

kurac338 commented 10 months ago

Yeah... it seems like an issue several layers deeper than the plugin/addon. As of now I believe than your plugin's asoundrc is not the root cause.

Firstly Sunshine and Moonlight-QT started using "Steam streaming speakers" as the host PC's audio output interface recently. From what I see on the official steam page for "Steam streaming speakers", they officially only support up to 5.1 surround. However in Windows audio output configuration interface, a 7.1 option is available for it.

When you change the surround config dropdown menu item in Moonlight, you are actually manipulating the Steam streaming speakers's configuration dialog on the host PC, and are switching between: stereo, 5.1, 7.1. Obviously stereo and 5.1 work as expected, but 7.1 does not.

So it seems that the issue is in Moonlight-QT's handling of 7.1 OR that "Steam streaming speakers" driver does not really implement proper 7.1.

With that said, I believe this issue can be reproduced on any multichannel audio setup (even with a 5.1 audio setup), since we don't really need the rear satellites to check the basic functionality of the woofer, front and side channels.

To do this in Moonlight configuration switch to 7.1 audio, start streaming Desktop, open the Windows sound config (of Steam streaming speakers) and test out the speaker outputs. Regardless if you configure the Steam streming speaker to 5.1 or 7.1, as soon as you set Moonlight to use 7.1 audio breaks / gets distorted.

Veldenb, could you please confirm this?

veldenb commented 10 months ago

Regardless if you configure the Steam streming speaker to 5.1 or 7.1, as soon as you set Moonlight to use 7.1 audio breaks / gets distorted.

I get the same distorted, somewhat echo-ish sound when using my 5.1 receiver and 7.1 is selected from Moonlight. My receiver still detects it as multichannel PCM.

You could try the official installation method using Debian to see if the problem persists: See here. If it still occurs it's probably a Moonlight related bug.

kurac338 commented 10 months ago

Yep, thanks for confirming, I have the exact same behavior.

P.S. I have always been using the official (package) install instructions, so that can be ruled out as a correlation to the bug.

On Sat, Sep 9, 2023, 16:11 veldenb @.***> wrote:

Regardless if you configure the Steam streming speaker to 5.1 or 7.1, as soon as you set Moonlight to use 7.1 audio breaks / gets distorted.

I get the same distorted, somewhat echo-ish sound when using my 5.1 receiver and 7.1 is selected from Moonlight. My receiver still detects it as multichannel PCM.

You could try the official installation method using Debian to see if the problem persists: See here https://github.com/moonlight-stream/moonlight-docs/wiki/Installing-Moonlight-Qt-on-Raspberry-Pi-4. If it still occurs it's probably a Moonlight related bug.

— Reply to this email directly, view it on GitHub https://github.com/veldenb/plugin.program.moonlight-qt/issues/37#issuecomment-1712520906, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIZEQ4MVFQH4UFMUN7V5PFLXZR2IXANCNFSM6AAAAAA4RKQJFY . You are receiving this because you authored the thread.Message ID: @.***>

cgutman commented 10 months ago

I think this is a Raspberry Pi specific issue. I just tested streaming 7.1 surround sound from Sunshine nightly using Steam Streaming Speakers. All the channels are mapped correctly and I don't hear any underruns or other artifacts. I tested Moonlight on Windows, macOS, and Fedora 38 and everything worked fine.

We use SDL for audio, so any bug is likely there. Can you clone the latest SDL source and compile testsurround and try that? When you clone, use git clone --branch=SDL2 https://github.com/libsdl-org/SDL because SDL3 has major audio changes that may affect behavior.