{"id":19195252,"url":"https://github.com/quartiq/idsp","last_synced_at":"2025-04-05T08:06:40.000Z","repository":{"id":40366831,"uuid":"406843225","full_name":"quartiq/idsp","owner":"quartiq","description":"Rust DSP algorithms. Often integer math. no-std.","archived":false,"fork":false,"pushed_at":"2025-02-10T09:15:50.000Z","size":230,"stargazers_count":45,"open_issues_count":1,"forks_count":5,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-29T07:06:20.233Z","etag":null,"topics":["dsp","fir-filter","halfband-filter","iir-filter","pid","rust","sinara-hw"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quartiq.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-15T16:20:49.000Z","updated_at":"2025-03-21T14:20:06.000Z","dependencies_parsed_at":"2023-01-21T06:01:56.872Z","dependency_job_id":"4873cc91-bf3e-4418-9b9e-39fbe38c79f3","html_url":"https://github.com/quartiq/idsp","commit_stats":{"total_commits":79,"total_committers":3,"mean_commits":"26.333333333333332","dds":"0.22784810126582278","last_synced_commit":"9a9cf60e08107f9344e368d9e109d8f1ddad7276"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quartiq%2Fidsp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quartiq%2Fidsp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quartiq%2Fidsp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quartiq%2Fidsp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quartiq","download_url":"https://codeload.github.com/quartiq/idsp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305934,"owners_count":20917208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dsp","fir-filter","halfband-filter","iir-filter","pid","rust","sinara-hw"],"created_at":"2024-11-09T12:09:18.503Z","updated_at":"2025-04-05T08:06:39.962Z","avatar_url":"https://github.com/quartiq.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Embedded DSP algorithms\n\n[![GitHub release](https://img.shields.io/github/v/release/quartiq/idsp?include_prereleases)](https://github.com/quartiq/idsp/releases)\n[![crates.io](https://img.shields.io/crates/v/idsp.svg)](https://crates.io/crates/idsp)\n[![Documentation](https://img.shields.io/badge/docs-online-success)](https://docs.rs/idsp)\n[![QUARTIQ Matrix Chat](https://img.shields.io/matrix/quartiq:matrix.org)](https://matrix.to/#/#quartiq:matrix.org)\n[![Continuous Integration](https://github.com/quartiq/idsp/actions/workflows/ci.yml/badge.svg)](https://github.com/quartiq/idsp/actions/workflows/ci.yml)\n\nThis crate contains some tuned DSP algorithms for general and especially embedded use.\nMany of the algorithms are implemented on integer (fixed point) datatypes.\n\nOne comprehensive user for these algorithms is [Stabilizer](https://github.com/quartiq/stabilizer).\n\n## Fixed point\n\n### Cosine/Sine\n\n[`cossin()`] uses a small (128 element or 512 byte) LUT, smart octant (un)mapping, linear interpolation and comprehensive analysis of corner cases to achieve a very clean signal (4e-6 RMS error, 9e-6 max error, 108 dB SNR typ), low spurs, and no bias with about 40 cortex-m instruction per call. It computes both cosine and sine (i.e. the complex signal) at once given a phase input.\n\n### Two-argument arcus-tangens\n\n[`atan2()`] returns a phase given a complex signal (a pair of in-phase/`x`/cosine and quadrature/`y`/sine). The RMS phase error is less than 5e-6 rad, max error is less than 1.2e-5 rad, i.e. 20.5 bit RMS, 19.1 bit max accuracy. The bias is minimal.\n\n## PLL, RPLL\n\n[`PLL`], [`RPLL`]: High accuracy, zero-assumption, fully robust, forward and reciprocal PLLs with dynamically adjustable time constant and arbitrary (in the Nyquist sampling sense) capture range, and noise shaping.\n\n## `Unwrapper`, `Accu`, `saturating_scale()`\n\n[`Unwrapper`], [`Accu`], [`saturating_scale()`]:\nTools to handle, track, and unwrap phase signals or generate them.\n\n## Float and Fixed point\n\n## IIR/Biquad\n\n[`iir::Biquad`] are fixed point (`i8`, `i16`, `i32`, `i64`) and floating point (`f32`, `f64`) biquad IIR filters.\nRobust and clean clipping and offset (anti-windup, no derivative kick, dynamically adjustable gains and gain limits) suitable for PID controller applications.\nThree kinds of filter actions: Direct Form 1, Direct Form 2 Transposed, and Direct Form 1 with noise shaping supported.\nCoefficient sharing for multiple channels.\n\n### Comparison\n\nThis is a rough feature comparison of several available `biquad` crates, with no claim for completeness, accuracy, or even fairness.\nTL;DR: `idsp` is slower but offers more features.\n\n| Feature\\Crate | [`biquad-rs`](https://crates.io/crates/biquad) | [`fixed-filters`](https://crates.io/crates/fixed-filters) | `idsp::iir` |\n|---|---|---|---|\n| Floating point `f32`/`f64` | ✅ | ❌ | ✅ |\n| Fixed point `i32` | ❌ | ✅ | ✅ |\n| Parametric fixed point `i32` | ❌ | ✅ | ❌ |\n| Fixed point `i8`/`i16`/`i64`/`i128` | ❌ | ❌ | ✅ |\n| DF2T | ✅ | ❌ | ✅ |\n| Limiting/Clamping | ❌ | ✅ | ✅ |\n| Fixed point accumulator guard bits | ❌ | ❌ | ✅ |\n| Summing junction offset | ❌ | ❌ | ✅ |\n| Fixed point noise shaping | ❌ | ❌ | ✅ |\n| Configuration/state decoupling/multi-channel | ❌ | ❌ | ✅ |\n| `f32` parameter audio filter builder | ✅ | ✅ | ✅ |\n| `f64` parameter audio filter builder | ✅ | ❌ | ✅ |\n| Additional filters (I/HO) | ❌ | ❌ | ✅ |\n| `f32` PI builder | ❌ | ✅ | ✅ |\n| `f32/f64` PI²D² builder | ❌ | ❌ | ✅ |\n| PI²D² builder limits | ❌ | ❌ | ✅ |\n| Support for fixed point `a1=-2` | ❌ | ❌ | ✅ |\n\nThree crates have been compared when processing 4x1M samples (4 channels) with a biquad lowpass.\nHardware was `thumbv7em-none-eabihf`, `cortex-m7`, code in ITCM, data in DTCM, caches enabled.\n\n| Crate | Type, features | Cycles per sample |\n|---|---|---|\n| [`biquad-rs`](https://crates.io/crates/biquad) | `f32` | 11.4 |\n| `idsp::iir` | `f32`, limits, offset | 15.5 |\n| [`fixed-filters`](https://crates.io/crates/fixed-filters) | `i32`, limits | 20.3 |\n| `idsp::iir` | `i32`, limits, offset | 23.5 |\n| `idsp::iir` | `i32`, limits, offset, noise shaping | 30.0 |\n\n## State variable filter\n\n[`svf`] is a simple IIR state variable filter simultaneously providing highpass, lowpass,\nbandpass, and notch filtering of a signal.\n\n## `Lowpass`, `Lockin`\n\n[`Lowpass`], [`Lockin`] are fast, infinitely cascadable, first- and second-order lowpass and the corresponding integration into a lockin amplifier algorithm.\n\n## FIR filters\n\n[`hbf::HbfDec`], [`hbf::HbfInt`], [`hbf::HbfDecCascade`], [`hbf::HbfIntCascade`]:\nFast `f32` symmetric FIR filters, optimized half-band filters, half-band filter decimators and integators and cascades.\nThese are used in [`stabilizer-stream`](https://github.com/quartiq/stabilizer-stream) for online PSD calculation on log\nfrequency scale for arbitrarily large amounts of data.\n\n## Delta Sigma modulator/noise shaper\n\n[`Dsm`] is a delta sigma modulator/noise shaper in MASH-(1)^K architecture.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquartiq%2Fidsp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquartiq%2Fidsp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquartiq%2Fidsp/lists"}