tor-browser

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

echo_canceller_test_tools.h (1493B)


      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_PROCESSING_TEST_ECHO_CANCELLER_TEST_TOOLS_H_
     12 #define MODULES_AUDIO_PROCESSING_TEST_ECHO_CANCELLER_TEST_TOOLS_H_
     13 
     14 #include <cstddef>
     15 #include <vector>
     16 
     17 #include "api/array_view.h"
     18 #include "rtc_base/random.h"
     19 
     20 namespace webrtc {
     21 
     22 // Randomizes the elements in a vector with values -32767.f:32767.f.
     23 void RandomizeSampleVector(Random* random_generator, ArrayView<float> v);
     24 
     25 // Randomizes the elements in a vector with values -amplitude:amplitude.
     26 void RandomizeSampleVector(Random* random_generator,
     27                           ArrayView<float> v,
     28                           float amplitude);
     29 
     30 // Class for delaying a signal a fixed number of samples.
     31 template <typename T>
     32 class DelayBuffer {
     33 public:
     34  explicit DelayBuffer(size_t delay) : buffer_(delay) {}
     35  ~DelayBuffer() = default;
     36 
     37  // Produces a delayed signal copy of x.
     38  void Delay(ArrayView<const T> x, ArrayView<T> x_delayed);
     39 
     40 private:
     41  std::vector<T> buffer_;
     42  size_t next_insert_index_ = 0;
     43 };
     44 
     45 }  // namespace webrtc
     46 
     47 #endif  // MODULES_AUDIO_PROCESSING_TEST_ECHO_CANCELLER_TEST_TOOLS_H_