hrtf.txt 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 built-in data set is based on the KEMAR HRTF diffuse data provided by MIT,
  13. which can be found at <http://sound.media.mit.edu/resources/KEMAR.html>. It's
  14. only available when using 44100hz playback.
  15. External 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 built-in 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 for the data sets is specified below. It uses little-endian
  23. byte order. Certain data fields are restricted to specific values (these
  24. restriction may be lifted in future versions of the lib).
  25. ==
  26. ALchar magic[8] = "MinPHR00";
  27. ALuint sampleRate;
  28. ALushort hrirCount; /* Required value: 828 */
  29. ALushort hrirSize; /* Required value: 32 */
  30. ALubyte evCount; /* Required value: 19 */
  31. ALushort evOffset[evCount]; /* Required values:
  32. { 0, 1, 13, 37, 73, 118, 174, 234, 306, 378, 450, 522, 594, 654, 710, 755,
  33. 791, 815, 827 } */
  34. ALshort coefficients[hrirCount][hrirSize];
  35. ALubyte delays[hrirCount]; /* Element values must not exceed 127 */
  36. ==
  37. The data is described as thus:
  38. The file first starts with the 8-byte marker, "MinPHR00", to identify it as an
  39. HRTF data set. This is followed by an unsigned 32-bit integer, specifying the
  40. sample rate the data set is designed for (OpenAL Soft will not use it if the
  41. output device's playback rate doesn't match).
  42. Afterward, an unsigned 16-bit integer specifies the total number of HRIR sets
  43. (each HRIR set is a collection of impulse responses forming the coefficients
  44. for a convolution filter). The next unsigned 16-bit integer specifies how many
  45. samples are in each HRIR set (the number of coefficients in the filter). The
  46. following unsigned 8-bit integer specifies the number of elevations used by the
  47. data set. The elevations start at the bottom, and increment upwards.
  48. Following this is an array of unsigned 16-bit integers, one for each elevation
  49. which specifies the index offset to the start of the HRIR sets for each given
  50. elevation (the number of HRIR sets at each elevation is infered by the offset
  51. to the next elevation, or by the total count for the last elevation).
  52. The actual coefficients follow. Each coefficient is a signed 16-bit sample,
  53. with each HRIR set being a consecutive number of samples. For each elevation,
  54. the HRIR sets first start with a neutral "in-front" set (that is, one that is
  55. applied equally to the left and right outputs). After this, the sets follow a
  56. clockwise pattern, constructing a full circle for the left ear only. The right
  57. ear uses the same sets but in reverse (ie, left = angle, right = 360-angle).
  58. After the coefficients is an array of unsigned 8-bit delay values, one for each
  59. HRIR set. This is the delay, in samples, after recieving an input sample before
  60. before it's added in to the convolution filter that the corresponding HRIR set
  61. operates on and gets heard.
  62. Note that the HRTF data is expected to be minimum-phase reconstructed. The
  63. time delays are handled by OpenAL Soft according to the specified delay[]
  64. values, and afterward the samples are fed into the convolution filter using the
  65. corresponding coefficients. This allows for less processing by using a shorter
  66. convolution filter, as it skips the first coefficients that do little more than
  67. cause a timed delay, as well as the tailing coefficients that are used to
  68. equalize the length of all the sets and contribute nothing.
  69. For reference, the built-in data set uses a 32-sample convolution filter while
  70. even the smallest data set provided by MIT used a 128-sample filter (a 4x
  71. reduction by applying minimum-phase reconstruction). Theoretically, one could
  72. further reduce the minimum-phase version down to a 16-sample convolution filter
  73. with little quality loss.