Skip to content

Bind sdr::AutomaticGainControl #122

Description

@Ravenwater

Bind sw::dsp::sdr::AutomaticGainControl — the level-regulating loop that
belongs upstream of every other synchronization block.

Upstream source: include/sw/dsp/sdr/agc.hpp (closes upstream #100).
Upstream tests: tests/test_sdr_agc.cpp.

Surface

  • enum class LevelDetector { magnitude, rms }
  • AgcConfig<T>reference_level, attack_time_s, decay_time_s,
    averaging_time_s, sample_rate_hz, min_gain_db, max_gain_db,
    initial_gain_db, detector
  • AutomaticGainControl<StateScalar, SampleScalar>process(sample),
    block process(vector), reset(), set_gain_db(db), gain_db(),
    invariants_hold()

Binding notes

  • First consumer of the scalar-pair dispatch decision from the foundations
    issue. <StateScalar, SampleScalar> here is not incidental: the whole point
    of an AGC study is a narrow sample path against a wide-enough loop state, so
    whatever scheme is chosen must be able to express that combination.
  • AgcConfig<T> is templated on the state scalar. Binding one config class per
    arithmetic config would be absurd; bind a single float64-valued config struct
    and narrow the fields on construction of the Impl<T>. The config is
    parameters, not state.
  • Times are in seconds against sample_rate_hz, and leaving the rate at 1
    makes them sample counts. Say this in the docstring — it is the kind of
    detail that silently produces a loop 48000x too slow.
  • invariants_hold() is a debug predicate. Bind it; it is exactly the sort of
    thing a precision study wants to assert at narrow widths.
  • Follow the type-erased IImpl + templated Impl<T> + Py* wrapper pattern
    already used in src/acquisition_bindings.cpp and
    src/multirate_bindings.cpp.
  • Complex process() — see the foundations issue for the inbound convention.

Depends on

Foundations issue (both decisions).

Deliverables

  • Bindings in src/sdr_bindings.cpp.
  • Exported by explicit name in python/mpdsp/__init__.py.
  • tests/test_sdr_agc.py — settling behaviour, gain clamping at
    min_gain_db/max_gain_db, and a narrow-dtype run that shows where the
    loop stops converging.
  • scripts/build_api_ref.py tables updated, docs/api_reference.md
    regenerated.

Part of the SDR binding epic #130.

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions