58 releases

new 0.6.1 Dec 7, 2024
0.5.5 Nov 25, 2024
0.4.3 Apr 20, 2024
0.4.1 Nov 14, 2023

#86 in Audio

Download history 2/week @ 2024-08-16 2/week @ 2024-09-13 30/week @ 2024-09-20 11/week @ 2024-09-27 168/week @ 2024-10-04 34/week @ 2024-10-11 11/week @ 2024-10-18 7/week @ 2024-10-25 17/week @ 2024-11-01 17/week @ 2024-11-08 8/week @ 2024-11-15 725/week @ 2024-11-22 202/week @ 2024-11-29

955 downloads per month

MIT license

1MB
6K SLoC

Rust Radio

A library for digital signals processing in the spirit of GNU Radio.

For extra speed(?), build with env RUSTFLAGS="-C target-cpu=native"

Publish new version

./extra/bump_version.sh
git push && cargo publish

Benchmark

cargo +nightly bench

Useful commands

Plot I/Q data

$ od -A none -w8 -f test.c32 > t
$ gnuplot
gnuplot> plot 't' using 1 w l, 't' using 2 w l

lib.rs:

This create provides a framework for running SDR (software defined radio) applications.

It's heavily inspired by GNURadio, except of course written in Rust.

It currently has very few blocks, and is missing tags, and PDU messages.

In addition to the example applications in this crate, there's also a sparslog project using this framework, that decodes IKEA Sparsnäs electricity meter RF signals.

Architecture overview

A RustRadio application consists of blocks that are connected by unidirectional streams. Each block has zero or more input streams, and zero or more output streams.

The signal flows through the blocks from "sources" (blocks without any input streams) to "sinks" (blocks without any output streams.

These blocks and streams are called a "graph", like the mathematical concept of graphs that have nodes and edges.

A block does something to its input(s), and passes the result to its output(s).

A typical graph will be something like:

[ Raw radio source ]
↓
[ Filtering ]
↓
[ Resampling ]
↓
[ Demodulation ]
↓
[ Symbol Sync ]
↓
[ Packet assembly and save ]

Or concretely, for sparslog:

[ RtlSdrSource ]
↓
[ RtlSdrDecode to convert from ]
[ own format to complex I/Q    ]
↓
[ FftFilter ]
↓
[ RationalResampler ]
↓
[ QuadratureDemod ]
↓
[ AddConst for frequency offset ]
↓
[ ZeroCrossing symbol sync ]
↓
[ Custom Sparsnäs decoder ]
[ block in the binary,    ]
[ not in the framework    ]

Examples

Here's a simple example that creates a couple of blocks, connects them with streams, and runs the graph.

use rustradio::graph::{Graph, GraphRunner};
use rustradio::blocks::{AddConst, VectorSource, DebugSink};
use rustradio::Complex;
let src = Box::new(VectorSource::new(
vec![
Complex::new(10.0, 0.0),
Complex::new(-20.0, 0.0),
Complex::new(100.0, -100.0),
],
));
let add = Box::new(AddConst::new(src.out(), Complex::new(1.1, 2.0)));
let sink = Box::new(DebugSink::new(add.out()));
let mut g = Graph::new();
g.add(src);
g.add(add);
g.add(sink);
g.run()?;

Test helper functions.

Dependencies

~5–36MB
~578K SLoC