Skip to content

[AUD-021][High] Correct FIR simulator band-pass construction #319

Description

@gabrielsantosphilips

Audit finding

  • ID: AUD-021
  • Status: Verified defect
  • Severity: High
  • Confidence: High
  • Audited revision: 2f479320d805a1f9f35ebe4afaaeeded48913a94

Problem

The FIR simulator converts the low-cutoff low-pass kernel into a high-pass kernel, then computes LP(high) - HP(low). At DC this is approximately one, but a band-pass response must be zero. The spectral subtraction should be LP(high) - LP(low).

Source:

lowpass[mid] += 1.0f;
return lowpass;
}
case FilterType::BandPass:
{
auto normalizedLow = design.cutoffHz / design.sampleRateHz;
auto normalizedHigh = design.cutoffHighHz / design.sampleRateHz;
auto highpass = WindowedSinc(design.order, normalizedHigh);
auto lowpass = WindowedSinc(design.order, normalizedLow);
auto mid = (design.order - 1) / 2;
for (std::size_t i = 0; i < lowpass.size(); ++i)
lowpass[i] = -lowpass[i];
lowpass[mid] += 1.0f;
std::vector<float> bandpass(design.order);
for (std::size_t i = 0; i < design.order; ++i)
bandpass[i] = highpass[i] - lowpass[i];
return bandpass;
}
default:
return WindowedSinc(design.order, normalizedCutoff);

Acceptance criteria

  • Construct the band-pass from two low-pass prototypes with correct cutoff ordering.
  • DC and Nyquist response are attenuated; center-band response matches an independent reference.
  • Reject invalid cutoff ordering and cutoff above Nyquist.
  • Add simulator-domain coefficient and response tests.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions