ValveSoftware / steam-audio

Steam Audio
https://valvesoftware.github.io/steam-audio/
Apache License 2.0
2.2k stars 152 forks source link

Ambisonic Binaural vs IPLBinauralEffect #268

Closed anomiet closed 10 months ago

anomiet commented 10 months ago

Hello!

I have some questions about binaural audio and the different approaches available.

I was originally doing everything through IPLBinauralEffect and adding it to each point source individually. This worked well enough.

However, from reading docs and then trying it myself, another path seems to encode all your point sources into an ambisonic sound field and then decoding it while setting binaural to IPL_TRUE. This also seems to work, but have some questions about this:

1) Is mixing many point sources into one ambisonic sound field and decoding once on the final field more performant than running individual IPLBinauralEffects on each point source? 2) The two methods actually sound quite different with IPLBinauralEffect having a much more pronounced spatializing effect (hard left and hard right seem to pan much more aggressively), but this also seems to color the point sources a bit more in not always the most desirable way. Is this expected?

One final note, there seems to be yet a third way to do this, and that's to use iplAmbisonicsBinauralEffectApply on an already encoded ambisonic sound field. You also have to apply iplAmbisonicsRotationEffectApply before using this effect, and this effect also seems to handle the decoding to 2 channels for you as well. From what I can tell, this sounds the same as doing the ambisonic approach mentioned above.

I'm currently on 4.2.0.

Cheers!

lakulish commented 10 months ago

To answer your questions:

  1. Mixing multiple point sources into a single Ambisonic field and then decoding can be more performant than separately spatializing each point source. This depends on the number of Ambisonic channels vs. the number of sources. Some audio engines provide an option for running the entire mixing pipeline in Ambisonic format, which also allows for decoding to arbitrary speaker configurations in addition to binaural rendering.
  2. Correct, IPLBinauralEffect provides more accurate spatialization and a greater sense of externalization, at the cost of more spectral coloration. Ambisonics results in reduced spatial resolution, but provides less spectral coloration in addition to the advantages of mixing, arbitrary speaker layouts, etc.
  3. iplAmbisonicsDecodeEffectApply is essentially implemented as iplAmbisonicsRotateEffectApply followed by iplAmbisonicsBinauralEffectApply (assuming binaural is set to IPL_TRUE), so yes, these approaches should sound the same.
anomiet commented 10 months ago

Thank you for the detailed response! Very excited to see proper ambisonics work so well for game tech. Matches my experiences with ATK, but harder to get that working with game tech: https://www.ambisonictoolkit.net/

I actually prefer the sound going trough the ambisonic field but curious to compare in a setting where localization is super crucial (like you would want in something like Counter Strike). Might also help to test more SOFAs but the default Steam Audio one works best so far on my head and ear shape.

I'll close the issue since you've answered everything I need. Quite fond of this API!

Cheers