Skip to content

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

Description

@LucaBianco

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions