| 329 | } |
| 330 | |
| 331 | std::unique_ptr<HRTFElevation> HRTFElevation::createForSubject(HRTFDatabaseInfo * info, int elevation) |
| 332 | { |
| 333 | bool isElevationGood = elevation >= -45 && elevation <= 90 && (elevation / 15) * 15 == elevation; |
| 334 | ASSERT(isElevationGood); |
| 335 | |
| 336 | if (!isElevationGood) |
| 337 | return nullptr; |
| 338 | |
| 339 | std::unique_ptr<HRTFKernelList> kernelListL = std::unique_ptr<HRTFKernelList>(new HRTFKernelList(NumberOfTotalAzimuths)); |
| 340 | std::unique_ptr<HRTFKernelList> kernelListR = std::unique_ptr<HRTFKernelList>(new HRTFKernelList(NumberOfTotalAzimuths)); |
| 341 | |
| 342 | // Load convolution kernels from HRTF files. |
| 343 | int interpolatedIndex = 0; |
| 344 | for (uint32_t rawIndex = 0; rawIndex < NumberOfRawAzimuths; ++rawIndex) |
| 345 | { |
| 346 | // Don't let elevation exceed maximum for this azimuth. |
| 347 | int maxElevation = maxElevations[rawIndex]; |
| 348 | int actualElevation = min(elevation, maxElevation); |
| 349 | |
| 350 | bool success = calculateKernelsForAzimuthElevation( |
| 351 | info, |
| 352 | rawIndex * AzimuthSpacing, |
| 353 | actualElevation, kernelListL->at(interpolatedIndex), |
| 354 | kernelListR->at(interpolatedIndex)); |
| 355 | |
| 356 | if (!success) |
| 357 | return nullptr; |
| 358 | |
| 359 | interpolatedIndex += InterpolationFactor; |
| 360 | } |
| 361 | |
| 362 | // Now go back and interpolate intermediate azimuth values. |
| 363 | for (uint32_t i = 0; i < NumberOfTotalAzimuths; i += InterpolationFactor) |
| 364 | { |
| 365 | int j = (i + InterpolationFactor) % NumberOfTotalAzimuths; |
| 366 | |
| 367 | // Create the interpolated convolution kernels and delays. |
| 368 | for (uint32_t jj = 1; jj < InterpolationFactor; ++jj) |
| 369 | { |
| 370 | float x = float(jj) / float(InterpolationFactor); // interpolate from 0 -> 1 |
| 371 | |
| 372 | (*kernelListL)[i + jj] = MakeInterpolatedKernel(kernelListL->at(i).get(), kernelListL->at(j).get(), x); |
| 373 | (*kernelListR)[i + jj] = MakeInterpolatedKernel(kernelListR->at(i).get(), kernelListR->at(j).get(), x); |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | return std::unique_ptr<HRTFElevation>(new HRTFElevation(info, std::move(kernelListL), std::move(kernelListR), elevation)); |
| 378 | } |
| 379 | |
| 380 | std::unique_ptr<HRTFElevation> HRTFElevation::createByInterpolatingSlices(HRTFDatabaseInfo * info, HRTFElevation * hrtfElevation1, HRTFElevation * hrtfElevation2, float x) |
| 381 | { |
nothing calls this directly
no test coverage detected