nRF Edge AI DSP
The Digital Signal Processing (DSP) module provides a compact, optimized set of primitives for preprocessing, filtering, feature extraction, time-domain, frequency-domain signal analysis.
Overview
The DSP module implements the following categories of functionality:
Basic mathematical operations
FFT, frequency-domain processing, spectral features
Statistical measures (for example, mean, variance, RMS, entropy)
Signal transformations (for example, FFT, RFHT, Mel-spectrogram)
Utility functions (windowing, quantization, scaling, clipping)
All functions are designed for embedded usage with predictable memory and CPU usage. The library avoids dynamic memory allocation and exposes context-based APIs to enable scratch buffer reuse.
FFT and transform functions include precomputed tables for common input sizes.
See the headers in transform/fft/ for details.
Module structure
Files are located in the include/nrf_edgeai/dsp/ directory, grouped by functionality:
include/nrf_edgeai/dsp/nrf_dsp_transform.h- Aggregated interface for signal transformationsinclude/nrf_edgeai/dsp/transform/nrf_dsp_fft.h- Fast Fourier Transform (FFT) signal transformsinclude/nrf_edgeai/dsp/transform/nrf_dsp_rfht.h- Real Fast Hartley Transform (RFHT) signal transformsinclude/nrf_edgeai/dsp/transform/nrf_dsp_melspectr.h- Mel-spectrogram transforms
include/nrf_edgeai/dsp/nrf_dsp_spectral.h- Aggregated interface for spectral analysisinclude/nrf_edgeai/dsp/spectral/nrf_dsp_findpeaks.h- Peak detection helpersinclude/nrf_edgeai/dsp/spectral/nrf_dsp_freq_snr.h- Frequency SNR computationsinclude/nrf_edgeai/dsp/spectral/nrf_dsp_freq_thd.h- Frequency THD computationsinclude/nrf_edgeai/dsp/spectral/nrf_dsp_spectral_centroid.h- Spectral centroid calculationsinclude/nrf_edgeai/dsp/spectral/nrf_dsp_spectral_spread.h- Spectral spread calculations
include/nrf_edgeai/dsp/nrf_dsp_statistic.h- Aggregated interface for statistical operationsinclude/nrf_edgeai/dsp/statistic/nrf_dsp_mean.h- Mean value calculationsinclude/nrf_edgeai/dsp/statistic/nrf_dsp_rms.h- RMS calculationsinclude/nrf_edgeai/dsp/statistic/nrf_dsp_autocorr.h- Autocorrelation functions
include/nrf_edgeai/dsp/nrf_dsp_fast_math.h- Fast math helper functionsinclude/nrf_edgeai/dsp/support/- Utility functions for windowing, quantization, clipping, and scalinginclude/nrf_edgeai/dsp/utils/- Additional utility functions
Types and contexts
The DSP API provides a small set of reusable context types that store intermediate results and eliminate redundant computation when deriving multiple metrics from the same data.
For example, nrf_dsp_stat_ctx_f32_t() and nrf_dsp_spectral_ctx_f32_t() contexts hold precomputed sums, sum-of-squares, variance, and other derived metrics.
Key typedefs include:
nrf_dsp_stat_ctx_f32_t()— Floating-point statistics context (sum, tss, var, abssum)nrf_dsp_spectral_ctx_f32_t()— Floating-point spectral context (magnitude sum, centroid)nrf_dsp_sigma_factor_t()— Sigma factor enum used by statistical helpers
Usage pattern
A typical usage pattern is to create a context, reset it, and then call metric helper functions to compute derived values. For example:
#include <nrf_edgeai/dsp/nrf_dsp.h>
void compute_features(const float* samples, size_t n)
{
nrf_dsp_stat_ctx_f32_t stat_ctx;
NRF_DSP_STAT_CTX_RESET(stat_ctx);
/* Compute mean and RMS (API names follow the nrf_dsp_statistic headers) */
flt32_t mean = nrf_dsp_mean_f32(samples, n, &stat_ctx);
flt32_t rms = nrf_dsp_rms_f32(samples, n, &stat_ctx);
/* Run FFT and compute spectral centroid */
/* Use FFT helpers under transform/ and spectral/ headers */
}
The DSP module offers both floating-point and fixed-point (int8, int16, int32) variants where appropriate. The choice depends on hardware FPU availability and model quantization requirements. Types and contexts expose explicit variants for i8, i16, i32 statistics contexts.