Skip to content

[AUD-020][High] Pass sample period to the PSD simulator #315

Description

@gabrielsantosphilips

Audit finding

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

Problem

The PSD simulator passes total record duration inputSize / sampleRateHz as the PSD sampling interval. The numerical API expects one-sample period 1 / sampleRateHz.

Source:

{
template<std::size_t SegmentSize, std::size_t Overlap>
PsdResult ComputeForSizeAndOverlap(float sampleRateHz, std::size_t inputSize,
const std::vector<float>& signal, windowing::Window<float>& window)
{
using FFT = ::analysis::FastFourierTransformRadix2Impl<float, SegmentSize>;
using TwiddleFactors = utils::TwiddleFactorsTable<float, SegmentSize / 2>;
float samplingTime = static_cast<float>(inputSize) / sampleRateHz;
float frequencyResolution = sampleRateHz / static_cast<float>(SegmentSize);
::analysis::PowerSpectralDensity<float, SegmentSize, FFT, TwiddleFactors, Overlap> psd(window, samplingTime);
infra::BoundedVector<float>::WithMaxSize<4096> input;

The default 1,024-sample record inflates power density by 1,024, approximately 30.10 dB.

Acceptance criteria

  • Pass 1 / sampleRateHz to PowerSpectralDensity.
  • Verify frequency bins and integrated density against an independent signal-variance reference.
  • Test all supported segment sizes, overlaps, and windows using the real FFT path.

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