Index: Source/modules/webaudio/AudioParamTimeline.cpp |
diff --git a/Source/modules/webaudio/AudioParamTimeline.cpp b/Source/modules/webaudio/AudioParamTimeline.cpp |
index 7482279a05b2498b21cbdcec0f28584a0b184bd8..a24a9cf705812b94f30ffb4a56f47e90cac73c93 100644 |
--- a/Source/modules/webaudio/AudioParamTimeline.cpp |
+++ b/Source/modules/webaudio/AudioParamTimeline.cpp |
@@ -349,6 +349,31 @@ float AudioParamTimeline::valuesForTimeRangeImpl( |
float timeConstant = event.timeConstant(); |
float discreteTimeConstant = static_cast<float>(AudioUtilities::discreteTimeConstantForSampleRate(timeConstant, controlRate)); |
+#if CPU(X86) || CPU(X86_64) |
+ // Necessary for unrolling.. |
Raymond Toy
2015/08/13 15:42:56
As in the other panner node CL, can you include a
adrian.belgun
2015/08/14 07:49:21
Done.
|
+ const float c0 = discreteTimeConstant; |
+ const float c1 = 2 * c0 - c0 * c0; |
+ const float c2 = 3 * c0 - 3 * c0 * c0 + c0 * c0 * c0; |
+ const float c3 = 4 * c0 - 6 * c0 * c0 + 4 * c0 * c0 * c0 - c0 * c0 * c0 * c0; |
Raymond Toy
2015/08/13 15:42:56
Would it help accuracy if the constants were compu
adrian.belgun
2015/08/14 07:49:21
Experimented also with doing the computations with
Raymond Toy
2015/08/14 16:00:03
You mean you computed the c's using doubles and al
adrian.belgun
2015/08/17 07:58:14
Yes, applied Horner's rule and for testing to make
Raymond Toy
2015/08/17 15:54:50
Interesting. Thanks for doing the tests.
I think
|
+ |
+ float delta; |
+ __m128 vC = _mm_set_ps(c2, c1, c0, 0); |
+ __m128 vDelta, vValue, vResult; |
+ |
+ // Process in batches of 4. |
+ unsigned fillToFrameTrunc = writeIndex + ((fillToFrame - writeIndex) / 4) * 4; |
+ for (; writeIndex < fillToFrameTrunc; writeIndex += 4) { |
+ delta = target - value; |
+ vDelta = _mm_set_ps1(delta); |
+ vValue = _mm_set_ps1(value); |
+ |
+ vResult = _mm_add_ps(vValue, _mm_mul_ps(vDelta, vC)); |
+ _mm_storeu_ps(values + writeIndex, vResult); |
+ |
+ value += delta * c3; |
+ } |
+#endif |
+ // Serially process remaining values |
for (; writeIndex < fillToFrame; ++writeIndex) { |
values[writeIndex] = value; |
value += (target - value) * discreteTimeConstant; |