hrtf.txt 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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] = "MinPHR01";
  25. ALuint sampleRate;
  26. ALubyte hrirSize; /* Can be 8 to 128 in steps of 8. */
  27. ALubyte evCount; /* Can be 5 to 128. */
  28. ALubyte azCount[evCount]; /* Each can be 1 to 128. */
  29. /* NOTE: hrirCount is the sum of all azCounts */
  30. ALshort coefficients[hrirCount][hrirSize];
  31. ALubyte delays[hrirCount]; /* Each can be 0 to 63. */
  32. ==
  33. The data is described as thus:
  34. The file first starts with the 8-byte marker, "MinPHR01", to identify it as an
  35. HRTF data set. This is followed by an unsigned 32-bit integer, specifying the
  36. sample rate the data set is designed for (OpenAL Soft will not use it if the
  37. output device's playback rate doesn't match).
  38. Afterward, an unsigned 8-bit integer specifies how many sample points (or
  39. finite impulse response filter coefficients) make up each HRIR.
  40. The following unsigned 8-bit integer specifies the number of elevations used
  41. by the data set. The elevations start at the bottom (-90 degrees), and
  42. increment upwards. Following this is an array of unsigned 8-bit integers, one
  43. for each elevation which specifies the number of azimuths (and thus HRIRs) that
  44. make up each elevation. Azimuths start clockwise from the front, constructing
  45. a full circle for the left ear only. The right ear uses the same HRIRs but in
  46. reverse (ie, left = angle, right = 360-angle).
  47. The actual coefficients follow. Each coefficient is a signed 16-bit sample,
  48. with each HRIR being a consecutive number of sample points. The HRIRs must be
  49. minimum-phase. This allows the use of a smaller filter length, reducing
  50. computation. For reference, the built-in data set uses a 32-point filter while
  51. even the smallest data set provided by MIT used a 128-sample filter (a 4x
  52. reduction by applying minimum-phase reconstruction). Theoretically, one could
  53. further reduce the minimum-phase version down to a 16-point filter with only a
  54. small reduction in quality.
  55. After the coefficients is an array of unsigned 8-bit delay values, one for
  56. each HRIR. This is the propagation delay (in samples) a signal must wait before
  57. being convolved with the corresponding minimum-phase HRIR filter.