ZigRadio is a lightweight flow graph signal processing framework for software-defined radio. It provides a suite of source, sink, and processing blocks, with a simple API for defining flow graphs, running flow graphs, and creating blocks. ZigRadio has an API similar to that of LuaRadio and is also MIT licensed.
ZigRadio can be used to rapidly prototype software radios, modulation/demodulation utilities, and signal processing experiments.
const std = @import("std");
const radio = @import("radio");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const frequency: f64 = 91.1e6; // 91.1 MHz
const tune_offset = -250e3;
var source = radio.blocks.RtlSdrSource.init(frequency + tune_offset, 1102500, .{ .debug = true });
var if_translator = radio.blocks.FrequencyTranslatorBlock.init(tune_offset);
var if_filter = radio.blocks.LowpassFilterBlock(std.math.Complex(f32), 128).init(100e3, .{});
var if_downsampler = radio.blocks.DownsamplerBlock(std.math.Complex(f32)).init(5);
var fm_demod = radio.blocks.FrequencyDiscriminatorBlock.init(1.25);
var af_filter = radio.blocks.LowpassFilterBlock(f32, 128).init(15e3, .{});
var af_deemphasis = radio.blocks.FMDeemphasisFilterBlock.init(75e-6);
var af_downsampler = radio.blocks.DownsamplerBlock(f32).init(5);
var sink = radio.blocks.PulseAudioSink.init();
var top = radio.Flowgraph.init(gpa.allocator(), .{ .debug = true });
defer top.deinit();
try top.connect(&source.block, &if_translator.block);
try top.connect(&if_translator.block, &if_filter.block);
try top.connect(&if_filter.block, &if_downsampler.block);
try top.connect(&if_downsampler.block, &fm_demod.block);
try top.connect(&fm_demod.block, &af_filter.block);
try top.connect(&af_filter.block, &af_deemphasis.block);
try top.connect(&af_deemphasis.block, &af_downsampler.block);
try top.connect(&af_downsampler.block, &sink.block);
try top.run();
}
Check out some more examples of what you can build with ZigRadio.
$ git clone https://github.com/vsergeev/zigradio.git
$ cd zigradio
Build examples:
$ zig build -Drelease-fast examples
Try out one of the examples with an RTL-SDR dongle:
$ ./zig-out/bin/example-rtlsdr_wbfm_mono 89.7e6
- src/ - Sources
- examples/ - Examples
- docs/ - Documentation
- build.zig - Zig build script
- CHANGELOG.md - Change log
- LICENSE - MIT License
- README.md - This README
Run unit tests with:
$ zig build test
Test vectors are generated with Python 3 and NumPy/SciPy:
$ zig build generate
ZigRadio is MIT licensed. See the included LICENSE file.