| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 m_meteringReleaseK = static_cast<float>(discreteTimeConstantForSampleRate( | 66 m_meteringReleaseK = static_cast<float>(discreteTimeConstantForSampleRate( |
| 67 meteringReleaseTimeConstant, sampleRate)); | 67 meteringReleaseTimeConstant, sampleRate)); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void DynamicsCompressorKernel::setNumberOfChannels(unsigned numberOfChannels) { | 70 void DynamicsCompressorKernel::setNumberOfChannels(unsigned numberOfChannels) { |
| 71 if (m_preDelayBuffers.size() == numberOfChannels) | 71 if (m_preDelayBuffers.size() == numberOfChannels) |
| 72 return; | 72 return; |
| 73 | 73 |
| 74 m_preDelayBuffers.clear(); | 74 m_preDelayBuffers.clear(); |
| 75 for (unsigned i = 0; i < numberOfChannels; ++i) | 75 for (unsigned i = 0; i < numberOfChannels; ++i) { |
| 76 m_preDelayBuffers.append(makeUnique<AudioFloatArray>(MaxPreDelayFrames)); | 76 m_preDelayBuffers.append( |
| 77 WTF::makeUnique<AudioFloatArray>(MaxPreDelayFrames)); |
| 78 } |
| 77 } | 79 } |
| 78 | 80 |
| 79 void DynamicsCompressorKernel::setPreDelayTime(float preDelayTime) { | 81 void DynamicsCompressorKernel::setPreDelayTime(float preDelayTime) { |
| 80 // Re-configure look-ahead section pre-delay if delay time has changed. | 82 // Re-configure look-ahead section pre-delay if delay time has changed. |
| 81 unsigned preDelayFrames = preDelayTime * sampleRate(); | 83 unsigned preDelayFrames = preDelayTime * sampleRate(); |
| 82 if (preDelayFrames > MaxPreDelayFrames - 1) | 84 if (preDelayFrames > MaxPreDelayFrames - 1) |
| 83 preDelayFrames = MaxPreDelayFrames - 1; | 85 preDelayFrames = MaxPreDelayFrames - 1; |
| 84 | 86 |
| 85 if (m_lastPreDelayFrames != preDelayFrames) { | 87 if (m_lastPreDelayFrames != preDelayFrames) { |
| 86 m_lastPreDelayFrames = preDelayFrames; | 88 m_lastPreDelayFrames = preDelayFrames; |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 for (unsigned i = 0; i < m_preDelayBuffers.size(); ++i) | 481 for (unsigned i = 0; i < m_preDelayBuffers.size(); ++i) |
| 480 m_preDelayBuffers[i]->zero(); | 482 m_preDelayBuffers[i]->zero(); |
| 481 | 483 |
| 482 m_preDelayReadIndex = 0; | 484 m_preDelayReadIndex = 0; |
| 483 m_preDelayWriteIndex = DefaultPreDelayFrames; | 485 m_preDelayWriteIndex = DefaultPreDelayFrames; |
| 484 | 486 |
| 485 m_maxAttackCompressionDiffDb = -1; // uninitialized state | 487 m_maxAttackCompressionDiffDb = -1; // uninitialized state |
| 486 } | 488 } |
| 487 | 489 |
| 488 } // namespace blink | 490 } // namespace blink |
| OLD | NEW |