Skip to content

Commit

Permalink
radio/blocks/signal: update docstrings for new refman generator
Browse files Browse the repository at this point in the history
  • Loading branch information
vsergeev committed Sep 4, 2018
1 parent 5249e30 commit ce1b2ba
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 30 deletions.
1 change: 1 addition & 0 deletions radio/blocks/signal/complexmagnitude.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
-- Compute the magnitude of a complex-valued signal.
--
-- $$ y[n] = |x[n]| $$
--
-- $$ y[n] = \sqrt{\text{Re}(x[n])^2 + \text{Im}(x[n])^2} $$
--
-- @category Math Operations
Expand Down
1 change: 1 addition & 0 deletions radio/blocks/signal/complexphase.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
-- Compute the argument (phase) of a complex-valued signal.
--
-- $$ y[n] = \text{arg}(x[n]) $$
--
-- $$ y[n] = \text{atan2}(\text{Im}(x[n]), \text{Re}(x[n])) $$
--
-- @category Math Operations
Expand Down
47 changes: 33 additions & 14 deletions radio/blocks/signal/filter_utils.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
-- FIR filter generation functions.
--
-- @module radio.blocks.signal.filter_utils

local math = require('math')

local window_utils = require('radio.blocks.signal.window_utils')
Expand All @@ -8,7 +13,8 @@ local window_utils = require('radio.blocks.signal.window_utils')
---
-- Generate the shifted, truncated coefficients of an ideal low-pass filter.
--
-- @local
-- @internal
-- @function fir_lowpass
-- @tparam int num_taps Number of taps
-- @tparam number cutoff Normalized cutoff frequency
-- @treturn array Shifted impulse response taps
Expand All @@ -29,7 +35,8 @@ end
---
-- Generate the shifted, truncated coefficients of an ideal high-pass filter.
--
-- @local
-- @internal
-- @function fir_highpass
-- @tparam int num_taps Number of taps, must be odd
-- @tparam number cutoff Normalized cutoff frequency
-- @treturn array Shifted impulse response taps
Expand All @@ -52,7 +59,8 @@ end
---
-- Generate the shifted, truncated coefficients of an ideal band-pass filter.
--
-- @local
-- @internal
-- @function fir_bandpass
-- @tparam int num_taps Number of taps, must be odd
-- @tparam {number,number} cutoffs Normalized cutoff frequencies
-- @treturn array Shifted impulse response taps
Expand All @@ -76,7 +84,8 @@ end
---
-- Generate the shifted, truncated coefficients of an ideal band-stop filter.
--
-- @local
-- @internal
-- @function fir_bandstop
-- @tparam int num_taps Number of taps, must be odd
-- @tparam {number,number} cutoffs Normalized cutoff frequencies
-- @treturn array Shifted impulse response taps
Expand All @@ -103,7 +112,8 @@ end
---
-- Apply window to and normalize magnitude of finite impulse response taps.
--
-- @local
-- @internal
-- @function firwin
-- @tparam array h Impulse response taps
-- @tparam[opt='hamming'] string window_type Window function type
-- @tparam number scale_freq Normalized frequency to scale to unity magnitude
Expand Down Expand Up @@ -133,7 +143,8 @@ end
---
-- Generate FIR low-pass filter taps by the window design method.
--
-- @local
-- @internal
-- @function firwin_lowpass
-- @tparam int num_taps Number of taps
-- @tparam number cutoff Normalized cutoff frequency
-- @tparam[opt='hamming'] string window_type Window function type
Expand All @@ -148,7 +159,8 @@ end
---
-- Generate FIR high-pass filter taps by the window design method.
--
-- @local
-- @internal
-- @function firwin_highpass
-- @tparam int num_taps Number of taps, must be odd
-- @tparam number cutoff Normalized cutoff frequency
-- @tparam[opt='hamming'] string window_type Window function type
Expand All @@ -163,7 +175,8 @@ end
---
-- Generate FIR band-pass filter taps by the window design method.
--
-- @local
-- @internal
-- @function firwin_bandpass
-- @tparam int num_taps Number of taps, must be odd
-- @tparam {number,number} cutoffs Normalized cutoff frequencies
-- @tparam[opt='hamming'] string window_type Window function type
Expand All @@ -178,7 +191,8 @@ end
---
-- Generate FIR band-stop filter taps by the window design method.
--
-- @local
-- @internal
-- @function firwin_bandstop
-- @tparam int num_taps Number of taps, must be odd
-- @tparam {number,number} cutoffs Normalized cutoff frequencies
-- @tparam[opt='hamming'] string window_type Window function type
Expand All @@ -196,7 +210,8 @@ end
-- Apply window to and normalize magnitude of complex finite impulse response
-- taps.
--
-- @local
-- @internal
-- @function complex_firwin
-- @tparam array h Complex impulse response taps
-- @tparam number scale_freq Normalized center frequency of filter
-- @tparam[opt='hamming'] string window_type Window function type
Expand Down Expand Up @@ -236,7 +251,8 @@ end
---
-- Generate FIR complex band-pass filter taps by the window design method.
--
-- @local
-- @internal
-- @function firwin_complex_bandpass
-- @tparam int num_taps Number of taps
-- @tparam {number,number} cutoffs Normalized cutoff frequencies, can be
-- positive or negative
Expand All @@ -252,7 +268,8 @@ end
---
-- Generate FIR complex band-stop filter taps by the window design method.
--
-- @local
-- @internal
-- @function firwin_complex_bandstop
-- @tparam int num_taps Number of taps, must be odd
-- @tparam {number,number} cutoffs Normalized cutoff frequencies, can be
-- positive or negative
Expand All @@ -274,7 +291,8 @@ end
-- Generate an FIR approximation of a root-raised cosine filter, normalized to
-- unity gain at DC.
--
-- @local
-- @internal
-- @function fir_root_raised_cosine
-- @tparam int num_taps Number of taps, must be odd
-- @tparam number sample_rate Sample rate in Hz
-- @tparam number beta Roll-off factor
Expand Down Expand Up @@ -324,7 +342,8 @@ end
---
-- Generate a windowed FIR approximation of the discrete Hilbert transform.
--
-- @local
-- @internal
-- @function fir_hilbert_transform
-- @tparam int num_taps Number of taps, must be odd
-- @tparam[opt='hamming'] string window_type Window function type
-- @treturn array Filter taps
Expand Down
7 changes: 4 additions & 3 deletions radio/blocks/signal/firfilter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
-- Filter a complex or real valued signal with an FIR filter.
--
-- $$ y[n] = (x * h)[n] $$
--
-- $$ y[n] = b_0 x[n] + b_1 x[n-1] + ... + b_N x[n-N] $$
--
-- @category Filtering
-- @block FIRFilterBlock
-- @tparam array|vector taps Real-valued taps specified with a number array or
-- a Float32 vector, or complex-valued taps specified
-- with a ComplexFloat32 vector
-- @tparam[opt] bool use_fft Use FFT overlap-save convolution. Defaults to true
-- when acceleration is available and taps length is
-- greater than 16
-- @tparam[opt=true] bool use_fft Use FFT overlap-save convolution. Defaults to true
-- when acceleration is available and taps length is
-- greater than 16
--
-- @signature in:ComplexFloat32 > out:ComplexFloat32
-- @signature in:Float32 > out:Float32
Expand Down
1 change: 1 addition & 0 deletions radio/blocks/signal/iirfilter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
-- Filter a complex or real valued signal with an IIR filter.
--
-- $$ y[n] = (x * h)[n] $$
--
-- $$ \begin{align} y[n] = &\frac{1}{a_0}(b_0 x[n] + b_1 x[n-1] + ... + b_N x[n-N] \\ - &a_1 y[n-1] - a_2 y[n-2] - ... - a_M x[n-M])\end{align} $$
--
-- @category Filtering
Expand Down
2 changes: 2 additions & 0 deletions radio/blocks/signal/singlepolehighpassfilter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
-- filter.
--
-- $$ H(s) = \frac{\tau s}{\tau s + 1} $$
--
-- $$ H(z) = \frac{2\tau f_s}{1 + 2\tau f_s} \frac{1 - z^{-1}}{1 + (\frac{1 - 2\tau f_s}{1 + 2\tau f_s}) z^{-1}} $$
--
-- $$ y[n] = \frac{2\tau f_s}{1 + 2\tau f_s} \; x[n] + \frac{2\tau f_s}{1 + 2\tau f_s} \; x[n-1] - \frac{1 - 2\tau f_s}{1 + 2\tau f_s} \; y[n-1] $$
--
-- @category Filtering
Expand Down
2 changes: 2 additions & 0 deletions radio/blocks/signal/singlepolelowpassfilter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
-- filter.
--
-- $$ H(s) = \frac{1}{\tau s + 1} $$
--
-- $$ H(z) = \frac{1}{1 + 2\tau f_s} \frac{1 + z^{-1}}{1 + (\frac{1 - 2\tau f_s}{1 + 2\tau f_s}) z^{-1}} $$
--
-- $$ y[n] = \frac{1}{1 + 2\tau f_s} \; x[n] + \frac{1}{1 + 2\tau f_s} \; x[n-1] - \frac{1 - 2\tau f_s}{1 + 2\tau f_s} \; y[n-1] $$
--
-- @category Filtering
Expand Down
30 changes: 18 additions & 12 deletions radio/blocks/signal/spectrum_utils.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
-- DFT, IDFT, PSD, and fftshift implementations.
--
-- @module radio.blocks.signal.spectrum_utils

local ffi = require('ffi')
local math = require('math')

Expand All @@ -13,8 +18,8 @@ local window_utils = require('radio.blocks.signal.window_utils')
---
-- Discrete Fourier Transform class.
--
-- @local
-- @type DFT
-- @internal
-- @class DFT
-- @tparam vector input_samples ComplexFloat32 or Float32 vector of input samples
-- @tparam vector output_samples ComplexFloat32 vector of output transformed samples
local DFT = class.factory()
Expand Down Expand Up @@ -54,7 +59,7 @@ end
---
-- Compute the discrete fourier transform.
--
-- @local
-- @internal
-- @function DFT:compute

--------------------------------------------------------------------------------
Expand Down Expand Up @@ -258,8 +263,8 @@ end
---
-- Inverse Discrete Fourier Transform class.
--
-- @local
-- @type IDFT
-- @internal
-- @class IDFT
-- @tparam vector input_samples ComplexFloat32 vector of input DFT samples
-- @tparam vector output_samples ComplexFloat32 or Float32 vector of output samples
local IDFT = class.factory()
Expand Down Expand Up @@ -299,8 +304,8 @@ end
---
-- Compute the inverse discrete fourier transform.
--
-- @local
-- @function DFT:compute
-- @internal
-- @function IDFT:compute

--------------------------------------------------------------------------------
-- IDFT implementations
Expand Down Expand Up @@ -529,8 +534,8 @@ end
---
-- Power Spectral Density class.
--
-- @local
-- @type PSD
-- @internal
-- @class PSD
-- @tparam vector input_samples ComplexFloat32 or Float32 vector of input samples
-- @tparam vector output_samples Float32 vector of output power spectral density samples
-- @tparam[opt='hamming'] string window_type Window type
Expand Down Expand Up @@ -580,8 +585,8 @@ end
---
-- Compute the power spectral density.
--
-- @local
-- @function DFT:compute
-- @internal
-- @function PSD:compute

--------------------------------------------------------------------------------
-- PSD implementations
Expand Down Expand Up @@ -665,7 +670,8 @@ end
---
-- Shift frequency components into negative, zero, positive frequency order.
--
-- @local
-- @internal
-- @function fftshift
-- @tparam vector samples ComplexFloat32 or Float32 vector of samples
local function fftshift(samples)
local offset = samples.length/2
Expand Down
8 changes: 7 additions & 1 deletion radio/blocks/signal/window_utils.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
-- Window generation function.
--
-- @module radio.blocks.signal.window_utils

local math = require('math')

-- Window functions.
Expand All @@ -24,7 +29,8 @@ local window_functions = {
---
-- Generate a window.
--
-- @local
-- @internal
-- @function window
-- @tparam int M Window length
-- @tparam string window_type Window function, choice of "rectangular",
-- "hamming", "hanning", "bartlett", "blackman".
Expand Down

0 comments on commit ce1b2ba

Please sign in to comment.