Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 342 | 342 |
| 343 case ParamEvent::SetTarget: | 343 case ParamEvent::SetTarget: |
| 344 { | 344 { |
| 345 currentTime = fillToTime; | 345 currentTime = fillToTime; |
| 346 | 346 |
| 347 // Exponential approach to target value with given time cons tant. | 347 // Exponential approach to target value with given time cons tant. |
| 348 float target = event.value(); | 348 float target = event.value(); |
| 349 float timeConstant = event.timeConstant(); | 349 float timeConstant = event.timeConstant(); |
| 350 float discreteTimeConstant = static_cast<float>(AudioUtiliti es::discreteTimeConstantForSampleRate(timeConstant, controlRate)); | 350 float discreteTimeConstant = static_cast<float>(AudioUtiliti es::discreteTimeConstantForSampleRate(timeConstant, controlRate)); |
| 351 | 351 |
| 352 #if CPU(X86) || CPU(X86_64) | |
| 353 // 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.
| |
| 354 const float c0 = discreteTimeConstant; | |
| 355 const float c1 = 2 * c0 - c0 * c0; | |
| 356 const float c2 = 3 * c0 - 3 * c0 * c0 + c0 * c0 * c0; | |
| 357 const float c3 = 4 * c0 - 6 * c0 * c0 + 4 * c0 * c0 * c0 - c 0 * 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
| |
| 358 | |
| 359 float delta; | |
| 360 __m128 vC = _mm_set_ps(c2, c1, c0, 0); | |
| 361 __m128 vDelta, vValue, vResult; | |
| 362 | |
| 363 // Process in batches of 4. | |
| 364 unsigned fillToFrameTrunc = writeIndex + ((fillToFrame - wri teIndex) / 4) * 4; | |
| 365 for (; writeIndex < fillToFrameTrunc; writeIndex += 4) { | |
| 366 delta = target - value; | |
| 367 vDelta = _mm_set_ps1(delta); | |
| 368 vValue = _mm_set_ps1(value); | |
| 369 | |
| 370 vResult = _mm_add_ps(vValue, _mm_mul_ps(vDelta, vC)); | |
| 371 _mm_storeu_ps(values + writeIndex, vResult); | |
| 372 | |
| 373 value += delta * c3; | |
| 374 } | |
| 375 #endif | |
| 376 // Serially process remaining values | |
| 352 for (; writeIndex < fillToFrame; ++writeIndex) { | 377 for (; writeIndex < fillToFrame; ++writeIndex) { |
| 353 values[writeIndex] = value; | 378 values[writeIndex] = value; |
| 354 value += (target - value) * discreteTimeConstant; | 379 value += (target - value) * discreteTimeConstant; |
| 355 } | 380 } |
| 356 | 381 |
| 357 break; | 382 break; |
| 358 } | 383 } |
| 359 | 384 |
| 360 case ParamEvent::SetValueCurve: | 385 case ParamEvent::SetValueCurve: |
| 361 { | 386 { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 458 // to the end of the values buffer. | 483 // to the end of the values buffer. |
| 459 for (; writeIndex < numberOfValues; ++writeIndex) | 484 for (; writeIndex < numberOfValues; ++writeIndex) |
| 460 values[writeIndex] = value; | 485 values[writeIndex] = value; |
| 461 | 486 |
| 462 return value; | 487 return value; |
| 463 } | 488 } |
| 464 | 489 |
| 465 } // namespace blink | 490 } // namespace blink |
| 466 | 491 |
| 467 #endif // ENABLE(WEB_AUDIO) | 492 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |