aboutsummaryrefslogtreecommitdiffstats
path: root/utils/makemhr
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-12-08 17:56:56 -0800
committerChris Robinson <[email protected]>2019-12-08 17:56:56 -0800
commit5942974d471abb7ed0d5ea1975e2e96050093b37 (patch)
treecc665e13b6812ccd14790c33b0be57787a1f9de3 /utils/makemhr
parent8076fd8aa94e3f5421610ed72415280515070f5c (diff)
Report the non-uniform elevations in sofa-info
Diffstat (limited to 'utils/makemhr')
-rw-r--r--utils/makemhr/loadsofa.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/utils/makemhr/loadsofa.cpp b/utils/makemhr/loadsofa.cpp
index 1dc64522..00dbf8f9 100644
--- a/utils/makemhr/loadsofa.cpp
+++ b/utils/makemhr/loadsofa.cpp
@@ -136,13 +136,20 @@ static double GetUniformAzimStep(const double epsilon, const std::vector<double>
* can uniformly cover the list. Ideally this will be over half, but in
* degenerate cases this can fall to a minimum of 5 (the lower limit).
*/
-static double GetUniformElevStep(const double epsilon, const std::vector<double> &elems)
+static double GetUniformElevStep(const double epsilon, std::vector<double> &elems)
{
if(elems.size() < 5) return 0.0;
+ /* Reverse the elevations so it increments starting with -90 (flipped from
+ * +90). This makes it easier to work out a proper stepping value.
+ */
+ std::reverse(elems.begin(), elems.end());
+ for(auto &v : elems) v *= -1.0;
+
uint count{static_cast<uint>(std::ceil(180.0 / (elems[1]-elems[0])))};
- count = std::min(count, uint{MAX_EV_COUNT}-1u);
+ count = std::min(count, uint{MAX_EV_COUNT-1u});
+ double ret{0.0};
for(;count >= 5;--count)
{
const double step{180.0 / count};
@@ -159,9 +166,16 @@ static double GetUniformElevStep(const double epsilon, const std::vector<double>
good &= !(idx < elems.size()) || !(std::abs(target-elems[idx++]) > epsilon);
}
if(good)
- return step;
+ {
+ ret = step;
+ break;
+ }
}
- return 0.0;
+ /* Re-reverse the elevations to restore the correct order. */
+ for(auto &v : elems) v *= -1.0;
+ std::reverse(elems.begin(), elems.end());
+
+ return ret;
}
/* Attempts to produce a compatible layout. Most data sets tend to be
@@ -219,12 +233,6 @@ static bool PrepareLayout(const uint m, const float *xyzs, HrirDataT *hData)
};
elevs.erase(std::remove_if(elevs.begin(), elevs.end(), invalid_elev), elevs.end());
- /* Reverse the elevations so it increments starting with -90 (flipped
- * from +90). This makes it easier to work out a proper stepping value.
- */
- std::reverse(elevs.begin(), elevs.end());
- for(auto &ev : elevs) ev *= -1.0;
-
double step{GetUniformElevStep(0.1, elevs)};
if(step <= 0.0)
{
@@ -234,10 +242,6 @@ static bool PrepareLayout(const uint m, const float *xyzs, HrirDataT *hData)
continue;
}
- /* Re-reverse the elevations to restore the correct order. */
- for(auto &ev : elevs) ev *= -1.0;
- std::reverse(elevs.begin(), elevs.end());
-
uint evStart{0u};
for(uint ei{0u};ei < elevs.size();ei++)
{