Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
freq_estimator.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Roc authors
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
8 
9 //! @file roc_audio/freq_estimator.h
10 //! @brief Frequency estimator.
11 
12 #ifndef ROC_AUDIO_FREQ_ESTIMATOR_H_
13 #define ROC_AUDIO_FREQ_ESTIMATOR_H_
14 
16 #include "roc_audio/units.h"
17 #include "roc_core/noncopyable.h"
18 #include "roc_packet/units.h"
19 
20 namespace roc {
21 namespace audio {
22 
23 //! Evaluates sender's frequency to receivers's frequency ratio.
24 class FreqEstimator : public core::NonCopyable<> {
25 public:
26  //! Initialize.
27  //!
28  //! @b Parameters
29  //! - @p target_latency defines latency we want to archive.
30  explicit FreqEstimator(packet::timestamp_t target_latency);
31 
32  //! Get current frequecy coefficient.
33  float freq_coeff() const;
34 
35  //! Compute new value of frequency coefficient.
36  void update(packet::timestamp_t current_latency);
37 
38 private:
39  bool run_decimators_(packet::timestamp_t current, float& filtered);
40  float run_controller_(float current);
41 
42  const float target_; // Target latency.
43 
44  float dec1_casc_buff_[fe_decim_len];
45  size_t dec1_ind_;
46 
47  float dec2_casc_buff_[fe_decim_len];
48  size_t dec2_ind_;
49 
50  size_t samples_counter_; // Input samples counter.
51  float accum_; // Integrator value.
52 
53  float coeff_; // Current frequency coefficient value.
54 };
55 
56 } // namespace audio
57 } // namespace roc
58 
59 #endif // ROC_AUDIO_FREQ_ESTIMATOR_H_
Evaluates sender&#39;s frequency to receivers&#39;s frequency ratio.
FreqEstimator(packet::timestamp_t target_latency)
Initialize.
Various units used in audio processing.
void update(packet::timestamp_t current_latency)
Compute new value of frequency coefficient.
Root namespace.
float freq_coeff() const
Get current frequecy coefficient.
uint32_t timestamp_t
Audio packet timestamp.
Definition: units.h:46
Base class for non-copyable objects.
Definition: noncopyable.h:23
Various units used in packets.
Non-copyable object.
Frequency estimator config.