| 35 | |
| 36 | |
| 37 | HRTFDatabase::HRTFDatabase(float sampleRate, const std::string & searchPath) |
| 38 | { |
| 39 | info.reset(new HRTFDatabaseInfo("Composite", searchPath, sampleRate)); |
| 40 | |
| 41 | m_elevations.resize(info->numTotalElevations); |
| 42 | |
| 43 | int elevationIndex = 0; |
| 44 | for (int elevation = info->minElevation; elevation <= info->maxElevation; elevation += info->rawElevationAngleSpacing) |
| 45 | { |
| 46 | std::unique_ptr<HRTFElevation> hrtfElevation = HRTFElevation::createForSubject(info.get(), elevation); |
| 47 | |
| 48 | // @tofix - removed ASSERT(hrtfElevation.get()); |
| 49 | if (!hrtfElevation.get()) return; |
| 50 | |
| 51 | m_elevations[elevationIndex] = std::move(hrtfElevation); |
| 52 | elevationIndex += info->interpolationFactor; |
| 53 | } |
| 54 | |
| 55 | // Go back and interpolate elevations |
| 56 | if (info->interpolationFactor > 1) |
| 57 | { |
| 58 | for (int i = 0; i < info->numTotalElevations; i += info->interpolationFactor) |
| 59 | { |
| 60 | int j = (i + info->interpolationFactor); |
| 61 | |
| 62 | if (j >= info->numTotalElevations) |
| 63 | { |
| 64 | j = i; // for last elevation interpolate with itself |
| 65 | } |
| 66 | |
| 67 | // Create the interpolated convolution kernels and delays. |
| 68 | for (int jj = 1; jj < info->interpolationFactor; ++jj) |
| 69 | { |
| 70 | float x = static_cast<float>(jj) / static_cast<float>(info->interpolationFactor); |
| 71 | m_elevations[i + jj] = HRTFElevation::createByInterpolatingSlices(info.get(), m_elevations[i].get(), m_elevations[j].get(), x); |
| 72 | ASSERT(m_elevations[i + jj].get()); |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | void HRTFDatabase::getKernelsFromAzimuthElevation(double azimuthBlend, |
| 79 | unsigned azimuthIndex, |