Skip to content
codenginePublic

About

A faithful port of the Iir1 filters

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

Iir1.Net

Iir1.Net is a faithful C# port of Bernd Porr's iir1 digital IIR filter library. It provides Butterworth, Chebyshev I, Chebyshev II, custom-pole, and RBJ filters while preserving the native implementation's coefficients, state progression, and sample-by-sample behavior.

The port targets .NET Standard 2.1, .NET 8, and .NET 10. Its parity suite contains 45 native scenarios captured independently with MSVC and GCC and runs 46 contract tests on both .NET 8 and .NET 10. Expected floating-point differences between native toolchains are handled with a strict 1e-14 absolute-or-relative tolerance; results that are bit-identical also pass directly. See Parity verification for the exact contract and regeneration procedure.

Install

dotnet add package Iir1.Net --version 1.0.0

Use

using Iir.Butterworth;

var filter = new LowPass();
filter.Setup(sampleRate: 48_000, cutoffFrequency: 2_000);

double output = filter.Filter(inputSample);

Butterworth, Chebyshev, and custom filters use direct-form II state by default; RBJ filters preserve the upstream direct-form I default. Generic filter types accept another ISectionState implementation when an application needs a different realization. Setup accepts frequencies in hertz; SetupN accepts frequencies normalized to the sample rate.

Repository layout

  • src is the source root for all solution projects.
  • src/Iir1.Net contains the package implementation.
  • src/Iir1.Net.Tests contains managed parity and behavior tests plus committed native fixtures.
  • src/Iir1.Net.Demo is a minimal executable example.
  • reference/iir1 is the exact upstream source revision used for verification.
  • tools/parity builds the native capture harness and regenerates fixtures.
  • tools/package validates and smoke-tests the package artifacts.

Build and test

Visual Studio 2022 or newer can open Iir1.Net.sln directly. The command-line equivalent is:

dotnet build Iir1.Net.sln -c Release
dotnet test src/Iir1.Net.Tests/Iir1.Net.Tests.csproj -c Release -f net8.0 --no-build
dotnet test src/Iir1.Net.Tests/Iir1.Net.Tests.csproj -c Release -f net10.0 --no-build

Initialize the pinned upstream source before regenerating parity data:

git submodule update --init --recursive

On Windows, tools/parity/scripts/regenerate-parity.ps1 prefers the installed Visual Studio C++ toolchain. The GCC profile accepts an explicit g++.exe through -Compiler. On Linux, use tools/parity/scripts/regenerate-parity.sh.

Attribution and license

The managed port is MIT-licensed; see LICENSE. The original iir1 copyright and license are preserved in THIRD_PARTY_NOTICES.md and LICENSES/iir1-MIT.txt.

About

A faithful port of the Iir1 filters

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages