Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distorted sound on Windows with Corsair or SteelSeries Wireless Headset #25875

Closed
xsellier opened this issue Feb 14, 2019 · 36 comments · Fixed by #76541
Closed

Distorted sound on Windows with Corsair or SteelSeries Wireless Headset #25875

xsellier opened this issue Feb 14, 2019 · 36 comments · Fixed by #76541

Comments

@xsellier
Copy link
Contributor

Godot version:
2.1.5

OS/device including version:
Microsoft Windows 10 Pro
Realtek High Definition Audio

Issue description:
Sound distorted and crakling:
DistortedSound.zip

Steps to reproduce:

  • Original music is an OGG file

  • Project configuration
    image

  • StreamPlayer node configuration
    image

  • Piece of code used to strat playing the music

func _play_music(volume):
  music_nodes[MUSIC_PLAYER.MUSIC].set_volume(volume)

  if volume <= 0.0 and music_data.next != null:
    music_data.current = music_data.next
    music_data.next = null

    # Update current music
    music_nodes[MUSIC_PLAYER.MUSIC].set_stream(music_data.current.source)
    music_nodes[MUSIC_PLAYER.MUSIC].play()
    music_nodes[MUSIC_PLAYER.MUSIC].set_loop(music_data.current.loop)
  • Audio file informations
Input #0, ogg, from '00-titlescreen.ogg':
  Duration: 00:01:36.01, start: 0.000000, bitrate: 194 kb/s
    Stream #0:0: Audio: vorbis, 44100 Hz, stereo, fltp, 192 kb/s
    Metadata:
      ENCODER         : FL Studio
@akien-mga akien-mga added this to the 2.1 milestone Feb 14, 2019
@xsellier
Copy link
Contributor Author

xsellier commented Feb 14, 2019

@akien-mga Sorry to flag you. Do you have an idea if this issue has been solved on 3.1/3.0/master? and/or which commit might fixed that? Or maybe I can tweak the audio mixer to fix it?

@akien-mga
Copy link
Member

Do you have an idea if this issue has been solved on 3.1/3.0/master?

The best way to know would be for you to give it a try, I can't say just from the description without doing tests myself.

@xsellier
Copy link
Contributor Author

xsellier commented Feb 14, 2019

The fact is, I cannot reproduce it, on any of my windows machine. But according to the sample I received, I cannot deny the issue.

I cannot know if the issue has been solved on branch 3.0/3.1 or master since I can't reproduce the issue on 2.1. I was just wondering if you've remembered having changed something related to the audio driver used by godot engine that might solve that issue.

Maybe you have an idea of where the issue might come from, like an entry point where I can start digging please.

@akien-mga
Copy link
Member

akien-mga commented Feb 14, 2019

Well 3.0+ use a different audio driver on Windows (xaudio2 WASAPI), so it's likely that things changed in between. The whole audio server and audio nodes have been rewritten from scratch. So I doubt anything can be cherry-picked, it would be as difficult as porting your game to 3.1 ;)

CC @marcelofg55 who might have ideas on how to debug this further.

@xsellier
Copy link
Contributor Author

xsellier commented Feb 14, 2019

Thank you a lot @akien-mga <3 Hope @marcelofg55 would be able to help me even just a little bit.

Well 3.0+ use a different audio driver on Windows (xaudio2 WASAPI), so it's likely that things changed in between

Godot 2.1.5 also uses WASAPI for windows. It uses XAudio only for winrt.

Im gonna try switching from WASAPI drivers to RtAudio drivers.

@marcelofg55
Copy link
Contributor

Hi, so to who is this happening? Some Windows users? It's a bit a complicated to solve if we can't reproduce this, maybe try to find out what audio card are they using, what sample rate and if they're using stereo or 5.1.
Also, does this happens with any music? or some music files only?

@xsellier
Copy link
Contributor Author

@marcelofg55 Hey, I replaced WASAPI with RtAudio, it fixed the issue.

User who have the problem has a surround headset. I suggest to replace the default driver for godot 2.1.5 for RtAudio instead of WASAPI

@marcelofg55
Copy link
Contributor

@xsellier Can you find out what Surround Headset is the user using? Thanks

@xsellier
Copy link
Contributor Author

@marcelofg55 I don't have the exact model, but it is a wireless Bluetooth surround headset.

Sound card is a Realtek High Definition Audio.

Raw data:

<Data>
<Item><![CDATA[Name]]></Item>
<Value><![CDATA[USB Audio Device]]></Value>
</Data>
<Data>
<Item><![CDATA[Manufacturer]]></Item>
<Value><![CDATA[(Generic USB Audio)]]></Value>
</Data>
<Data>
<Item><![CDATA[Status]]></Item>
<Value><![CDATA[OK]]></Value>
</Data>
<Data>
<Item><![CDATA[PNP Device ID]]></Item>
<Value><![CDATA[USB\VID_B58E&PID_9E84&MI_00\6&78CC2BF&0&0000]]></Value>
</Data>
<Data>
<Item><![CDATA[Driver]]></Item>
<Value><![CDATA[c:\windows\system32\drivers\usbaudio.sys (10.0.17134.1, 148.00 KB (151,552 bytes), 12-Apr-18 00:33)]]></Value>
</Data>
<Data>
<Item><![CDATA[]]></Item>
<Value><![CDATA[]]></Value>
</Data>
<Data>
<Item><![CDATA[Name]]></Item>
<Value><![CDATA[Realtek High Definition Audio]]></Value>
</Data>
<Data>
<Item><![CDATA[Manufacturer]]></Item>
<Value><![CDATA[Realtek]]></Value>
</Data>
<Data>
<Item><![CDATA[Status]]></Item>
<Value><![CDATA[OK]]></Value>
</Data>
<Data>
<Item><![CDATA[PNP Device ID]]></Item>
<Value><![CDATA[HDAUDIO\FUNC_01&VEN_10EC&DEV_0900&SUBSYS_1462D977&REV_1000\4&2D91D51F&0&0001]]></Value>
</Data>
<Data>
<Item><![CDATA[Driver]]></Item>
<Value><![CDATA[c:\windows\system32\drivers\rtkvhd64.sys (6.0.1.8496, 6.04 MB (6,330,824 bytes), 04-Jan-19 19:30)]]></Value>
</Data>
<Data>
<Item><![CDATA[]]></Item>
<Value><![CDATA[]]></Value>
</Data>
<Data>
<Item><![CDATA[Name]]></Item>
<Value><![CDATA[NVIDIA High Definition Audio]]></Value>
</Data>
<Data>
<Item><![CDATA[Manufacturer]]></Item>
<Value><![CDATA[NVIDIA]]></Value>
</Data>
<Data>
<Item><![CDATA[Status]]></Item>
<Value><![CDATA[OK]]></Value>
</Data>
<Data>
<Item><![CDATA[PNP Device ID]]></Item>
<Value><![CDATA[HDAUDIO\FUNC_01&VEN_10DE&DEV_0083&SUBSYS_14623362&REV_1001\5&E5A73DC&0&0001]]></Value>
</Data>
<Data>
<Item><![CDATA[Driver]]></Item>
<Value><![CDATA[c:\windows\system32\drivers\nvhda64v.sys (1.3.38.4, 222.55 KB (227,896 bytes), 20-Nov-18 08:36)]]></Value>
</Data>
<Data>
<Item><![CDATA[]]></Item>
<Value><![CDATA[]]></Value>
</Data>
<Data>
<Item><![CDATA[Name]]></Item>
<Value><![CDATA[USB Audio Device]]></Value>
</Data>
<Data>
<Item><![CDATA[Manufacturer]]></Item>
<Value><![CDATA[(Generic USB Audio)]]></Value>
</Data>
<Data>
<Item><![CDATA[Status]]></Item>
<Value><![CDATA[OK]]></Value>
</Data>
<Data>
<Item><![CDATA[PNP Device ID]]></Item>
<Value><![CDATA[USB\VID_1038&PID_1234&MI_00\7&24E5F7A9&0&0000]]></Value>
</Data>
<Data>
<Item><![CDATA[Driver]]></Item>
<Value><![CDATA[c:\windows\system32\drivers\usbaudio.sys (10.0.17134.1, 148.00 KB (151,552 bytes), 12-Apr-18 00:33)]]></Value>
</Data>
</Category>

@marcelofg55
Copy link
Contributor

@xsellier So I've been trying to reproduce this myself without much luck, tried with my external 5.1 sound card setting it to 5.1, 7.1 and 3.1 and I've got no distortion on the sound, even tried some Surround Virtual software and no luck.
Do you know if the user experienced this bug on any music file?

I think that this bug should also be present on the 3.0/3.1 branch since the WASAPI driver uses the same logic to output sound, but until I'm able to reproduce it and can't be sure of this.

@xsellier
Copy link
Contributor Author

Any music file and even with FX sound.

@xsellier
Copy link
Contributor Author

xsellier commented Feb 24, 2019

@marcelofg55 This issue won't happen on the latest version of godot 3+ because of that:
https://github.com/godotengine/godot/blob/2.1/drivers/wasapi/audio_driver_wasapi.cpp#L159

So I wonder why it is like that and not as following:

	switch (wasapi_channels) {
		case 2: // Stereo
		case 4: // Surrounf 3.1
		case 6: // Surround 5.1
		case 8: // Surround 7.1
			channels = wasapi_channels;
			break;

@xsellier
Copy link
Contributor Author

Bump @marcelofg55

@marcelofg55
Copy link
Contributor

@xsellier Unless we find a way to reproduce this I don't see a way to fix it.

@xsellier
Copy link
Contributor Author

@marcelofg55 It happens only on version 2.1.5 because WASAPI in version 2.1.5 does not handle surround system. (more than 2 channels):
https://github.com/godotengine/godot/blob/2.1/drivers/wasapi/audio_driver_wasapi.cpp#L159

@marcelofg55
Copy link
Contributor

@xsellier I tested this with a 5.1 surround system myself and the distortion didn't happen to me. Could you reproduce the distortion using a surround system?

@xsellier
Copy link
Contributor Author

xsellier commented Mar 15, 2019

@marcelofg55 I don't have a surround system at home.
I have one player (who reported it, it might have more than one) who has the issue, on release build, with a surround system as described in the first message.

But I'm wondering if it cannot come from that part:
https://github.com/godotengine/godot/blob/2.1/drivers/wasapi/audio_driver_wasapi.cpp#L159

Because on master/3.0/3.1 it looks like that:
https://github.com/godotengine/godot/blob/master/drivers/wasapi/audio_driver_wasapi.cpp#L323

Which is not the same algorithm.

@marcelofg55
Copy link
Contributor

@xsellier Well, I tested it on my 5.1 surround device and couldn't reproduce it, so unless somebody else finds a way to reproduce it I don't think I can find a fix for this.

But I'm wondering if it cannot come from that part:
https://github.com/godotengine/godot/blob/2.1/drivers/wasapi/audio_driver_wasapi.cpp#L159

Because on master/3.0/3.1 it looks like that:
https://github.com/godotengine/godot/blob/master/drivers/wasapi/audio_driver_wasapi.cpp#L323

Which is not the same algorithm.

Godot 3.0+ supports surround audio on the audio server, Godot 2.1 doesn't, so that's why that code is different. Anyways, I don't thins is the problem of the distortion, but since I can't reproduce it myself I can't be sure.

@xsellier
Copy link
Contributor Author

@marcelofg55 Thank you for that explanation.
Maybe this informations will help you.
Whenever a player has an audio issue, I suggest him to switch to RtAudio driver (using -ad RtAudio) and it solves the issue.

@xsellier
Copy link
Contributor Author

xsellier commented Jun 5, 2019

Here is another record of another player who is having the same issue with WASAPI driver on windows:
https://www.youtube.com/watch?v=7CRpFD_0Qo4&feature=youtu.be

PC Specs of the guy who have the issue:
PC :

  • Intel Core i7-7700K (4.2 GHz)
  • Asus STRIX Z270E GAMING
  • Gigabyte AORUS GeForce GTX 1080 Ti XTREME Edition, 11 Go
  • DDR4 Corsair Vengeance RGB, Noir, 32 Go, 3200 MHz, CAS 16
  • Seagate BarraCuda, 2 To (x2)
  • SSD Samsung 120 Go
  • Sandisk SSD PLUS TLC, 480 Go, SATA III
  • EVGA SuperNOVA 850 G3, 850W
  • NZXT Noctis 450 ROG
  • Thermaltake Water 3.0 Riing RGB 240

Other:

  • PS4 Pro
  • HTC Vive

Screens :

  • 1920 x 1080 Samsung C24F396FHU Curved Monitor
  • Acer Predator Z321QU Curved 31.5" WQHD - 144 Hz / G-Sync / VA (I hate so much IPS glow)
  • Ultra HD 4k HDR TV

Accessory :

  • Speaker - 2.1 Logitech Z333
  • Corsair ST100 RGB :)
  • headphone - Corsair Void Pro Special Edition Wireless for my PC
  • Astro A40 TR + Mixamp Pro TR for PC and PS4
  • Keyboard - Corsair K70 RGB
  • Mouse - Logitech G502 (wow this is not corsair :o)
  • WD 3TB Portable External Hard Drive
  • The limited edition Xbox Controller of Sea of Thieves
  • 1 Xbox one classic controller and 2 Ps4 dualchock controller

@Houkime
Copy link

Houkime commented Jul 10, 2019

I have run into similar issue with the recent master while checking in wine my result of cross-compilation.

@Favorlock
Copy link

Favorlock commented Apr 10, 2020

I as well am running into an issue that appears to be related to this. I get the error: W 0:00:02.221 init_render_device: WASAPI: Unsupported number of channels: 1
<C++ Source> drivers/wasapi/audio_driver_wasapi.cpp:330 @ init_render_device()

I'm using a steelseries wireless headset and I believe the receiver is connected over usb.

@Mkneeshaw
Copy link

I am getting this same issue using a SteelSeries wireless headset.
W 0:00:00.363 init_render_device: WASAPI: Unsupported number of channels: 1
<C++ Source> drivers/wasapi/audio_driver_wasapi.cpp:330 @ init_render_device()

@Calinou

This comment has been minimized.

@xsellier
Copy link
Contributor Author

@Mkneeshaw Please open a new issue as this appears to be unrelated to OP's setup.

In fact this is exactly the same issue (see this comment: #25875 (comment) )

@akien-mga akien-mga changed the title [2.1.5] Distorted sound on some Windows [2.1] Distorted sound on some Windows Oct 25, 2021
@akien-mga akien-mga changed the title [2.1] Distorted sound on some Windows Distorted sound on Windows with Corsair or SteelSeries Wireless Headset Oct 25, 2021
@akien-mga akien-mga removed this from the 2.1 milestone Oct 25, 2021
@akien-mga
Copy link
Member

So it sounds like it's not 2.1 specific in the end.

@Favorlock @Mkneeshaw What Godot versions did you experience this with? Is it still reproducible with latest 3.3 and 3.4 releases?

@xsellier
Copy link
Contributor Author

@Mkneeshaw
Copy link

I have this issue still with 3.3.3 and 3.4 rc2

@KoBeWi
Copy link
Member

KoBeWi commented Jun 8, 2022

I have the issue with this warning (not sure if it's the same as the original):

WARNING: WASAPI: Unsupported number of channels: 1
   at: AudioDriverWASAPI::init_render_device (drivers\wasapi\audio_driver_wasapi.cpp:328) - WASAPI: Unsupported number of channels: 1

The issue is that when you have bluetooth headset, it usually has 2 audio modes. One with only sound and one with sound + microphone. You can find more info here: https://answers.microsoft.com/en-us/windows/forum/all/headset-vs-headphones/93aca8a3-626c-4439-ab9f-8f774d76be44
The issue is that in the "microphone" mode, audio quality drops. You can hear it in any game/application, but in Godot the difference is just extreme, to the point that the game is unplayable with distorted audio.

Here's vide with normal audio:

godot.windows.opt.tools.64_rCwGpHbcGG.mp4

And here is the other audio mode:

godot.windows.opt.tools.64_WWvL4b4Okk.mp4

The character's voice is especially distorted. It gets even worse when you enable music:

godot.windows.opt.tools.64_XNr41XgWMS.mp4

vs

godot.windows.opt.tools.64_TN0w2uCmEh.mp4

There is this crackling noise that's just unbearable.

I don't know if there is something that can be done about it, as it might be some WASAPI problem. I know that in other games (non-Godot) the sound doesn't become completely illegible like this, so there is room for improvement.

@Calinou
Copy link
Member

Calinou commented Jun 8, 2022

@KoBeWi Can you reproduce this if you change the output mix frequency to 44100, 48000 or even 22050 in the Project Settings?

@KoBeWi
Copy link
Member

KoBeWi commented Jun 8, 2022

48000 and 22050 don't seem to make difference, with 441100 there is no sound at all (so I guess it fixes distortions? 😂).

@Calinou
Copy link
Member

Calinou commented Jun 8, 2022

48000 and 22050 don't seem to make difference, with 441100 there is no sound at all (so I guess it fixes distortions? joy).

I meant 44100 instead of 441100, sorry. I guess 44100 is the default value already though.

@KoBeWi
Copy link
Member

KoBeWi commented Jun 8, 2022

Right. I just added 0, so actually it was 441000.
But it doesn't seem to be related to mix rate anyway.

@mdarcy
Copy link

mdarcy commented Aug 26, 2022

Hey. I, too, am experiencing this problem. Any updates?

@Calinou
Copy link
Member

Calinou commented Aug 26, 2022

Hey. I, too, am experiencing this problem. Any updates?

We don't know the exact source of the problem yet, so there is no ETA for fixing this.

We did suspect however that Godot not handling mono audio output well on Windows could be a possible culprit, but this may be unrelated. (Using microphone mode on a Bluetooth headset will force audio output to be mono in many cases.)

@akien-mga
Copy link
Member

Reposting my comment from #76504 (comment):

The WASAPI driver doesn't seem to implement mono audio indeed. This might just be an oversight.

Relevant code (in master, but it's likely similar in 3.x and 3.5):

switch (audio_output.channels) {
case 2: // Stereo
case 4: // Surround 3.1
case 6: // Surround 5.1
case 8: // Surround 7.1
channels = audio_output.channels;
break;
default:
WARN_PRINT("WASAPI: Unsupported number of channels: " + itos(audio_output.channels));
channels = 2;
break;
}

Likewise for macOS's coreaudio driver:

switch (strdesc.mChannelsPerFrame) {
case 2: // Stereo
case 4: // Surround 3.1
case 6: // Surround 5.1
case 8: // Surround 7.1
channels = strdesc.mChannelsPerFrame;
break;
default:
// Unknown number of channels, default to stereo
channels = 2;
break;
}

While pulseaudio handles mono and other odd channel counts, apparently by just adding + 1:

switch (pa_map.channels) {
case 1: // Mono
case 3: // Surround 2.1
case 5: // Surround 5.0
case 7: // Surround 7.0
channels = pa_map.channels + 1;
break;
case 2: // Stereo
case 4: // Surround 4.0
case 6: // Surround 5.1
case 8: // Surround 7.1
channels = pa_map.channels;
break;
default:
WARN_PRINT("PulseAudio: Unsupported number of output channels: " + itos(pa_map.channels));
pa_channel_map_init_stereo(&pa_map);
channels = 2;
break;
}

That likely wouldn't be enough here though, because in this case it's basically what happens (1 channel is unsupported, so it falls back to 2 / stereo).

The mono output basically just needs to be implemented. The downsampling done in the PulseAudio driver could probably be ported to WASAPI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants