From 283067dea28c2082b71793706f582ce96e667370 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 5 Jan 2011 12:17:06 -0800 Subject: uhd: replaced templated ranges with one range thing using doubles only to avoid trouble with compiler portability --- host/lib/utils/gain_group.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'host/lib/utils') diff --git a/host/lib/utils/gain_group.cpp b/host/lib/utils/gain_group.cpp index 11bbb8c0a..cba5056ea 100644 --- a/host/lib/utils/gain_group.cpp +++ b/host/lib/utils/gain_group.cpp @@ -39,7 +39,7 @@ static bool compare_by_step_size( * Get a multiple of step with the following relation: * result = step*floor(num/step) * - * Due to small floating-point inaccuracies: + * Due to small gain_ting-point inaccuracies: * num = n*step + e, where e is a small inaccuracy. * When e is negative, floor would yeild (n-1)*step, * despite that n*step is really the desired result. @@ -66,7 +66,7 @@ public: gain_range_t get_range(const std::string &name){ if (not name.empty()) return _name_to_fcns[name].get_range(); - float overall_min = 0, overall_max = 0, overall_step = 0; + gain_t overall_min = 0, overall_max = 0, overall_step = 0; BOOST_FOREACH(const gain_fcns_t &fcns, get_all_fcns()){ const gain_range_t range = fcns.get_range(); overall_min += range.start(); @@ -78,33 +78,33 @@ public: return gain_range_t(overall_min, overall_max, overall_step); } - float get_value(const std::string &name){ + gain_t get_value(const std::string &name){ if (not name.empty()) return _name_to_fcns[name].get_value(); - float overall_gain = 0; + gain_t overall_gain = 0; BOOST_FOREACH(const gain_fcns_t &fcns, get_all_fcns()){ overall_gain += fcns.get_value(); } return overall_gain; } - void set_value(float gain, const std::string &name){ + void set_value(gain_t gain, const std::string &name){ if (not name.empty()) return _name_to_fcns[name].set_value(gain); std::vector all_fcns = get_all_fcns(); if (all_fcns.size() == 0) return; //nothing to set! //get the max step size among the gains - float max_step = 0; + gain_t max_step = 0; BOOST_FOREACH(const gain_fcns_t &fcns, all_fcns){ max_step = std::max(max_step, fcns.get_range().step()); } //create gain bucket to distribute power - std::vector gain_bucket; + std::vector gain_bucket; //distribute power according to priority (round to max step) - float gain_left_to_distribute = gain; + gain_t gain_left_to_distribute = gain; BOOST_FOREACH(const gain_fcns_t &fcns, all_fcns){ const gain_range_t range = fcns.get_range(); gain_bucket.push_back(floor_step(std::clip( @@ -131,7 +131,7 @@ public: //fill in the largest step sizes first that are less than the remainder BOOST_FOREACH(size_t i, indexes_step_size_dec){ const gain_range_t range = all_fcns.at(i).get_range(); - float additional_gain = floor_step(std::clip( + gain_t additional_gain = floor_step(std::clip( gain_bucket.at(i) + gain_left_to_distribute, range.start(), range.stop() ), range.step()) - gain_bucket.at(i); gain_bucket.at(i) += additional_gain; -- cgit v1.2.3