| 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 16 matching lines...) Expand all Loading... |
| 27 #include "wtf/MathExtras.h" | 27 #include "wtf/MathExtras.h" |
| 28 #include <algorithm> | 28 #include <algorithm> |
| 29 | 29 |
| 30 namespace blink { | 30 namespace blink { |
| 31 | 31 |
| 32 const float SmoothingTimeConstant = 0.020f; // 20ms | 32 const float SmoothingTimeConstant = 0.020f; // 20ms |
| 33 | 33 |
| 34 DelayDSPKernel::DelayDSPKernel(DelayProcessor* processor) | 34 DelayDSPKernel::DelayDSPKernel(DelayProcessor* processor) |
| 35 : AudioDelayDSPKernel(processor, AudioHandler::ProcessingSizeInFrames) | 35 : AudioDelayDSPKernel(processor, AudioHandler::ProcessingSizeInFrames) |
| 36 { | 36 { |
| 37 ASSERT(processor); | 37 DCHECK(processor); |
| 38 ASSERT(processor->sampleRate() > 0); | 38 DCHECK_GT(processor->sampleRate(), 0); |
| 39 if (!(processor && processor->sampleRate() > 0)) | 39 if (!(processor && processor->sampleRate() > 0)) |
| 40 return; | 40 return; |
| 41 | 41 |
| 42 m_maxDelayTime = processor->maxDelayTime(); | 42 m_maxDelayTime = processor->maxDelayTime(); |
| 43 ASSERT(m_maxDelayTime >= 0); | 43 DCHECK_GE(m_maxDelayTime, 0); |
| 44 ASSERT(!std::isnan(m_maxDelayTime)); | 44 DCHECK(!std::isnan(m_maxDelayTime)); |
| 45 if (m_maxDelayTime < 0 || std::isnan(m_maxDelayTime)) | 45 if (m_maxDelayTime < 0 || std::isnan(m_maxDelayTime)) |
| 46 return; | 46 return; |
| 47 | 47 |
| 48 m_buffer.allocate(bufferLengthForDelay(m_maxDelayTime, processor->sampleRate
())); | 48 m_buffer.allocate(bufferLengthForDelay(m_maxDelayTime, processor->sampleRate
())); |
| 49 m_buffer.zero(); | 49 m_buffer.zero(); |
| 50 | 50 |
| 51 m_smoothingRate = AudioUtilities::discreteTimeConstantForSampleRate(Smoothin
gTimeConstant, processor->sampleRate()); | 51 m_smoothingRate = AudioUtilities::discreteTimeConstantForSampleRate(Smoothin
gTimeConstant, processor->sampleRate()); |
| 52 } | 52 } |
| 53 | 53 |
| 54 bool DelayDSPKernel::hasSampleAccurateValues() | 54 bool DelayDSPKernel::hasSampleAccurateValues() |
| 55 { | 55 { |
| 56 return getDelayProcessor()->delayTime().hasSampleAccurateValues(); | 56 return getDelayProcessor()->delayTime().hasSampleAccurateValues(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void DelayDSPKernel::calculateSampleAccurateValues(float* delayTimes, size_t fra
mesToProcess) | 59 void DelayDSPKernel::calculateSampleAccurateValues(float* delayTimes, size_t fra
mesToProcess) |
| 60 { | 60 { |
| 61 getDelayProcessor()->delayTime().calculateSampleAccurateValues(delayTimes, f
ramesToProcess); | 61 getDelayProcessor()->delayTime().calculateSampleAccurateValues(delayTimes, f
ramesToProcess); |
| 62 } | 62 } |
| 63 | 63 |
| 64 double DelayDSPKernel::delayTime(float) | 64 double DelayDSPKernel::delayTime(float) |
| 65 { | 65 { |
| 66 return getDelayProcessor()->delayTime().finalValue(); | 66 return getDelayProcessor()->delayTime().finalValue(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace blink | 69 } // namespace blink |
| 70 | 70 |
| OLD | NEW |