/
hrtf file format.txt
23 lines (12 loc) · 2.31 KB
/
hrtf file format.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
This document's long-term accuracy has been proven, and the code is not likely to change. If there is any doubt, however, the code wins.
A file specifying an HRTF definition shall consist of the following, specified in the order below. Note that everything is either ints or floats, so moving over the file with a window size of 4 and swapping bytes can reverse its endianness for little-endian processors. HRTF files are written in whatever endianness the writing machine happens to have, and it is fixed on read.
Assume an integer is 4 bytes and a float is 4 bytes.
- A unique string of 16 bytes. How these are generated doesn't matter; the scripts included with this repository use Python's uuid module. If two files have the same string of 16 bytes, they are considered to be the same HRTF for caching purposes.
- The integer 1 represented as 4 bytes. This allows us to tell if the file was written on an endianness other than ours through a simple compare. If it, when compared, is not equal to 1, then iterate over the file with a window size of 4 and swap appropriately.
- The sample rate of the responses in this file in hertz as a 4-byte integer.
- Next, the number of HRIR impulse responses as a 4-byte integer.
- The number of elevations, as an integer. This must be at least 1.
- The minimum and maximum elevations, in degrees. 0 is horizontal; -90 is straight down; 90 is straight up. Unless the elevation number is 1, these may not be equal. Note that if max-min is not divisible by the number of elevations, floating point inaccuracies may accumulate. Furthermore, the minimum elevation must be less than or equal to 0, and the maximum elevation must be greater than or equal to 0.
- The number of azimuths for each elevation, as 4-byte ints. There shall be as many of these as elevations, so a length for this list is unnecessary. 0 is not valid.
- The length of each response as 4 bytes. All responses must have the same length. If they don't in the original data, pad them with zeros to the length of the longest.
- The responses themselves. These are assumed to be for the right ear and are stored starting at the minimum elevation azimuth 0. Storage then proceeds clockwise for the current elevation, before jumping up to the next one. If your dataset is giving responses for the left ear, add180 mod 360 to the angle.