Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

spectrum-analyzer

> 编程语言
Open source

An easy to use and fast `no_std` library (with `alloc`) to get the frequency spectrum of a digital signal (e.g. audio) using FFT.

174 stars0 likes1 views
WebsiteGitHub

About

An easy to use and fast `no_std` library (with `alloc`) to get the frequency spectrum of a digital signal (e.g. audio) using FFT.

Rust: library for frequency spectrum analysis using FFT

An easy to use and fast no_std library (with alloc) to get the frequency spectrum of a digital signal (e.g. audio) using FFT.

Supported Platforms

The base library supports all standard and non-standard targets: Linux, macOS, and Windows, but also embedded systems running custom software.

I want to understand how FFT can be used to get a spectrum

Please see file /EDUCATIONAL.md.

How to use (including no_std-contexts)

The crate is no_std and only needs alloc, so there is no feature to enable and nothing to turn off. The most basic usage looks like this:

Cargo.toml

toml
[dependencies]
spectrum-analyzer = ""

your_binary.rs

…

Which settings should I use?

The example above is a good default: a Hann window, divide_by_N, and a block of 2048 samples. Which window and which scaling function to pick, how many samples to use, and what the resulting values mean is documented in the crate documentation, including the windows and scaling modules.

Performance

I've tested multiple FFT implementations and settled on microfft::real. It was not only the fastest, but is also the only one that works in no_std contexts.

Run cargo bench for numbers on your machine.

Example Visualizations

In the following examples you can see a basic visualization of the spectrum from 0 to 4000Hz for a layered signal of sine waves of 50, 1000, and 3777Hz @ 44100Hz sampling rate. The peaks for the given frequencies are clearly visible. Each calculation was done with 2048 samples, i.e. ≈46ms of audio signal.

Spectrum without window function on samples

Peaks (50, 1000, 3777 Hz) are clearly visible but also some noise. are clearly visible but also some noise.")

Spectrum with Hann window function on samples before FFT

Peaks (50, 1000, 3777 Hz) are clearly visible and Hann window reduces noise a little. Because this example has little noise, you don't see much difference. are clearly visible and Hann window reduces noise a little bit. Because this example has few noise, you don't see much difference.")

Live Audio + Spectrum Visualization

Execute example $ cargo run --release --example live-visualization. It will show you how you can visualize audio data in realtime + the current spectrum.

Building and Executing Tests

Tests and examples pull in audio-visualizer, which needs native libraries for audio input and for the window of the live example. On Ubuntu/Debian these are libasound2-dev, libgl1-mesa-dev, libx11-dev, libxcursor-dev, libxi-dev, libxkbcommon-dev, libxrandr-dev, and libwayland-dev. The flake.nix in this repository provides the same set.

Note that not all tests are "automatic unit tests" but also tests that you need to check visually, by looking at the generated diagram of the spectrum.

MSRV

The MSRV (minimum supported Rust version) of the library is 1.85.1. To run benchmarks, tests, and examples you may need a more recent version.

Trivia / FAQ

Why f32 and not f64?

I tested f64 but the additional accuracy doesn't pay out the ~40% calculation overhead (on x86_64).

What can I do against the noise?

Apply a window function. The windows module documents which one to pick.

Good resources with more information

  • Interpreting FFT Results:
  • FFT basic concepts:
  • „The Fundamentals of FFT-Based Signal Analysis and Measurement“
  • Fast Fourier Transforms (FFTs) and Windowing:

Also check out my blog post.

License

MIT, see LICENSE.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rust

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言