tor-browser

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

sinusoidal_linear_chirp_source.h (1969B)


      1 /*
      2 *  Copyright (c) 2013 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 // Modified from the Chromium original here:
     12 // src/media/base/sinc_resampler_unittest.cc
     13 
     14 #ifndef COMMON_AUDIO_RESAMPLER_SINUSOIDAL_LINEAR_CHIRP_SOURCE_H_
     15 #define COMMON_AUDIO_RESAMPLER_SINUSOIDAL_LINEAR_CHIRP_SOURCE_H_
     16 
     17 #include <cstddef>
     18 
     19 #include "common_audio/resampler/sinc_resampler.h"
     20 
     21 namespace webrtc {
     22 
     23 // Fake audio source for testing the resampler.  Generates a sinusoidal linear
     24 // chirp (http://en.wikipedia.org/wiki/Chirp) which can be tuned to stress the
     25 // resampler for the specific sample rate conversion being used.
     26 class SinusoidalLinearChirpSource : public SincResamplerCallback {
     27 public:
     28  // `delay_samples` can be used to insert a fractional sample delay into the
     29  // source.  It will produce zeros until non-negative time is reached.
     30  SinusoidalLinearChirpSource(int sample_rate,
     31                              size_t samples,
     32                              double max_frequency,
     33                              double delay_samples);
     34 
     35  ~SinusoidalLinearChirpSource() override {}
     36 
     37  SinusoidalLinearChirpSource(const SinusoidalLinearChirpSource&) = delete;
     38  SinusoidalLinearChirpSource& operator=(const SinusoidalLinearChirpSource&) =
     39      delete;
     40 
     41  void Run(size_t frames, float* destination) override;
     42 
     43  double Frequency(size_t position);
     44 
     45 private:
     46  static constexpr int kMinFrequency = 5;
     47 
     48  int sample_rate_;
     49  size_t total_samples_;
     50  double max_frequency_;
     51  double k_;
     52  size_t current_index_;
     53  double delay_samples_;
     54 };
     55 
     56 }  // namespace webrtc
     57 
     58 #endif  // COMMON_AUDIO_RESAMPLER_SINUSOIDAL_LINEAR_CHIRP_SOURCE_H_