| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "config.h" | 29 #include "config.h" |
| 30 | 30 |
| 31 #if ENABLE(WEB_AUDIO) | 31 #if ENABLE(WEB_AUDIO) |
| 32 | 32 |
| 33 #include "platform/audio/HRTFElevation.h" | 33 #include "platform/audio/HRTFElevation.h" |
| 34 | 34 |
| 35 #include <math.h> | |
| 36 #include <algorithm> | |
| 37 #include "platform/audio/AudioBus.h" | 35 #include "platform/audio/AudioBus.h" |
| 38 #include "platform/audio/HRTFPanner.h" | 36 #include "platform/audio/AudioUtilities.h" |
| 37 #include "platform/audio/HRTFDatabase.h" |
| 39 #include "wtf/ThreadingPrimitives.h" | 38 #include "wtf/ThreadingPrimitives.h" |
| 40 #include "wtf/text/StringHash.h" | 39 #include "wtf/text/StringHash.h" |
| 41 | 40 |
| 41 #include <algorithm> |
| 42 #include <math.h> |
| 43 |
| 42 namespace blink { | 44 namespace blink { |
| 43 | 45 |
| 44 const unsigned HRTFElevation::AzimuthSpacing = 15; | 46 const unsigned HRTFElevation::AzimuthSpacing = 15; |
| 45 const unsigned HRTFElevation::NumberOfRawAzimuths = 360 / AzimuthSpacing; | 47 const unsigned HRTFElevation::NumberOfRawAzimuths = 360 / AzimuthSpacing; |
| 46 const unsigned HRTFElevation::InterpolationFactor = 8; | 48 const unsigned HRTFElevation::InterpolationFactor = 8; |
| 47 const unsigned HRTFElevation::NumberOfTotalAzimuths = NumberOfRawAzimuths * Inte
rpolationFactor; | 49 const unsigned HRTFElevation::NumberOfTotalAzimuths = NumberOfRawAzimuths * Inte
rpolationFactor; |
| 48 | 50 |
| 49 // Total number of components of an HRTF database. | 51 // Total number of components of an HRTF database. |
| 50 const size_t TotalNumberOfResponses = 240; | 52 const size_t TotalNumberOfResponses = 240; |
| 51 | 53 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 bool isBusGood = responseLength == expectedLength && impulseResponse->number
OfChannels() == 2; | 161 bool isBusGood = responseLength == expectedLength && impulseResponse->number
OfChannels() == 2; |
| 160 ASSERT(isBusGood); | 162 ASSERT(isBusGood); |
| 161 if (!isBusGood) | 163 if (!isBusGood) |
| 162 return false; | 164 return false; |
| 163 | 165 |
| 164 AudioChannel* leftEarImpulseResponse = impulseResponse->channelByType(AudioB
us::ChannelLeft); | 166 AudioChannel* leftEarImpulseResponse = impulseResponse->channelByType(AudioB
us::ChannelLeft); |
| 165 AudioChannel* rightEarImpulseResponse = impulseResponse->channelByType(Audio
Bus::ChannelRight); | 167 AudioChannel* rightEarImpulseResponse = impulseResponse->channelByType(Audio
Bus::ChannelRight); |
| 166 #endif | 168 #endif |
| 167 | 169 |
| 168 // Note that depending on the fftSize returned by the panner, we may be trun
cating the impulse response we just loaded in. | 170 // Note that depending on the fftSize returned by the panner, we may be trun
cating the impulse response we just loaded in. |
| 169 const size_t fftSize = HRTFPanner::fftSizeForSampleRate(sampleRate); | 171 const size_t fftSize = AudioUtilities::fftSizeForSampleRate(sampleRate); |
| 170 kernelL = HRTFKernel::create(leftEarImpulseResponse, fftSize, sampleRate); | 172 kernelL = HRTFKernel::create(leftEarImpulseResponse, fftSize, sampleRate); |
| 171 kernelR = HRTFKernel::create(rightEarImpulseResponse, fftSize, sampleRate); | 173 kernelR = HRTFKernel::create(rightEarImpulseResponse, fftSize, sampleRate); |
| 172 | 174 |
| 173 return true; | 175 return true; |
| 174 } | 176 } |
| 175 | 177 |
| 176 // The range of elevations for the IRCAM impulse responses varies depending on a
zimuth, but the minimum elevation appears to always be -45. | 178 // The range of elevations for the IRCAM impulse responses varies depending on a
zimuth, but the minimum elevation appears to always be -45. |
| 177 // | 179 // |
| 178 // Here's how it goes: | 180 // Here's how it goes: |
| 179 static int maxElevations[] = { | 181 static int maxElevations[] = { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 double frameDelay2R = m_kernelListR->at(azimuthIndex2)->frameDelay(); | 306 double frameDelay2R = m_kernelListR->at(azimuthIndex2)->frameDelay(); |
| 305 | 307 |
| 306 // Linearly interpolate delays. | 308 // Linearly interpolate delays. |
| 307 frameDelayL = (1.0 - azimuthBlend) * frameDelayL + azimuthBlend * frameDelay
2L; | 309 frameDelayL = (1.0 - azimuthBlend) * frameDelayL + azimuthBlend * frameDelay
2L; |
| 308 frameDelayR = (1.0 - azimuthBlend) * frameDelayR + azimuthBlend * frameDelay
2R; | 310 frameDelayR = (1.0 - azimuthBlend) * frameDelayR + azimuthBlend * frameDelay
2R; |
| 309 } | 311 } |
| 310 | 312 |
| 311 } // namespace blink | 313 } // namespace blink |
| 312 | 314 |
| 313 #endif // ENABLE(WEB_AUDIO) | 315 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |