| 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 } else { | 159 } else { |
| 160 // Too bad - The tryLock() failed. We must be in the middle of changing the | 160 // Too bad - The tryLock() failed. We must be in the middle of changing the |
| 161 // properties of the panner or the listener. | 161 // properties of the panner or the listener. |
| 162 destination->zero(); | 162 destination->zero(); |
| 163 } | 163 } |
| 164 } | 164 } |
| 165 | 165 |
| 166 void PannerHandler::processSampleAccurateValues(AudioBus* destination, | 166 void PannerHandler::processSampleAccurateValues(AudioBus* destination, |
| 167 const AudioBus* source, | 167 const AudioBus* source, |
| 168 size_t framesToProcess) { | 168 size_t framesToProcess) { |
| 169 RELEASE_ASSERT(framesToProcess <= ProcessingSizeInFrames); | 169 RELEASE_ASSERT(framesToProcess <= AudioUtilities::kRenderQuantumFrames); |
| 170 | 170 |
| 171 // Get the sample accurate values from all of the AudioParams, including the | 171 // Get the sample accurate values from all of the AudioParams, including the |
| 172 // values from the AudioListener. | 172 // values from the AudioListener. |
| 173 float pannerX[ProcessingSizeInFrames]; | 173 float pannerX[AudioUtilities::kRenderQuantumFrames]; |
| 174 float pannerY[ProcessingSizeInFrames]; | 174 float pannerY[AudioUtilities::kRenderQuantumFrames]; |
| 175 float pannerZ[ProcessingSizeInFrames]; | 175 float pannerZ[AudioUtilities::kRenderQuantumFrames]; |
| 176 | 176 |
| 177 float orientationX[ProcessingSizeInFrames]; | 177 float orientationX[AudioUtilities::kRenderQuantumFrames]; |
| 178 float orientationY[ProcessingSizeInFrames]; | 178 float orientationY[AudioUtilities::kRenderQuantumFrames]; |
| 179 float orientationZ[ProcessingSizeInFrames]; | 179 float orientationZ[AudioUtilities::kRenderQuantumFrames]; |
| 180 | 180 |
| 181 m_positionX->calculateSampleAccurateValues(pannerX, framesToProcess); | 181 m_positionX->calculateSampleAccurateValues(pannerX, framesToProcess); |
| 182 m_positionY->calculateSampleAccurateValues(pannerY, framesToProcess); | 182 m_positionY->calculateSampleAccurateValues(pannerY, framesToProcess); |
| 183 m_positionZ->calculateSampleAccurateValues(pannerZ, framesToProcess); | 183 m_positionZ->calculateSampleAccurateValues(pannerZ, framesToProcess); |
| 184 m_orientationX->calculateSampleAccurateValues(orientationX, framesToProcess); | 184 m_orientationX->calculateSampleAccurateValues(orientationX, framesToProcess); |
| 185 m_orientationY->calculateSampleAccurateValues(orientationY, framesToProcess); | 185 m_orientationY->calculateSampleAccurateValues(orientationY, framesToProcess); |
| 186 m_orientationZ->calculateSampleAccurateValues(orientationZ, framesToProcess); | 186 m_orientationZ->calculateSampleAccurateValues(orientationZ, framesToProcess); |
| 187 | 187 |
| 188 // Get the automation values from the listener. | 188 // Get the automation values from the listener. |
| 189 const float* listenerX = | 189 const float* listenerX = |
| 190 listener()->getPositionXValues(ProcessingSizeInFrames); | 190 listener()->getPositionXValues(AudioUtilities::kRenderQuantumFrames); |
| 191 const float* listenerY = | 191 const float* listenerY = |
| 192 listener()->getPositionYValues(ProcessingSizeInFrames); | 192 listener()->getPositionYValues(AudioUtilities::kRenderQuantumFrames); |
| 193 const float* listenerZ = | 193 const float* listenerZ = |
| 194 listener()->getPositionZValues(ProcessingSizeInFrames); | 194 listener()->getPositionZValues(AudioUtilities::kRenderQuantumFrames); |
| 195 | 195 |
| 196 const float* forwardX = listener()->getForwardXValues(ProcessingSizeInFrames); | 196 const float* forwardX = |
| 197 const float* forwardY = listener()->getForwardYValues(ProcessingSizeInFrames); | 197 listener()->getForwardXValues(AudioUtilities::kRenderQuantumFrames); |
| 198 const float* forwardZ = listener()->getForwardZValues(ProcessingSizeInFrames); | 198 const float* forwardY = |
| 199 listener()->getForwardYValues(AudioUtilities::kRenderQuantumFrames); |
| 200 const float* forwardZ = |
| 201 listener()->getForwardZValues(AudioUtilities::kRenderQuantumFrames); |
| 199 | 202 |
| 200 const float* upX = listener()->getUpXValues(ProcessingSizeInFrames); | 203 const float* upX = |
| 201 const float* upY = listener()->getUpYValues(ProcessingSizeInFrames); | 204 listener()->getUpXValues(AudioUtilities::kRenderQuantumFrames); |
| 202 const float* upZ = listener()->getUpZValues(ProcessingSizeInFrames); | 205 const float* upY = |
| 206 listener()->getUpYValues(AudioUtilities::kRenderQuantumFrames); |
| 207 const float* upZ = |
| 208 listener()->getUpZValues(AudioUtilities::kRenderQuantumFrames); |
| 203 | 209 |
| 204 // Compute the azimuth, elevation, and total gains for each position. | 210 // Compute the azimuth, elevation, and total gains for each position. |
| 205 double azimuth[ProcessingSizeInFrames]; | 211 double azimuth[AudioUtilities::kRenderQuantumFrames]; |
| 206 double elevation[ProcessingSizeInFrames]; | 212 double elevation[AudioUtilities::kRenderQuantumFrames]; |
| 207 float totalGain[ProcessingSizeInFrames]; | 213 float totalGain[AudioUtilities::kRenderQuantumFrames]; |
| 208 | 214 |
| 209 for (unsigned k = 0; k < framesToProcess; ++k) { | 215 for (unsigned k = 0; k < framesToProcess; ++k) { |
| 210 FloatPoint3D pannerPosition(pannerX[k], pannerY[k], pannerZ[k]); | 216 FloatPoint3D pannerPosition(pannerX[k], pannerY[k], pannerZ[k]); |
| 211 FloatPoint3D orientation(orientationX[k], orientationY[k], orientationZ[k]); | 217 FloatPoint3D orientation(orientationX[k], orientationY[k], orientationZ[k]); |
| 212 FloatPoint3D listenerPosition(listenerX[k], listenerY[k], listenerZ[k]); | 218 FloatPoint3D listenerPosition(listenerX[k], listenerY[k], listenerZ[k]); |
| 213 FloatPoint3D listenerForward(forwardX[k], forwardY[k], forwardZ[k]); | 219 FloatPoint3D listenerForward(forwardX[k], forwardY[k], forwardZ[k]); |
| 214 FloatPoint3D listenerUp(upX[k], upY[k], upZ[k]); | 220 FloatPoint3D listenerUp(upX[k], upY[k], upZ[k]); |
| 215 | 221 |
| 216 calculateAzimuthElevation(&azimuth[k], &elevation[k], pannerPosition, | 222 calculateAzimuthElevation(&azimuth[k], &elevation[k], pannerPosition, |
| 217 listenerPosition, listenerForward, listenerUp); | 223 listenerPosition, listenerForward, listenerUp); |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 visitor->trace(m_positionZ); | 775 visitor->trace(m_positionZ); |
| 770 | 776 |
| 771 visitor->trace(m_orientationX); | 777 visitor->trace(m_orientationX); |
| 772 visitor->trace(m_orientationY); | 778 visitor->trace(m_orientationY); |
| 773 visitor->trace(m_orientationZ); | 779 visitor->trace(m_orientationZ); |
| 774 | 780 |
| 775 AudioNode::trace(visitor); | 781 AudioNode::trace(visitor); |
| 776 } | 782 } |
| 777 | 783 |
| 778 } // namespace blink | 784 } // namespace blink |
| OLD | NEW |