MCPcopy Create free account
hub / github.com/LabSound/LabSound / ExtractAverageGroupDelay

Function ExtractAverageGroupDelay

src/internal/src/HRTFPanner.cpp:451–472  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

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.
451inline 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
474HRTFKernel::HRTFKernel(AudioChannel * channel, int fftSize, float sampleRate)
475 : m_frameDelay(0)

Callers 1

HRTFKernelMethod · 0.85

Calls 5

mutableDataMethod · 0.80
lengthMethod · 0.45
computeForwardFFTMethod · 0.45
computeInverseFFTMethod · 0.45

Tested by

no test coverage detected