tor-browser

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

gain_change_calculator.h (1346B)


      1 /*
      2 *  Copyright (c) 2017 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 #ifndef MODULES_AUDIO_MIXER_GAIN_CHANGE_CALCULATOR_H_
     12 #define MODULES_AUDIO_MIXER_GAIN_CHANGE_CALCULATOR_H_
     13 
     14 #include <stdint.h>
     15 
     16 #include "api/array_view.h"
     17 
     18 namespace webrtc {
     19 
     20 class GainChangeCalculator {
     21 public:
     22  // The 'out' signal is assumed to be produced from 'in' by applying
     23  // a smoothly varying gain. This method computes variations of the
     24  // gain and handles special cases when the samples are small.
     25  float CalculateGainChange(ArrayView<const int16_t> in,
     26                            ArrayView<const int16_t> out);
     27 
     28  float LatestGain() const;
     29 
     30 private:
     31  void CalculateGain(ArrayView<const int16_t> in,
     32                     ArrayView<const int16_t> out,
     33                     ArrayView<float> gain);
     34 
     35  float CalculateDifferences(ArrayView<const float> values);
     36  float last_value_ = 0.f;
     37  float last_reliable_gain_ = 1.0f;
     38 };
     39 
     40 }  // namespace webrtc
     41 
     42 #endif  // MODULES_AUDIO_MIXER_GAIN_CHANGE_CALCULATOR_H_