| 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 14 matching lines...) Expand all Loading... |
| 25 #include "config.h" | 25 #include "config.h" |
| 26 | 26 |
| 27 #if ENABLE(WEB_AUDIO) | 27 #if ENABLE(WEB_AUDIO) |
| 28 | 28 |
| 29 #include "platform/audio/AudioDelayDSPKernel.h" | 29 #include "platform/audio/AudioDelayDSPKernel.h" |
| 30 | 30 |
| 31 #include "platform/audio/AudioUtilities.h" | 31 #include "platform/audio/AudioUtilities.h" |
| 32 #include "wtf/MathExtras.h" | 32 #include "wtf/MathExtras.h" |
| 33 #include <algorithm> | 33 #include <algorithm> |
| 34 | 34 |
| 35 using namespace std; | |
| 36 | |
| 37 namespace blink { | 35 namespace blink { |
| 38 | 36 |
| 39 const float SmoothingTimeConstant = 0.020f; // 20ms | 37 const float SmoothingTimeConstant = 0.020f; // 20ms |
| 40 | 38 |
| 41 AudioDelayDSPKernel::AudioDelayDSPKernel(AudioDSPKernelProcessor* processor, siz
e_t processingSizeInFrames) | 39 AudioDelayDSPKernel::AudioDelayDSPKernel(AudioDSPKernelProcessor* processor, siz
e_t processingSizeInFrames) |
| 42 : AudioDSPKernel(processor) | 40 : AudioDSPKernel(processor) |
| 43 , m_writeIndex(0) | 41 , m_writeIndex(0) |
| 44 , m_firstTime(true) | 42 , m_firstTime(true) |
| 45 , m_delayTimes(processingSizeInFrames) | 43 , m_delayTimes(processingSizeInFrames) |
| 46 { | 44 { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 double maxTime = maxDelayTime(); | 106 double maxTime = maxDelayTime(); |
| 109 | 107 |
| 110 bool sampleAccurate = hasSampleAccurateValues(); | 108 bool sampleAccurate = hasSampleAccurateValues(); |
| 111 | 109 |
| 112 if (sampleAccurate) { | 110 if (sampleAccurate) { |
| 113 calculateSampleAccurateValues(delayTimes, framesToProcess); | 111 calculateSampleAccurateValues(delayTimes, framesToProcess); |
| 114 } else { | 112 } else { |
| 115 delayTime = this->delayTime(sampleRate); | 113 delayTime = this->delayTime(sampleRate); |
| 116 | 114 |
| 117 // Make sure the delay time is in a valid range. | 115 // Make sure the delay time is in a valid range. |
| 118 delayTime = min(maxTime, delayTime); | 116 delayTime = std::min(maxTime, delayTime); |
| 119 delayTime = max(0.0, delayTime); | 117 delayTime = std::max(0.0, delayTime); |
| 120 | 118 |
| 121 if (m_firstTime) { | 119 if (m_firstTime) { |
| 122 m_currentDelayTime = delayTime; | 120 m_currentDelayTime = delayTime; |
| 123 m_firstTime = false; | 121 m_firstTime = false; |
| 124 } | 122 } |
| 125 } | 123 } |
| 126 | 124 |
| 127 for (unsigned i = 0; i < framesToProcess; ++i) { | 125 for (unsigned i = 0; i < framesToProcess; ++i) { |
| 128 if (sampleAccurate) { | 126 if (sampleAccurate) { |
| 129 delayTime = delayTimes[i]; | 127 delayTime = delayTimes[i]; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 } | 171 } |
| 174 | 172 |
| 175 double AudioDelayDSPKernel::latencyTime() const | 173 double AudioDelayDSPKernel::latencyTime() const |
| 176 { | 174 { |
| 177 return 0; | 175 return 0; |
| 178 } | 176 } |
| 179 | 177 |
| 180 } // namespace blink | 178 } // namespace blink |
| 181 | 179 |
| 182 #endif // ENABLE(WEB_AUDIO) | 180 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |