aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/hrtf.c
Commit message (Collapse)AuthorAgeFilesLines
* Rebalance the frequencies for B-Format HRTF coefficientsChris Robinson2016-11-011-14/+27
| | | | | | | | | | | | | | | The original pseudo-inverse method that generated the LF matrix expects the high frequencies to be scaled up by ~2.645751 over the low frequencies (or sqrt(7), ~8.45dB). However, the AllRAD method used to generate the HF matrix produced a matrix that was only scaled up by 1.46551981258 (based on the average of the W coefficients). Previously, the LF matrix was scaled down by sqrt(7), as the difference specified in the pseudo-inverse results. This failed to account for the increase already present in the HF matrix, so now the LF matrix is scaled down by the remaining difference between the expected scaling and the scaling already present in the HF matrix (sqrt(7) / 1.46551981258 = 1.80533302205, or roughly 5.13dB, where the reciprocal is 0.553914423 for -5.13 dB).
* Don't interpolate between nearest HRIRsChris Robinson2016-10-091-75/+38
| | | | | | | | It still fades between HRIRs when it changes, but now it selects the nearest one instead of blending the nearest four. Due to the minimum-phase nature of the HRIRs, interpolating between delays lead to some oddities which are exasperated by the fading (and the fading is needed to avoid clicks and pops, and smooth out changes).
* Update the ambisonic coefficients for HRTFChris Robinson2016-09-261-15/+15
| | | | | | | This uses an AllRAD-derived decoder matrix for the high frequencies, which seems to improve positioning response. It also switches back to dual-band. The low frequencies appear to be unexpectedly quiet by comparison, but it's not that bad and can be tweaked later.
* Don't warn if the desired default HRTF is already firstChris Robinson2016-09-101-4/+4
|
* Reduce the volume for the HRTF ambisonic decoderChris Robinson2016-09-081-14/+14
| | | | | | | Since it's accumulating multiple HRIRs for two output speakers, it seems to be a better option to preserve the amplitude of the high-frequency decoder instead of increasing it, and reduce the amplitude of the low-frequency decoder to compensate.
* Use a few more HRIRs for the HRTF B-Format decoderChris Robinson2016-09-071-19/+31
| | | | | 14 in total, an 8-point cube and a 6-point diamond shape, to help improve sound localization a bit. Incurs no real extra CPU cost once the IRs are built.
* Properly align 16-bit fields in the Hrtf structChris Robinson2016-09-071-10/+20
|
* Use more correct cube decoder matricesChris Robinson2016-09-051-8/+8
|
* Calculate a variable closer to where it's usedChris Robinson2016-09-011-5/+5
|
* Always load HRTF files through memory pointersChris Robinson2016-08-311-261/+134
|
* Add a compile-time macro to use dual-band ambisonic HRTF processingChris Robinson2016-08-301-12/+36
| | | | | Use single-band processing for now, to see if dual-band is causing a drop in quality at all.
* Band-split the HRIRs when building the ambisonic decoder filtersChris Robinson2016-08-211-21/+43
| | | | | This allows each HRIR to contribute a frequency-dependent response, essentially acting like a dual-band decoder playing over the cube speaker array.
* Fix HRTF index calculations for B-Format coefficientsChris Robinson2016-08-181-11/+10
| | | | | | | The CalcEvIndices and CalcAzIndices methods were dependent on the FPU being in round-to-zero mode, which is not the case for panning initialization. And since we just need the closest index and don't need to lerp between them, it's better to just directly calculate the index with rounding.
* Only use the cube points for generating the ambisonic HRTF coefficientsChris Robinson2016-08-171-56/+72
| | | | | | | | | | | Using all the HRIRs seems to have problems with volume balancing, due in part to HRTF data sets not having uniform enough measurements for a simple decoder matrix to work (and generating a proper one that would work better is not that easy). This still maintains the benefits of decoding ambisonics directly to HRTF, namely that it only needs to filter the 4 ambisonic channels and can use more optimized HRTF filtering methods on those channels. It can also be improved further with frequency-dependent processing baked into the generated coefficients, incurring no extra run-time cost for it.
* Decode directly from B-Format to HRTF instead of a cubeChris Robinson2016-08-111-0/+76
| | | | | | | | | | | | | | | | | | | | | Last time this attempted to average the HRIRs according to their contribution to a given B-Format channel as if they were loudspeakers, as well as averaging the HRIR delays. The latter part resulted in the loss of the ITD (inter-aural time delay), a key component of HRTF. This time, the HRIRs are averaged similar to above, except instead of averaging the delays, they're applied to the resulting coefficients (for example, a delay of 8 would apply the HRIR starting at the 8th sample of the target HRIR). This does roughly double the IR length, as the largest delay is about 35 samples while the filter is normally 32 samples. However, this is still smaller the original data set IR (which was 256 samples), it also only needs to be applied to 4 channels for first-order ambisonics, rather than the 8-channel cube. So it's doing twice as much work per sample, but only working on half the number of samples. Additionally, since the resulting HRIRs no longer rely on an extra delay line, a more efficient HRTF mixing function can be made that doesn't use one. Such a function can also avoid the per-sample stepping parameters the original uses.
* Properly skip loading of already-loaded HRTF data setsChris Robinson2016-07-241-4/+24
| | | | | | | Previously, if an HRTF file was loaded it would not only skip loading it, but it would also skip adding it to the output enumeration list. Now it properly skips loading it when it's already loaded, but still adds it to the enumeration list if it's not already in it.
* Enumerate the embedded HRTF resources when availableChris Robinson2016-07-121-3/+345
|
* Avoid standard malloc/free for Hrtf allocationChris Robinson2016-07-071-3/+4
|
* Avoid function calls to get the HRTF sample rate and IR sizeChris Robinson2016-07-071-25/+0
|
* Improve radius behavior with scaling of ambisonic coefficientsChris Robinson2016-04-241-1/+4
|
* Shorten VECTOR_ITER_ macros to VECTOR_Chris Robinson2016-04-151-3/+3
|
* Add and use a copy-range string functionChris Robinson2016-02-241-4/+1
|
* Exclude the file extension from the HRTF nameChris Robinson2016-02-241-1/+9
|
* Replace the hrtf_tables option with hrtf-pathsChris Robinson2016-02-231-17/+32
|
* Allow selecting a preferred HRTF in alsoft-configChris Robinson2016-02-231-1/+1
| | | | This currently only checks the default paths when they're being used.
* Avoid enumerating the same HRTF file twiceChris Robinson2016-02-211-41/+40
|
* Add a config option to specify the preferred HRTFChris Robinson2016-02-211-0/+19
|
* Include the HRTF filename in the HRTF memory chunkChris Robinson2016-02-201-25/+25
|
* Use an 8-channel cube for HRTF's virtual format.Chris Robinson2016-02-201-102/+0
| | | | | | There were phase issues caused by applying HRTF directly to the B-Format channels, since the HRIR delays were all averaged which removed the inter-aural time-delay, which in turn removed significant spatial information.
* Allocate each HRTF as a single chunkChris Robinson2016-02-161-21/+39
|
* Calculate HRTF stepping params right before mixingChris Robinson2016-02-141-134/+0
| | | | | This means we track the current params and the target params, rather than the target params and the stepping. This closer matches the non-HRTF mixers.
* Don't pass the channel count to GetBFormatHrtfCoeffsChris Robinson2016-02-091-6/+4
| | | | Since it's hard-coded anyway, there's no need to specify it.
* Use %s.mhr for the default hrtf table listChris Robinson2015-12-051-1/+1
|
* Use more accurate floating point literalsChris Robinson2015-11-061-1/+1
|
* Remove a couple unused parametersChris Robinson2015-10-241-16/+4
|
* Use the enumerated HRTF list for selecting an HRTFChris Robinson2015-10-061-135/+4
| | | | Also report the proper specifier of the one currently in use.
* Store the Hrtf struct with the corresponding HrtfEntryChris Robinson2015-10-061-16/+81
| | | | | Also store the filename with the Hrtf struct so it can be reused for multiple HrtfEntry objects.
* Enumerate and list HRTFs per-deviceChris Robinson2015-10-061-0/+91
|
* Fix B-Format HRTF decodingChris Robinson2015-09-231-5/+8
|
* Use N3D scaling instead of FuMaChris Robinson2015-09-231-4/+4
|
* Allow the hrtf_tables option to be device-specificChris Robinson2015-09-201-8/+7
|
* Rename F_2PI to F_TAUChris Robinson2015-09-131-3/+3
|
* Allow for device-specific config valuesChris Robinson2015-08-281-2/+2
|
* Use ACN ordering for ambisonics coefficients arraysChris Robinson2015-08-281-3/+3
| | | | | | Note that it still uses FuMa scalings internally. Coefficients loaded from config files specify if they're FuMa (in both ordering and scaling) or N3D, and will get reordered or rescaled as needed.
* Fix the HRTF B-Format decoder's W coefficientChris Robinson2015-02-141-18/+5
| | | | | And limit it to first-order again, since there will likely need to be extra scalings applied.
* Calculate HRTF coefficients for all B-Format channels at onceChris Robinson2015-02-101-29/+61
| | | | | | It's possible to calculate HRTF coefficients for full third-order ambisonics now, but it's still not possible to use them here without upmixing first-order content.
* Pass the (FuMa) channel number to GetBFormatHrtfCoeffsChris Robinson2015-02-101-6/+7
|
* Correct conversion from polar to cartesian coords for HRTFChris Robinson2015-02-101-3/+3
| | | | | A functional no-op (cos(a) == cos(-a), -sin(a) == sin(-a)), but Ambisonics expects the azimuth angle to go counter-clockwise.
* Use B-Format for HRTF's virtual output formatChris Robinson2015-02-091-1/+83
| | | | | | | | This adds the ability to directly decode B-Format with HRTF, though only first- order (WXYZ) for now. Second- and third-order would be easilly doable, however we'd need to be able to up-mix first-order content (from the BFORMAT2D and BFORMAT3D buffer formats) since it would be inappropriate to decode lower-order content with a higher-order decoder.
* Make CalcHrtfDelta more genericChris Robinson2014-11-241-34/+1
|