https://bugs.winehq.org/show_bug.cgi?id=45311
--- Comment #19 from Kai Krakow kai@kaishome.de --- Continuing my previous comment, I've played with this a little bit:
It's part of the solution. Skyrim uses the output matrix to upmix mono samples to the computer audio system (6 channels here). Voice samples will upmix to two channels, ambient sound upmix to 6 channels. They are played non-directional.
004b:trace:xaudio2_matrix:XA2SRC_SetOutputMatrix -- *pLevelMatrix = {0.250206,0.000000,0.000000,0.000000,0.368162,0.000000} 004b:trace:xaudio2_matrix:XA2SRC_SetOutputMatrix -- *pLevelMatrix = {0.573172,0.573172}
It's always the same values per sample no matter which direction I'm facing. So it's also not really handling the volume. Calculating an RMS from the values to prevent hard cut-offs and attenuation to the "main volume" has some effect: Ambient sounds now don't simply pop in and out but they attenuate with decreasing distance, strange is: This happens in steps, it's not smooth.
So actually Skyrim puts some volume information here. But it also sets an output filter which is also not implemented.
Ambient voices from NPCs tho still have the same issue: You can hear all talking NPC nearby as if talking face to face. Skyrim also tries to apply an output filter here.
What I think the filter should be doing is: After upmixing, the filter will arrange the sample spatially across your speakers. Voices would always use two virtual speakers so voice would come from the front. Ambient sounds always distribute the sound around you with attenuation from one direction. The filter probably should position the sound source spatially and also apply some filters for volume and some frequency pass filters (sounds farther away should fade out in the lower spectrum later).
Upmixing is a problem with OpenAL (which is used by xaudio2): It simply has no interface for that (only downmixing via spatial extensions). But we could probably infer an attenuation direction from the output matrix, and then set a direction of the sound source - but I'm pretty sure this won't be easy... That's more or less where my skills end currently.