Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIRWinSyncDesign, Filter data Exports Broken for some countries/systems #8

Open
LucaBianco opened this issue Apr 14, 2021 · 0 comments

Comments

@LucaBianco
Copy link

Hello, I found that Coefficients, Time Domain and Frequency Domain Data exports are broken for FIRWinSyncDesign.

Problem:
In some countries, a comma "," is used instead of the dot "." as a decimal separator, so the exported list of coefficients is unusable:

float coeff[] = {0,0005084f,0,0008706f,0,0000000f,-0,0011129f,-0,0008133f,0,0009761f, [...] -0,0008133f,-0,0011129f,0,0000000f,0,0008706f};

The problem is in frmMain.cs.

Floats are converted to string like in this example:
data[2] = "float coeff[] = {" + windowedImpulseResponse[0].ToString("F7") + "f";

float.ToString() Converts a float to string, but when executed on different systems the output can be different, for example:

  • 1.2321
  • 1,2321

Suggested Solution:
What I did to fix this little inconvenence was to define the culture of the conversion ("en-US", that uses "." as decimal separator):
CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");

and then convert all the floats to string specifying the culture to be used, for example:
data[2] = "float coeff[] = {" + windowedImpulseResponse[0].ToString("F7", culture) + "f";

By doing this, the resulting export is as expected:

float coeff[] = {0.0005084f,0.0008706f,0.0000000f,-0.0011129f,-0.0008133f,0.0009761f, [...] -0.0008133f,-0.0011129f,0.0000000f,0.0008706f};

P.S.:
Thanks for sharing these projects and for the very very clear explanations in the videos.
I am not very familiar with git, so I opened this issue instead of contributing directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant