| 33 | bool HRTFDatabase::sEnableNyquistCorrectionForPhaseInterpolation = false; |
| 34 | |
| 35 | HRTFDatabase::HRTFDatabase(const HRTFSettings& hrtfSettings, |
| 36 | int samplingRate, |
| 37 | int frameSize) |
| 38 | : mSamplingRate(samplingRate) |
| 39 | , mReferenceLoudness(0.0f) |
| 40 | , mHRTFMap(HRTFMapFactory::create(hrtfSettings, samplingRate)) |
| 41 | , mFFTInterpolation(mHRTFMap->numSamples()) |
| 42 | , mFFTAudioProcessing(frameSize + (frameSize / 4) + mHRTFMap->numSamples() - 1) |
| 43 | , mHRTF(IHRTFMap::kNumEars, numHRIRs(), mFFTAudioProcessing.numComplexSamples) |
| 44 | , mPeakDelay(IHRTFMap::kNumEars, numHRIRs()) |
| 45 | , mHRTFMagnitude(IHRTFMap::kNumEars, numHRIRs(), mFFTInterpolation.numComplexSamples) |
| 46 | , mHRTFPhase(IHRTFMap::kNumEars, numHRIRs(), mFFTInterpolation.numComplexSamples) |
| 47 | , mInterpolatedHRTFMagnitude(mFFTInterpolation.numComplexSamples) |
| 48 | , mInterpolatedHRTFPhase(mFFTInterpolation.numComplexSamples) |
| 49 | , mInterpolatedHRTF(IHRTFMap::kNumEars, mFFTInterpolation.numComplexSamples) |
| 50 | , mInterpolatedHRIR(IHRTFMap::kNumEars, mFFTAudioProcessing.numRealSamples) |
| 51 | , mAmbisonicsHRTF(IHRTFMap::kNumEars, SphericalHarmonics::numCoeffsForOrder(IHRTFMap::kMaxAmbisonicsOrder), mFFTAudioProcessing.numComplexSamples) |
| 52 | { |
| 53 | updateReferenceLoudness(hrtfSettings.normType); |
| 54 | applyVolumeSettings(hrtfSettings.volume, hrtfSettings.normType); |
| 55 | fourierTransformHRIRs(mHRTFMap->hrtfData(), mHRTF); |
| 56 | extractPeakDelays(); |
| 57 | decomposeToMagnitudePhase(mHRTFMap->hrtfData(), mHRTFMagnitude, mHRTFPhase); |
| 58 | |
| 59 | const auto& ambisonicsHRIR = mHRTFMap->ambisonicsData(); |
| 60 | if (ambisonicsHRIR.totalSize() == 0) |
| 61 | { |
| 62 | precomputeAmbisonicsHRTFs(samplingRate, frameSize); |
| 63 | } |
| 64 | else |
| 65 | { |
| 66 | fourierTransformHRIRs(ambisonicsHRIR, mAmbisonicsHRTF); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | void HRTFDatabase::getHRTFByIndex(int index, |
| 71 | const complex_t** hrtf) const |
nothing calls this directly
no test coverage detected