24 #include "Hrms-TDT-Reference.h" 35 HrmsTDTReference::HrmsTDTReference(Harmonics harmonics)
36 :_harmonics(harmonics)
40 void HrmsTDTReference::process(tdrt::FrequencySeries<float>& h_input,
41 std::vector<std::shared_ptr<tdrt::FrequencySeries<float>>>& h_output)
47 unsigned n_harmonics= _harmonics+1;
48 assert(h_output.size() >= n_harmonics);
50 size_t length = h_input.get_length();
51 float delta_f = h_input.get_delta_f();
53 for (std::vector<std::shared_ptr<tdrt::FrequencySeries<float>>>::const_iterator it = h_output.begin();
54 it!=h_output.end(); ++it)
56 assert ((*it)->get_length() == length);
57 assert ((*it)->get_delta_f() == delta_f);
63 const float Pmax = 9.9999;
64 size_t nf1 = 2 * length / (h_input.get_delta_f() * Pmax);
69 for (
unsigned fold= 0; fold <= _harmonics; ++fold)
71 float fval = 1 << fold;
72 size_t NFS = fval*nf1 - fval/2;
73 float xdiv = 1.0 / fval;
79 for (
size_t n = NFS; n < length; ++n)
81 h_output[fold]->get_data()[n] = 0.0;
82 long long last_idx = -1;
84 for (
unsigned m=0; m < fval; ++m)
86 float stretch_idx_float = n * m * xdiv + 0.5;
87 long long stretch_idx_int = (size_t) stretch_idx_float;
89 if ( stretch_idx_int > 1 && stretch_idx_int != last_idx)
91 h_output[fold]->get_data()[n] += h_input.get_data()[stretch_idx_int];
93 last_idx= stretch_idx_int;
100 void HrmsTDTReference::harmonics_train(
size_t period, tdrt::FrequencySeries<float>& h_harmonics_train_out)
102 assert(h_harmonics_train_out.get_length() > period * 10);
105 float* fsHarmonics = h_harmonics_train_out.get_data();
107 for(
size_t i = 0; i < h_harmonics_train_out.get_length(); ++i)
110 if(i % period == 0 && i <= 16 * period && i > 10)
Some limits and constants for FLDO.