Takes the input AudioChannel as an input impulse response and calculates the average group delay. This represents the initial delay before the most energetic part of the impulse response. The sample-frame delay is removed from the impulseP impulse response, and this value is returned. the length of the passed in AudioChannel must be a power of 2.
| 449 | // The sample-frame delay is removed from the impulseP impulse response, and this value is returned. |
| 450 | // the length of the passed in AudioChannel must be a power of 2. |
| 451 | inline float ExtractAverageGroupDelay(AudioChannel * channel, int analysisFFTSize) |
| 452 | { |
| 453 | ASSERT(channel); |
| 454 | |
| 455 | float * impulseP = channel->mutableData(); |
| 456 | |
| 457 | bool isSizeGood = channel->length() >= analysisFFTSize; |
| 458 | ASSERT(isSizeGood); |
| 459 | if (!isSizeGood) |
| 460 | return 0; |
| 461 | |
| 462 | // Check for power-of-2. |
| 463 | ASSERT(uint64_t(1) << static_cast<uint64_t>(log2(analysisFFTSize)) == analysisFFTSize); |
| 464 | |
| 465 | FFTFrame estimationFrame(analysisFFTSize); |
| 466 | estimationFrame.computeForwardFFT(impulseP); |
| 467 | |
| 468 | float frameDelay = static_cast<float>(estimationFrame.extractAverageGroupDelay()); |
| 469 | estimationFrame.computeInverseFFT(impulseP); |
| 470 | |
| 471 | return frameDelay; |
| 472 | } |
| 473 | |
| 474 | HRTFKernel::HRTFKernel(AudioChannel * channel, int fftSize, float sampleRate) |
| 475 | : m_frameDelay(0) |
no test coverage detected