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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 DEFINE_STATIC_LOCAL(AudioBusMap, audioBusMap, ()); | 67 DEFINE_STATIC_LOCAL(AudioBusMap, audioBusMap, ()); |
68 DEFINE_STATIC_LOCAL(Mutex, mutex, ()); | 68 DEFINE_STATIC_LOCAL(Mutex, mutex, ()); |
69 | 69 |
70 MutexLocker locker(mutex); | 70 MutexLocker locker(mutex); |
71 RefPtr<AudioBus> bus; | 71 RefPtr<AudioBus> bus; |
72 AudioBusMap::iterator iterator = audioBusMap.find(subjectName); | 72 AudioBusMap::iterator iterator = audioBusMap.find(subjectName); |
73 if (iterator == audioBusMap.end()) { | 73 if (iterator == audioBusMap.end()) { |
74 RefPtr<AudioBus> concatenatedImpulseResponses(AudioBus::loadPlatformReso
urce(subjectName.utf8().data(), ResponseSampleRate)); | 74 RefPtr<AudioBus> concatenatedImpulseResponses(AudioBus::loadPlatformReso
urce(subjectName.utf8().data(), ResponseSampleRate)); |
75 ASSERT(concatenatedImpulseResponses); | 75 ASSERT(concatenatedImpulseResponses); |
76 if (!concatenatedImpulseResponses) | 76 if (!concatenatedImpulseResponses) |
77 return 0; | 77 return nullptr; |
78 | 78 |
79 bus = concatenatedImpulseResponses; | 79 bus = concatenatedImpulseResponses; |
80 audioBusMap.set(subjectName, bus); | 80 audioBusMap.set(subjectName, bus); |
81 } else | 81 } else |
82 bus = iterator->value; | 82 bus = iterator->value; |
83 | 83 |
84 size_t responseLength = bus->length(); | 84 size_t responseLength = bus->length(); |
85 size_t expectedLength = static_cast<size_t>(TotalNumberOfResponses * Respons
eFrameSize); | 85 size_t expectedLength = static_cast<size_t>(TotalNumberOfResponses * Respons
eFrameSize); |
86 | 86 |
87 // Check number of channels and length. For now these are fixed and known. | 87 // Check number of channels and length. For now these are fixed and known. |
88 bool isBusGood = responseLength == expectedLength && bus->numberOfChannels()
== 2; | 88 bool isBusGood = responseLength == expectedLength && bus->numberOfChannels()
== 2; |
89 ASSERT(isBusGood); | 89 ASSERT(isBusGood); |
90 if (!isBusGood) | 90 if (!isBusGood) |
91 return 0; | 91 return nullptr; |
92 | 92 |
93 return bus; | 93 return bus; |
94 } | 94 } |
95 #endif | 95 #endif |
96 | 96 |
97 // Takes advantage of the symmetry and creates a composite version of the two me
asured versions. For example, we have both azimuth 30 and -30 degrees | 97 // Takes advantage of the symmetry and creates a composite version of the two me
asured versions. For example, we have both azimuth 30 and -30 degrees |
98 // where the roles of left and right ears are reversed with respect to each othe
r. | 98 // where the roles of left and right ears are reversed with respect to each othe
r. |
99 bool HRTFElevation::calculateSymmetricKernelsForAzimuthElevation(int azimuth, in
t elevation, float sampleRate, const String& subjectName, | 99 bool HRTFElevation::calculateSymmetricKernelsForAzimuthElevation(int azimuth, in
t elevation, float sampleRate, const String& subjectName, |
100 RefPtr<HRTFKern
el>& kernelL, RefPtr<HRTFKernel>& kernelR) | 100 RefPtr<HRTFKern
el>& kernelL, RefPtr<HRTFKernel>& kernelR) |
101 { | 101 { |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 double frameDelay2R = m_kernelListR->at(azimuthIndex2)->frameDelay(); | 333 double frameDelay2R = m_kernelListR->at(azimuthIndex2)->frameDelay(); |
334 | 334 |
335 // Linearly interpolate delays. | 335 // Linearly interpolate delays. |
336 frameDelayL = (1.0 - azimuthBlend) * frameDelayL + azimuthBlend * frameDelay
2L; | 336 frameDelayL = (1.0 - azimuthBlend) * frameDelayL + azimuthBlend * frameDelay
2L; |
337 frameDelayR = (1.0 - azimuthBlend) * frameDelayR + azimuthBlend * frameDelay
2R; | 337 frameDelayR = (1.0 - azimuthBlend) * frameDelayR + azimuthBlend * frameDelay
2R; |
338 } | 338 } |
339 | 339 |
340 } // namespace WebCore | 340 } // namespace WebCore |
341 | 341 |
342 #endif // ENABLE(WEB_AUDIO) | 342 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |