Skip to content

Commit

Permalink
ZamHeadX2: Fix mapping of FIR filter selection
Browse files Browse the repository at this point in the history
Fixes #98 - array indices swapped.

The array indices weren't actually swapped, but
the ranges were defined incorrectly resulting in only
some of the filters being used, rather than filter
coefficients being mixed up/corrupted.
  • Loading branch information
zamaudio committed Oct 27, 2023
1 parent 856349c commit 5dd4b19
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions plugins/ZamHeadX2/ZamHeadX2Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ void ZamHeadX2Plugin::initParameter(uint32_t index, Parameter& parameter)
parameter.symbol = "az";
parameter.unit = " ";
parameter.ranges.def = 0.0f;
parameter.ranges.min = -90.0f;
parameter.ranges.max = 270.0f;
parameter.ranges.min = -120.0f;
parameter.ranges.max = 120.0f;
break;
case paramElevation:
parameter.name = "Elevation";
parameter.symbol = "elev";
parameter.unit = " ";
parameter.ranges.def = 0.0f;
parameter.ranges.min = -45.0f;
parameter.ranges.min = -30.0f;
parameter.ranges.max = 90.0f;
break;
case paramWidth:
Expand Down Expand Up @@ -181,13 +181,12 @@ void ZamHeadX2Plugin::reload()
int az = 0;
int el = 0;

el = (int)((elevation + 45.) * 24. / 135.);
if (el >= 24) el = 24;
el = (int)((elevation + 30.) * 49. / 120.);
if (el >= 49) el = 49;
if (el < 0) el = 0;
az = (int)((azimuth + 90.) * 49. / 360.);
if (az >= 49) az = 49;
az = (int)((azimuth + 120.) * 24. / 240.);
if (az >= 24) az = 24;
if (az < 0) az = 0;
if (az > 24) az = 49 - az;
snprintf(elev, 3, "%d", el);
snprintf(azim, 3, "%d", az);
if ((az != azold) || (el != elold)) {
Expand Down

0 comments on commit 5dd4b19

Please sign in to comment.