tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

reverb_model.cc (1572B)


      1 /*
      2 *  Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
      3 *
      4 *  Use of this source code is governed by a BSD-style license
      5 *  that can be found in the LICENSE file in the root of the source
      6 *  tree. An additional intellectual property rights grant can be found
      7 *  in the file PATENTS.  All contributing project authors may
      8 *  be found in the AUTHORS file in the root of the source tree.
      9 */
     10 
     11 #include "modules/audio_processing/aec3/reverb_model.h"
     12 
     13 #include <cstddef>
     14 
     15 #include "api/array_view.h"
     16 
     17 namespace webrtc {
     18 
     19 ReverbModel::ReverbModel() {
     20  Reset();
     21 }
     22 
     23 ReverbModel::~ReverbModel() = default;
     24 
     25 void ReverbModel::Reset() {
     26  reverb_.fill(0.);
     27 }
     28 
     29 void ReverbModel::UpdateReverbNoFreqShaping(
     30    ArrayView<const float> power_spectrum,
     31    float power_spectrum_scaling,
     32    float reverb_decay) {
     33  if (reverb_decay > 0) {
     34    // Update the estimate of the reverberant power.
     35    for (size_t k = 0; k < power_spectrum.size(); ++k) {
     36      reverb_[k] = (reverb_[k] + power_spectrum[k] * power_spectrum_scaling) *
     37                   reverb_decay;
     38    }
     39  }
     40 }
     41 
     42 void ReverbModel::UpdateReverb(ArrayView<const float> power_spectrum,
     43                               ArrayView<const float> power_spectrum_scaling,
     44                               float reverb_decay) {
     45  if (reverb_decay > 0) {
     46    // Update the estimate of the reverberant power.
     47    for (size_t k = 0; k < power_spectrum.size(); ++k) {
     48      reverb_[k] =
     49          (reverb_[k] + power_spectrum[k] * power_spectrum_scaling[k]) *
     50          reverb_decay;
     51    }
     52  }
     53 }
     54 
     55 }  // namespace webrtc