bsnes-emu / bsnes

bsnes is a Super Nintendo (SNES) emulator focused on performance, features, and ease of use.
Other
1.68k stars 156 forks source link

Add a Default Audio Output Device #8

Open cascardian opened 4 years ago

cascardian commented 4 years ago

This is a minor quality of life issue.

Windows allows you to switch the audio output device on the fly (between speakers and headphones, for example). This is supposed to apply system-wide, but bsnes' audio output device selection only allows setting a specific audio device for backends other than waveOut. Meaning you can get a situation where you've set headphone output for the system, but bsnes's setting is still set to speakers. So, instead of simply using Windows' widget to set it for all applications (which usually respect this setting), you have to set it separately specifically for bsnes as well.

select-playback-device The solution is to add a setting for the system default device to the enumeration.

Thank you for your consideration.

Sintendo commented 4 years ago

The WASAPI and XAudio 2.1 drivers do indeed not allow you to select the 'Default' audio device right now.

Do you have a specific reason for using the XAudio 2.1 driver? If not, may I suggest using the waveOut driver as an alternative?

cascardian commented 4 years ago

Thank you for the suggestion. I had done that, but waveOut had always resulted in more crackling for me, no matter my skew and latency finagling. But it's actually fully gone now. The only relevant thing I've changed is finally not using Realtek's driver (I use the onboard ALC1220 chip) anymore, and just going with Windows 10's basic driver. Man, such a better experience. I can even set lower latencies now, no need to even configure any skew.

That clears up my issue. Should this still stay up in case anyone would still like to implement a default device selection for the other backends?

IPeluchito commented 4 years ago

XAudio 2.1 has better effects and sound quality than waveOut ...

Screwtapello commented 3 years ago

I don't know why the WASAPI and XAudio2 drivers require a specific device to be selected, but it seems like a sensible thing to have. I would take a PR adding this feature.

Sintendo commented 3 years ago

Part of the problem is that we're currently targeting XAudio 2.1, which cannot select the default audio output device. I think this version was chosen for compatibility with older Windows versions, but I don't recall the specifics. In any case, we'll need to move to at least 2.8 in order to support this.

I haven't looked into WASAPI, so I can't comment on what's needed there.

Screwtapello commented 3 years ago

My recollection is that XAudio 2.8 required Windows 8, while XAudio 2.7 could be installed on any OS version (including Windows 8) with the DirectX installer, so that made 2.7 the correct version to use. Apparently XAudio 2.9 now comes with Windows 10, and there's a redistributable version that works back to Win7, but it needs to be shipped with the executable and probably requires the MSVC toolchain... ugh. I'm also a little worried whether mingw32-w64's headers support later versions of the XAudio2 API, but I see mentions of XAudio 2.9 in their source tree so I assume it'll work eventually if it doesn't already.

The latest Steam Hardware Survey says ~90% of Windows gamers are using Windows 10, so as long as supporting later versions of XAudio doesn't break Win7 (i.e. as long as they can still use WASAPI or waveOut or DirectSound) it seems like a reasonable thing to do.

The XAudio docs also mention that the output sample-rate can change at runtime (say, somebody is playing a 48kHz audio stream, then plugs in USB headphones that only support 44.1kHz) and I bet ruby doesn't handle that very well at all. Still, I think that would be an improvement over the current situation (plug in headphones, audio keeps playing out the speaker) and for people whose headphones and speakers match, it'd be exactly right.

I would also like to hear more about WASAPI.