🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
3.9 KiB

  1. HRTF Support
  2. ============
  3. Starting with OpenAL Soft 1.14, HRTFs can be used to enable enhanced
  4. spatialization for both 3D (mono) and multi-channel sources, when used with
  5. headphones/stereo output. This can be enabled using the 'hrtf' config option.
  6. For multi-channel sources this creates a virtual speaker effect, making it
  7. sound as if speakers provide a discrete position for each channel around the
  8. listener. For mono sources this provides much more versatility in the perceived
  9. placement of sounds, making it seem as though they are coming from all around,
  10. including above and below the listener, instead of just to the front, back, and
  11. sides.
  12. The default data set is based on the KEMAR HRTF data provided by MIT, which can
  13. be found at <http://sound.media.mit.edu/resources/KEMAR.html>.
  14. Custom HRTF Data Sets
  15. =====================
  16. OpenAL Soft also provides an option to use user-specified data sets, in
  17. addition to or in place of the default set. This allows users to provide data
  18. sets that could be better suited for their heads, or to work with stereo
  19. speakers instead of headphones, for example.
  20. The file format is specified below. It uses little-endian byte order.
  21. ==
  22. ALchar magic[8] = "MinPHR03";
  23. ALuint sampleRate;
  24. ALubyte channelType; /* Can be 0 (mono) or 1 (stereo). */
  25. ALubyte hrirSize; /* Can be 8 to 128 in steps of 8. */
  26. ALubyte fdCount; /* Can be 1 to 16. */
  27. struct {
  28. ALushort distance; /* Can be 50mm to 2500mm. */
  29. ALubyte evCount; /* Can be 5 to 128. */
  30. ALubyte azCount[evCount]; /* Each can be 1 to 128. */
  31. } fields[fdCount];
  32. /* NOTE: ALbyte3 is a packed 24-bit sample type,
  33. * hrirCount is the sum of all azCounts.
  34. * channels can be 1 (mono) or 2 (stereo) depending on channelType.
  35. */
  36. ALbyte3 coefficients[hrirCount][hrirSize][channels];
  37. ALubyte delays[hrirCount][channels]; /* Each can be 0 to 63. */
  38. ==
  39. The data layout is as follows:
  40. The file first starts with the 8-byte marker, "MinPHR03", to identify it as an
  41. HRTF data set. This is followed by an unsigned 32-bit integer, specifying the
  42. sample rate the data set is designed for (OpenAL Soft will resample the HRIRs
  43. if the output device's playback rate doesn't match).
  44. Afterward, an unsigned 8-bit integer specifies the channel type, which can be 0
  45. (mono, single-channel) or 1 (stereo, dual-channel). After this is another 8-bit
  46. integer which specifies how many sample points (or finite impulse response
  47. filter coefficients) make up each HRIR.
  48. The following unsigned 8-bit integer specifies the number of fields used by the
  49. data set, which must be in descending order (farthest first, closest last).
  50. Then for each field an unsigned 16-bit short specifies the distance for that
  51. field in millimeters, followed by an 8-bit integer for the number of
  52. elevations. These elevations start at the bottom (-90 degrees), and increment
  53. upwards. Following this is an array of unsigned 8-bit integers, one for each
  54. elevation which specifies the number of azimuths (and thus HRIRs) that make up
  55. each elevation. Azimuths start clockwise from the front, constructing a full
  56. circle. Mono HRTFs use the same HRIRs for both ears by reversing the azimuth
  57. calculation (ie. left = angle, right = 360-angle).
  58. The actual coefficients follow. Each coefficient is a signed 24-bit sample.
  59. Stereo HRTFs interleave left/right ear coefficients. The HRIRs must be
  60. minimum-phase. This allows the use of a smaller filter length, reducing
  61. computation. For reference, the default data set uses a 32-point filter while
  62. even the smallest data set provided by MIT used a 128-sample filter (a 4x
  63. reduction by applying minimum-phase reconstruction).
  64. After the coefficients is an array of unsigned 8-bit delay values as 6.2 fixed-
  65. point integers, one for each HRIR (with stereo HRTFs interleaving left/right
  66. ear delays). This is the propagation delay in samples a signal must wait before
  67. being convolved with the corresponding minimum-phase HRIR filter.