<%namespace file="refman.template.utils.mako" name="utils" />\
Generated from LuaRadio ${utils.attr.git_version}
.
% if not utils.attr.disable_toc:
- Example
- Running
- Blocks
- Composition
- CompositeBlock % for category in utils.attr.block_categories:
- [${category}](#${category.replace(" ", "-").lower()})
% for block in blocks[category]:
- ${block.name} % for child in block.children:
- ${child.name}.lower()}) % endfor % endfor % endfor
- Composition
- Infrastructure
% endif
local radio = require('radio')
-- RTL-SDR Source, frequency 88.5 MHz - 250 kHz, sample rate 1102500 Hz
local source = radio.RtlSdrSource(88.5e6 - 250e3, 1102500)
-- Tuner block, translate -250 kHz, filter 200 kHz, decimate by 5
local tuner = radio.TunerBlock(-250e3, 200e3, 5)
-- Wideband FM Stereo Demodulator block
local demodulator = radio.WBFMStereoDemodulator()
-- Left and right AF downsampler blocks
local l_downsampler = radio.DownsamplerBlock(5)
local r_downsampler = radio.DownsamplerBlock(5)
-- Audio sink, 2 channels for left and right audio
local sink = radio.PulseAudioSink(2)
-- Top-level block
local top = radio.CompositeBlock()
-- Connect blocks in top block
top:connect(source, tuner, demodulator)
top:connect(demodulator, 'left', l_downsampler, 'in')
top:connect(demodulator, 'right', r_downsampler, 'in')
top:connect(l_downsampler, 'out', sink, 'in1')
top:connect(r_downsampler, 'out', sink, 'in2')
-- Run top block
top:run()
$ luaradio example.lua
LuaRadio scripts can be run with the luaradio
runner, or directly with
luajit
, if the radio
package is installed in your Lua path.
The luaradio
runner is a simple wrapper script for running LuaRadio scripts.
It can also print version information, dump relevant platform information, and
adjust the runtime debug verbosity of scripts. The runner modifies the Lua path
to support importing the radio
package locally, so it can be used to run
LuaRadio scripts directly from the repository without installation.
$ ./luaradio
Usage: luaradio [options] <script> [args]
Options:
-h, --help Print help and exit
--version Print version and exit
--platform Dump platform and exit
-v, --verbose Enable debug verbosity
$
To run a script, use luaradio
as you would use luajit
:
$ luaradio script.lua
To run a script with debug verbosity:
$ luaradio -v script.lua
LuaRadio interprets several environment variables to adjust runtime settings.
These environment variables are treated as flags that can be enabled with value
1
(or values y
, yes
, true
).
LUARADIO_DEBUG
- Enable debug verbosityLUARADIO_DISABLE_LIQUID
- Disable liquid-dsp libraryLUARADIO_DISABLE_VOLK
- Disable volk libraryLUARADIO_DISABLE_FFTW3F
- Disable fftw3f library
For example, to enable debug verbosity:
$ LUARADIO_DEBUG=1 luaradio script.lua
To disable use of the VOLK library:
$ LUARADIO_DISABLE_VOLK=1 luaradio script.lua
To run a script with no external libraries for acceleration:
$ LUARADIO_DISABLE_LIQUID=1 LUARADIO_DISABLE_VOLK=1 LUARADIO_DISABLE_FFTW3F=1 luaradio script.lua
${utils.render(modules['radio.core.composite'].children[0], namespace="radio.")} % for category in utils.attr.block_categories:
% for block in blocks[category]: ${utils.render(block, namespace="radio.")} % endfor % endfor
${utils.render(modules['radio'])}
${utils.render(modules['radio.vector'])}
${utils.render(modules['radio.block'])}
${utils.render(modules['radio.debug'])}
${utils.render(modules['radio.platform'])}