Chromium Code Reviews| Index: Source/modules/webaudio/PannerNode.cpp |
| diff --git a/Source/modules/webaudio/PannerNode.cpp b/Source/modules/webaudio/PannerNode.cpp |
| index fc68098c736097510a1ebdd9c60b0867799f6bd5..0b283414284decc71a586054cd8468f488f9615b 100644 |
| --- a/Source/modules/webaudio/PannerNode.cpp |
| +++ b/Source/modules/webaudio/PannerNode.cpp |
| @@ -386,9 +386,10 @@ void PannerNode::calculateAzimuthElevation(double* outAzimuth, double* outElevat |
| FloatPoint3D sourceListener = m_position - listenerPosition; |
| if (sourceListener.isZero()) { |
|
KhNo
2014/05/28 13:57:20
How do you think if we remove line from 388 to 394
Raymond Toy
2014/05/28 17:19:16
I think sourceListener.normalize() will fail (retu
Raymond Toy
2014/05/28 18:25:26
Oh, wait. normalize() does nothing if the length
Raymond Toy
2014/05/29 18:22:13
This is ok. The special case is removed.
|
| - // degenerate case if source and listener are at the same point |
| - *outAzimuth = 0.0; |
| - *outElevation = 0.0; |
| + // Degenerate case if source and listener are at the same point. To preserve continuity, |
|
Ken Russell (switch to Gerrit)
2014/05/27 23:24:43
Comparing against zero seems fragile. You're the e
Raymond Toy
2014/05/28 17:17:22
I think this is ok here. If it's not zero, sourceL
|
| + // don't change anything; just use the cached values. |
| + *outAzimuth = m_cachedAzimuth; |
| + *outElevation = m_cachedElevation; |
| return; |
| } |
| @@ -461,24 +462,30 @@ double PannerNode::calculateDopplerRate() |
| double sourceListenerMagnitude = sourceToListener.length(); |
| - double listenerProjection = sourceToListener.dot(listenerVelocity) / sourceListenerMagnitude; |
| - double sourceProjection = sourceToListener.dot(sourceVelocity) / sourceListenerMagnitude; |
| + if (!sourceListenerMagnitude) { |
|
Ken Russell (switch to Gerrit)
2014/05/27 23:24:43
Same comment here.
Raymond Toy
2014/05/28 17:17:22
I believe this is ok here too. It's only a proble
|
| + // Source and listener are at the same position. Skip the computation of the doppler |
| + // shift, and just return the cached value. |
| + dopplerShift = m_cachedDopplerRate; |
| + } else { |
| + double listenerProjection = sourceToListener.dot(listenerVelocity) / sourceListenerMagnitude; |
| + double sourceProjection = sourceToListener.dot(sourceVelocity) / sourceListenerMagnitude; |
| - listenerProjection = -listenerProjection; |
| - sourceProjection = -sourceProjection; |
| + listenerProjection = -listenerProjection; |
| + sourceProjection = -sourceProjection; |
| - double scaledSpeedOfSound = speedOfSound / dopplerFactor; |
| - listenerProjection = min(listenerProjection, scaledSpeedOfSound); |
| - sourceProjection = min(sourceProjection, scaledSpeedOfSound); |
| + double scaledSpeedOfSound = speedOfSound / dopplerFactor; |
| + listenerProjection = min(listenerProjection, scaledSpeedOfSound); |
| + sourceProjection = min(sourceProjection, scaledSpeedOfSound); |
| - dopplerShift = ((speedOfSound - dopplerFactor * listenerProjection) / (speedOfSound - dopplerFactor * sourceProjection)); |
| - fixNANs(dopplerShift); // avoid illegal values |
| + dopplerShift = ((speedOfSound - dopplerFactor * listenerProjection) / (speedOfSound - dopplerFactor * sourceProjection)); |
| + fixNANs(dopplerShift); // avoid illegal values |
| - // Limit the pitch shifting to 4 octaves up and 3 octaves down. |
| - if (dopplerShift > 16.0) |
| - dopplerShift = 16.0; |
| - else if (dopplerShift < 0.125) |
| - dopplerShift = 0.125; |
| + // Limit the pitch shifting to 4 octaves up and 3 octaves down. |
| + if (dopplerShift > 16.0) |
| + dopplerShift = 16.0; |
| + else if (dopplerShift < 0.125) |
| + dopplerShift = 0.125; |
| + } |
| } |
| } |