🛠️🐜 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.

84 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>. It's only
  14. available when using 44100hz or 48000hz playback.
  15. Custom HRTF Data Sets
  16. =====================
  17. OpenAL Soft also provides an option to use user-specified data sets, in
  18. addition to or in place of the default set. This allows users to provide their
  19. own data sets, which could be better suited for their heads, or to work with
  20. stereo speakers instead of headphones, or to support more playback sample
  21. rates, for example.
  22. The file format is specified below. It uses little-endian byte order.
  23. ==
  24. ALchar magic[8] = "MinPHR02";
  25. ALuint sampleRate;
  26. ALubyte sampleType; /* Can be 0 (16-bit) or 1 (24-bit). */
  27. ALubyte channelType; /* Can be 0 (mono) or 1 (stereo). */
  28. ALubyte hrirSize; /* Can be 8 to 128 in steps of 8. */
  29. ALubyte fdCount; /* Can be 1 to 16. */
  30. struct {
  31. ALushort distance; /* Can be 50mm to 2500mm. */
  32. ALubyte evCount; /* Can be 5 to 128. */
  33. ALubyte azCount[evCount]; /* Each can be 1 to 128. */
  34. } fields[fdCount];
  35. /* NOTE: ALtype can be ALshort (16-bit) or ALbyte[3] (24-bit) depending on
  36. * sampleType,
  37. * hrirCount is the sum of all azCounts.
  38. * channels can be 1 (mono) or 2 (stereo) depending on channelType.
  39. */
  40. ALtype coefficients[hrirCount][hrirSize][channels];
  41. ALubyte delays[hrirCount][channels]; /* Each can be 0 to 63. */
  42. ==
  43. The data is described as thus:
  44. The file first starts with the 8-byte marker, "MinPHR02", to identify it as an
  45. HRTF data set. This is followed by an unsigned 32-bit integer, specifying the
  46. sample rate the data set is designed for (OpenAL Soft will not use it if the
  47. output device's playback rate doesn't match).
  48. Afterward, an unsigned 8-bit integer specifies how many sample points (or
  49. finite impulse response filter coefficients) make up each HRIR.
  50. The following unsigned 8-bit integer specifies the number of fields used by the
  51. data set. Then for each field an unsigned 16-bit short specifies the distance
  52. for that field (in millimeters), followed by an 8-bit integer for the number of
  53. elevations. These elevations start at the bottom (-90 degrees), and increment
  54. upwards. Following this is an array of unsigned 8-bit integers, one for each
  55. elevation which specifies the number of azimuths (and thus HRIRs) that make up
  56. each elevation. Azimuths start clockwise from the front, constructing a full
  57. circle. Mono HRTFs use the same HRIRs for both ears by reversing the azimuth
  58. calculation (ie. left = angle, right = 360-angle).
  59. The actual coefficients follow. Each coefficient is a signed 16-bit or 24-bit
  60. sample. Stereo HRTFs interleave left/right ear coefficients. The HRIRs must
  61. be minimum-phase. This allows the use of a smaller filter length, reducing
  62. computation. For reference, the default data set uses a 32-point filter while
  63. even the smallest data set provided by MIT used a 128-sample filter (a 4x
  64. reduction by applying minimum-phase reconstruction).
  65. After the coefficients is an array of unsigned 8-bit delay values, one for
  66. each HRIR (with stereo HRTFs interleaving left/right ear delays). This is the
  67. propagation delay (in samples) a signal must wait before being convolved with
  68. the corresponding minimum-phase HRIR filter.