summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-04-19 20:49:26 +0200
committerCarl Hetherington <cth@carlh.net>2020-04-20 00:31:10 +0200
commitde23b8be00d6987928b25bfdab461f249676f7c8 (patch)
treec3fd4c9693c4e214b818839fa0e6f3b3114e2b1d /src
parent6eda04c4d3f7f5ef3e2c47e3988dca01a01365f9 (diff)
Tidy log/lin conversion functions.
Diffstat (limited to 'src')
-rw-r--r--src/leqm-nrt.cc30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/leqm-nrt.cc b/src/leqm-nrt.cc
index 500fff3..136b722 100644
--- a/src/leqm-nrt.cc
+++ b/src/leqm-nrt.cc
@@ -231,9 +231,8 @@ private:
void equalinterval2(double const freqsamples[], double const * freqresp, std::vector<double>& eqfreqsamples, std::vector<double>& eqfreqresp, int points, int samplingfreq, int origpoints, int bitdepthsoundfile);
-void convloglin(std::vector<double> const& in, std::vector<double>& out, int points);
-double convlinlog_single(double in);
-double convloglin_single(double in);
+std::vector<double> convert_log_to_linear(std::vector<double> const& in);
+double convert_log_to_linear_single(double in);
double inputcalib (double dbdiffch);
std::vector<double> inversefft2(std::vector<double> const& eqfreqresp, int npoints);
@@ -310,13 +309,13 @@ Result calculate_function(
//postprocessing parameters
if (static_cast<int>(channel_corrections.size()) == channels) {
for (auto i: channel_corrections) {
- channel_conf_cal.push_back(convloglin_single(i));
+ channel_conf_cal.push_back(convert_log_to_linear_single(i));
}
} else if (channel_corrections.empty() && channels == 6) {
double conf51[] = {0, 0, 0, 0, -3, -3};
for (auto cind = 0; cind < channels; cind++) {
- channel_conf_cal.push_back(convloglin_single(conf51[cind]));
+ channel_conf_cal.push_back(convert_log_to_linear_single(conf51[cind]));
}
} else {
return {-100};
@@ -337,10 +336,9 @@ Result calculate_function(
std::vector<double> eqfreqresp_db(number_of_filter_interpolation_points);
std::vector<double> eqfreqsamples(number_of_filter_interpolation_points);
- std::vector<double> eqfreqresp(number_of_filter_interpolation_points);
equalinterval2(freqsamples, freqresp_db, eqfreqsamples, eqfreqresp_db, number_of_filter_interpolation_points, sample_rate, origpoints, bits_per_sample);
- convloglin(eqfreqresp_db, eqfreqresp, number_of_filter_interpolation_points);
+ auto eqfreqresp = convert_log_to_linear(eqfreqresp_db);
#ifdef DEBUG
for (int i=0; i < number_of_filter_interpolation_points; i++) {
@@ -438,22 +436,22 @@ void equalinterval2(double const freqsamples[], double const freqresp_db[], std:
}
-void convloglin(std::vector<double> const& in, std::vector<double>& out, int points) {
- for (int i = 0; i < points; i++) {
- out[i] = powf(10, (in[i]/20.0));
+std::vector<double> convert_log_to_linear(std::vector<double> const& in)
+{
+ std::vector<double> out(in.size());
+ for (auto i = 0U; i < in.size(); i++) {
+ out[i] = powf(10, in[i] / 20.0);
}
+ return out;
}
-double convlinlog_single(double in) {
- return log(in) * 20.0f;
-}
-
-
-double convloglin_single(double in) {
+double convert_log_to_linear_single(double in)
+{
return powf(10, in / 20.0f);
}
+
std::vector<double> inversefft2(std::vector<double> const& eqfreqresp, int npoints)
{
std::vector<double> ir(npoints * 2);