| Index: Source/core/platform/audio/HRTFElevation.cpp
|
| diff --git a/Source/core/platform/audio/HRTFElevation.cpp b/Source/core/platform/audio/HRTFElevation.cpp
|
| index 998f6043a564a9b2fd5dc09da38a19842ef60454..a37e696f50ed6ec52fd056bb615d41d7667a572b 100644
|
| --- a/Source/core/platform/audio/HRTFElevation.cpp
|
| +++ b/Source/core/platform/audio/HRTFElevation.cpp
|
| @@ -39,7 +39,7 @@
|
| #include "wtf/OwnPtr.h"
|
|
|
| using namespace std;
|
| -
|
| +
|
| namespace WebCore {
|
|
|
| const unsigned HRTFElevation::AzimuthSpacing = 15;
|
| @@ -101,20 +101,20 @@ bool HRTFElevation::calculateSymmetricKernelsForAzimuthElevation(int azimuth, in
|
| bool success = calculateKernelsForAzimuthElevation(azimuth, elevation, sampleRate, subjectName, kernelL1, kernelR1);
|
| if (!success)
|
| return false;
|
| -
|
| +
|
| // And symmetric version
|
| int symmetricAzimuth = !azimuth ? 0 : 360 - azimuth;
|
| -
|
| +
|
| RefPtr<HRTFKernel> kernelL2;
|
| RefPtr<HRTFKernel> kernelR2;
|
| success = calculateKernelsForAzimuthElevation(symmetricAzimuth, elevation, sampleRate, subjectName, kernelL2, kernelR2);
|
| if (!success)
|
| return false;
|
| -
|
| +
|
| // Notice L/R reversal in symmetric version.
|
| kernelL = HRTFKernel::createInterpolatedKernel(kernelL1.get(), kernelR2.get(), 0.5f);
|
| kernelR = HRTFKernel::createInterpolatedKernel(kernelR1.get(), kernelL2.get(), 0.5f);
|
| -
|
| +
|
| return true;
|
| }
|
|
|
| @@ -133,7 +133,7 @@ bool HRTFElevation::calculateKernelsForAzimuthElevation(int azimuth, int elevati
|
| ASSERT(isElevationGood);
|
| if (!isElevationGood)
|
| return false;
|
| -
|
| +
|
| // Construct the resource name from the subject name, azimuth, and elevation, for example:
|
| // "IRC_Composite_C_R0195_T015_P000"
|
| // Note: the passed in subjectName is not a string passed in via JavaScript or the web.
|
| @@ -177,7 +177,7 @@ bool HRTFElevation::calculateKernelsForAzimuthElevation(int azimuth, int elevati
|
| ASSERT(impulseResponse.get());
|
| if (!impulseResponse.get())
|
| return false;
|
| -
|
| +
|
| size_t responseLength = impulseResponse->length();
|
| size_t expectedLength = static_cast<size_t>(256 * (sampleRate / 44100.0));
|
|
|
| @@ -186,7 +186,7 @@ bool HRTFElevation::calculateKernelsForAzimuthElevation(int azimuth, int elevati
|
| ASSERT(isBusGood);
|
| if (!isBusGood)
|
| return false;
|
| -
|
| +
|
| AudioChannel* leftEarImpulseResponse = impulseResponse->channelByType(AudioBus::ChannelLeft);
|
| AudioChannel* rightEarImpulseResponse = impulseResponse->channelByType(AudioBus::ChannelRight);
|
| #endif
|
| @@ -195,7 +195,7 @@ bool HRTFElevation::calculateKernelsForAzimuthElevation(int azimuth, int elevati
|
| const size_t fftSize = HRTFPanner::fftSizeForSampleRate(sampleRate);
|
| kernelL = HRTFKernel::create(leftEarImpulseResponse, fftSize, sampleRate);
|
| kernelR = HRTFKernel::create(rightEarImpulseResponse, fftSize, sampleRate);
|
| -
|
| +
|
| return true;
|
| }
|
|
|
| @@ -205,30 +205,30 @@ bool HRTFElevation::calculateKernelsForAzimuthElevation(int azimuth, int elevati
|
| static int maxElevations[] = {
|
| // Azimuth
|
| //
|
| - 90, // 0
|
| - 45, // 15
|
| - 60, // 30
|
| - 45, // 45
|
| - 75, // 60
|
| - 45, // 75
|
| - 60, // 90
|
| - 45, // 105
|
| - 75, // 120
|
| - 45, // 135
|
| - 60, // 150
|
| - 45, // 165
|
| - 75, // 180
|
| - 45, // 195
|
| - 60, // 210
|
| - 45, // 225
|
| - 75, // 240
|
| - 45, // 255
|
| - 60, // 270
|
| - 45, // 285
|
| - 75, // 300
|
| - 45, // 315
|
| - 60, // 330
|
| - 45 // 345
|
| + 90, // 0
|
| + 45, // 15
|
| + 60, // 30
|
| + 45, // 45
|
| + 75, // 60
|
| + 45, // 75
|
| + 60, // 90
|
| + 45, // 105
|
| + 75, // 120
|
| + 45, // 135
|
| + 60, // 150
|
| + 45, // 165
|
| + 75, // 180
|
| + 45, // 195
|
| + 60, // 210
|
| + 45, // 225
|
| + 75, // 240
|
| + 45, // 255
|
| + 60, // 270
|
| + 45, // 285
|
| + 75, // 300
|
| + 45, // 315
|
| + 60, // 330
|
| + 45 // 345
|
| };
|
|
|
| PassOwnPtr<HRTFElevation> HRTFElevation::createForSubject(const String& subjectName, int elevation, float sampleRate)
|
| @@ -237,7 +237,7 @@ PassOwnPtr<HRTFElevation> HRTFElevation::createForSubject(const String& subjectN
|
| ASSERT(isElevationGood);
|
| if (!isElevationGood)
|
| return nullptr;
|
| -
|
| +
|
| OwnPtr<HRTFKernelList> kernelListL = adoptPtr(new HRTFKernelList(NumberOfTotalAzimuths));
|
| OwnPtr<HRTFKernelList> kernelListR = adoptPtr(new HRTFKernelList(NumberOfTotalAzimuths));
|
|
|
| @@ -251,7 +251,7 @@ PassOwnPtr<HRTFElevation> HRTFElevation::createForSubject(const String& subjectN
|
| bool success = calculateKernelsForAzimuthElevation(rawIndex * AzimuthSpacing, actualElevation, sampleRate, subjectName, kernelListL->at(interpolatedIndex), kernelListR->at(interpolatedIndex));
|
| if (!success)
|
| return nullptr;
|
| -
|
| +
|
| interpolatedIndex += InterpolationFactor;
|
| }
|
|
|
| @@ -267,7 +267,7 @@ PassOwnPtr<HRTFElevation> HRTFElevation::createForSubject(const String& subjectN
|
| (*kernelListR)[i + jj] = HRTFKernel::createInterpolatedKernel(kernelListR->at(i).get(), kernelListR->at(j).get(), x);
|
| }
|
| }
|
| -
|
| +
|
| OwnPtr<HRTFElevation> hrtfElevation = adoptPtr(new HRTFElevation(kernelListL.release(), kernelListR.release(), elevation, sampleRate));
|
| return hrtfElevation.release();
|
| }
|
| @@ -277,9 +277,9 @@ PassOwnPtr<HRTFElevation> HRTFElevation::createByInterpolatingSlices(HRTFElevati
|
| ASSERT(hrtfElevation1 && hrtfElevation2);
|
| if (!hrtfElevation1 || !hrtfElevation2)
|
| return nullptr;
|
| -
|
| +
|
| ASSERT(x >= 0.0 && x < 1.0);
|
| -
|
| +
|
| OwnPtr<HRTFKernelList> kernelListL = adoptPtr(new HRTFKernelList(NumberOfTotalAzimuths));
|
| OwnPtr<HRTFKernelList> kernelListR = adoptPtr(new HRTFKernelList(NumberOfTotalAzimuths));
|
|
|
| @@ -287,7 +287,7 @@ PassOwnPtr<HRTFElevation> HRTFElevation::createByInterpolatingSlices(HRTFElevati
|
| HRTFKernelList* kernelListR1 = hrtfElevation1->kernelListR();
|
| HRTFKernelList* kernelListL2 = hrtfElevation2->kernelListL();
|
| HRTFKernelList* kernelListR2 = hrtfElevation2->kernelListR();
|
| -
|
| +
|
| // Interpolate kernels of corresponding azimuths of the two elevations.
|
| for (unsigned i = 0; i < NumberOfTotalAzimuths; ++i) {
|
| (*kernelListL)[i] = HRTFKernel::createInterpolatedKernel(kernelListL1->at(i).get(), kernelListL2->at(i).get(), x);
|
| @@ -296,9 +296,9 @@ PassOwnPtr<HRTFElevation> HRTFElevation::createByInterpolatingSlices(HRTFElevati
|
|
|
| // Interpolate elevation angle.
|
| double angle = (1.0 - x) * hrtfElevation1->elevationAngle() + x * hrtfElevation2->elevationAngle();
|
| -
|
| +
|
| OwnPtr<HRTFElevation> hrtfElevation = adoptPtr(new HRTFElevation(kernelListL.release(), kernelListR.release(), static_cast<int>(angle), sampleRate));
|
| - return hrtfElevation.release();
|
| + return hrtfElevation.release();
|
| }
|
|
|
| void HRTFElevation::getKernelsFromAzimuth(double azimuthBlend, unsigned azimuthIndex, HRTFKernel* &kernelL, HRTFKernel* &kernelR, double& frameDelayL, double& frameDelayR)
|
| @@ -307,7 +307,7 @@ void HRTFElevation::getKernelsFromAzimuth(double azimuthBlend, unsigned azimuthI
|
| ASSERT(checkAzimuthBlend);
|
| if (!checkAzimuthBlend)
|
| azimuthBlend = 0.0;
|
| -
|
| +
|
| unsigned numKernels = m_kernelListL->size();
|
|
|
| bool isIndexGood = azimuthIndex < numKernels;
|
| @@ -317,7 +317,7 @@ void HRTFElevation::getKernelsFromAzimuth(double azimuthBlend, unsigned azimuthI
|
| kernelR = 0;
|
| return;
|
| }
|
| -
|
| +
|
| // Return the left and right kernels.
|
| kernelL = m_kernelListL->at(azimuthIndex).get();
|
| kernelR = m_kernelListR->at(azimuthIndex).get();
|
|
|