|
RADLib
RADical C++ application framework
|
Classes | |
| struct | ComplexSample |
| Complex I/Q sample used by SDR and constellation-oriented helpers. More... | |
| class | FftPlan |
| Reusable power-of-two complex FFT plan with cached bit-reversal and twiddle factors. More... | |
| class | MatrixF |
| Row-major dense floating-point matrix for DSP transforms and small linear algebra. More... | |
| struct | BiquadCoefficients |
| Normalized direct-form biquad coefficients with a0 folded into all terms. More... | |
| struct | BiquadState |
| Stateful direct-form biquad delay elements. More... | |
| struct | EqualizerBand |
| One 16-band equalizer band setting. More... | |
| class | BiquadCascade |
| Stateful cascade of biquad sections. More... | |
| class | Equalizer16Band |
| 16-band peaking-EQ built from a biquad cascade. More... | |
Functions | |
| void | applyGain (std::vector< float > &samples, float gain) |
| Multiplies every scalar sample by gain in place. More... | |
| std::vector< float > | mix (const std::vector< float > &a, const std::vector< float > &b) |
| Adds two scalar buffers sample-by-sample; extra tail samples are preserved from the longer input. More... | |
| float | peak (const std::vector< float > &samples) |
| Returns the absolute peak amplitude in a scalar sample buffer. More... | |
| float | rms (const std::vector< float > &samples) |
| Returns root-mean-square amplitude for a scalar sample buffer. More... | |
| void | normalizePeak (std::vector< float > &samples, float targetPeak=1.0f) |
| Scales samples so their absolute peak equals targetPeak when possible. More... | |
| std::vector< float > | sine (float frequencyHz, float seconds, uint32_t sampleRate, float amplitude=1.0f) |
| Generates a sine wave at frequencyHz for seconds at sampleRate. More... | |
| std::vector< float > | whiteNoise (size_t count, float amplitude=1.0f, uint32_t seed=0x524144u) |
| Generates deterministic white noise using seed for repeatable tests and examples. More... | |
| std::vector< float > | linearResample (const std::vector< float > &interleaved, uint16_t channels, uint32_t sourceRate, uint32_t targetRate) |
| Resamples interleaved scalar audio using linear interpolation. More... | |
| std::vector< std::vector< float > > | deinterleave (const std::vector< float > &interleaved, uint16_t channels) |
| Splits interleaved channel data into one vector per channel. More... | |
| std::vector< float > | interleave (const std::vector< std::vector< float >> &channels) |
| Combines per-channel buffers into interleaved channel order. More... | |
| std::vector< float > | magnitude (const std::vector< ComplexSample > &samples) |
| Converts complex I/Q samples to magnitude values. More... | |
| std::vector< float > | phase (const std::vector< ComplexSample > &samples) |
| Converts complex I/Q samples to phase values in radians. More... | |
| void | applyGain (std::vector< ComplexSample > &samples, float gain) |
| Multiplies every complex sample by gain in place. More... | |
| std::vector< ComplexSample > | frequencyShift (const std::vector< ComplexSample > &samples, float frequencyHz, uint32_t sampleRate) |
| Frequency-shifts complex I/Q samples by frequencyHz at sampleRate. More... | |
| std::vector< float > | hannWindow (size_t count) |
| Builds a Hann window with count coefficients. More... | |
| std::vector< float > | hammingWindow (size_t count) |
| Builds a Hamming window with count coefficients. More... | |
| std::vector< float > | blackmanWindow (size_t count) |
| Builds a Blackman window with count coefficients. More... | |
| std::vector< float > | rectangularWindow (size_t count) |
| Builds a rectangular window with count coefficients. More... | |
| void | applyWindow (std::vector< float > &samples, const std::vector< float > &window) |
| Applies a window to samples in place up to the smaller buffer size. More... | |
| std::vector< float > | firFilter (const std::vector< float > &samples, const std::vector< float > &taps) |
| Applies an FIR filter using taps and returns filtered samples. More... | |
| std::vector< float > | convolve (const std::vector< float > &a, const std::vector< float > &b) |
| Convolves two scalar buffers using an FFT-based implementation. More... | |
| std::vector< float > | crossCorrelate (const std::vector< float > &a, const std::vector< float > &b) |
| Cross-correlates a and b using FFT-based convolution with reversed b. More... | |
| std::vector< float > | normalizedCrossCorrelate (const std::vector< float > &a, const std::vector< float > &b) |
| Cross-correlates and normalizes by signal energy when possible. More... | |
| std::vector< float > | onePoleLowPass (const std::vector< float > &samples, float alpha) |
| Applies a simple one-pole low-pass filter with alpha in the 0..1 smoothing range. More... | |
| FftPlan | createFftPlan (size_t size) |
| Creates a reusable FFT plan for power-of-two sizes. More... | |
| std::vector< ComplexSample > | fft (const std::vector< ComplexSample > &samples, bool inverse=false) |
| Computes a complex FFT for power-of-two sizes and DFT fallback otherwise. More... | |
| std::vector< std::vector< ComplexSample > > | fftMany (const std::vector< std::vector< ComplexSample >> &frames, bool inverse=false) |
| Computes many equal-sized power-of-two FFTs using one reusable plan. More... | |
| std::vector< ComplexSample > | fftFrames (const std::vector< ComplexSample > &frames, size_t frameSize, bool inverse=false) |
| Computes many contiguous equal-sized power-of-two FFT frames using one reusable plan. More... | |
| std::vector< float > | magnitudeSpectrum (const std::vector< ComplexSample > &spectrum) |
| Converts complex spectrum bins to magnitudes. More... | |
| std::vector< float > | powerSpectrum (const std::vector< ComplexSample > &spectrum) |
| Converts complex spectrum bins to power values. More... | |
| std::vector< float > | designLowPassFIR (size_t taps, float cutoffHz, uint32_t sampleRate) |
| Designs a windowed-sinc low-pass FIR filter. More... | |
| BiquadCoefficients | designBiquadLowPass (float cutoffHz, uint32_t sampleRate, float q=0.70710678f) |
| Designs an RBJ low-pass biquad. More... | |
| BiquadCoefficients | designBiquadHighPass (float cutoffHz, uint32_t sampleRate, float q=0.70710678f) |
| Designs an RBJ high-pass biquad. More... | |
| BiquadCoefficients | designBiquadBandPass (float centerHz, uint32_t sampleRate, float q=1.0f) |
| Designs an RBJ band-pass biquad. More... | |
| BiquadCoefficients | designBiquadNotch (float centerHz, uint32_t sampleRate, float q=1.0f) |
| Designs an RBJ notch biquad. More... | |
| BiquadCoefficients | designBiquadPeakingEQ (float centerHz, uint32_t sampleRate, float gainDb, float q=1.0f) |
| Designs an RBJ peaking equalizer biquad. More... | |
| std::vector< float > | decimate (const std::vector< float > &samples, size_t factor) |
| Keeps every factor-th sample after low-pass filtering should be applied by caller when needed. More... | |
| std::vector< float > | interpolateZeros (const std::vector< float > &samples, size_t factor) |
| Inserts factor-1 zeros between samples. More... | |
| std::vector< float > | mixCosine (const std::vector< float > &samples, float frequencyHz, uint32_t sampleRate) |
| Mixes scalar samples with a cosine oscillator. More... | |
| void | automaticGainControl (std::vector< float > &samples, float targetRms=0.25f, float maxGain=32.0f) |
| Applies simple automatic gain control toward targetRms. More... | |
| MatrixF | identityMatrix (size_t size) |
| Builds a square identity matrix. More... | |
| MatrixF | diagonalMatrix (const std::vector< float > &diagonal) |
| Builds a diagonal matrix from diagonal values. More... | |
| MatrixF | transpose (const MatrixF &matrix) |
| Returns the transpose of matrix. More... | |
| MatrixF | add (const MatrixF &a, const MatrixF &b) |
| Adds matrices with matching dimensions, or returns an empty matrix. More... | |
| MatrixF | subtract (const MatrixF &a, const MatrixF &b) |
| Subtracts matrices with matching dimensions, or returns an empty matrix. More... | |
| MatrixF | scale (const MatrixF &matrix, float scalar) |
| Multiplies every matrix value by scalar. More... | |
| MatrixF | hadamard (const MatrixF &a, const MatrixF &b) |
| Multiplies matching matrix elements, or returns an empty matrix. More... | |
| MatrixF | multiply (const MatrixF &a, const MatrixF &b) |
| Multiplies two dense matrices, or returns an empty matrix for incompatible dimensions. More... | |
| std::vector< float > | multiply (const MatrixF &matrix, const std::vector< float > &vector) |
| Multiplies a dense matrix by a vector, or returns an empty vector for incompatible dimensions. More... | |
| std::vector< float > | multiply (const MatrixF &matrix, std::initializer_list< float > vector) |
| Multiplies a dense matrix by an initializer-list vector. More... | |
| float | dot (const std::vector< float > &a, const std::vector< float > &b) |
| Returns the dot product of equal-size vectors, or 0 for mismatched sizes. More... | |
| float | l2Norm (const std::vector< float > &vector) |
| Returns the Euclidean norm of vector. More... | |
| std::vector< float > | normalizeVector (const std::vector< float > &vector) |
| Returns a normalized copy of vector, or zeros for zero-length input energy. More... | |
| MatrixF | outerProduct (const std::vector< float > &a, const std::vector< float > &b) |
| Builds the outer product a * b^T. More... | |
| MatrixF | covarianceMatrix (const MatrixF &observations) |
| Computes a covariance matrix from row-major observations where each row is one observation. More... | |
| bool | invert (const MatrixF &matrix, MatrixF &inverse, float epsilon=1.0e-6f) |
| Computes the inverse of a square matrix with partial pivoting. More... | |
| bool | solveLinearSystem (const MatrixF &matrix, const std::vector< float > &rhs, std::vector< float > &solution, float epsilon=1.0e-6f) |
| Solves matrix * x = rhs using Gaussian elimination with partial pivoting. More... | |
Adds matrices with matching dimensions, or returns an empty matrix.
| void RADDsp::applyGain | ( | std::vector< ComplexSample > & | samples, |
| float | gain | ||
| ) |
Multiplies every complex sample by gain in place.
| void RADDsp::applyGain | ( | std::vector< float > & | samples, |
| float | gain | ||
| ) |
Multiplies every scalar sample by gain in place.
| void RADDsp::applyWindow | ( | std::vector< float > & | samples, |
| const std::vector< float > & | window | ||
| ) |
Applies a window to samples in place up to the smaller buffer size.
| void RADDsp::automaticGainControl | ( | std::vector< float > & | samples, |
| float | targetRms = 0.25f, |
||
| float | maxGain = 32.0f |
||
| ) |
Applies simple automatic gain control toward targetRms.
| std::vector<float> RADDsp::blackmanWindow | ( | size_t | count | ) |
Builds a Blackman window with count coefficients.
| std::vector<float> RADDsp::convolve | ( | const std::vector< float > & | a, |
| const std::vector< float > & | b | ||
| ) |
Convolves two scalar buffers using an FFT-based implementation.
Computes a covariance matrix from row-major observations where each row is one observation.
| FftPlan RADDsp::createFftPlan | ( | size_t | size | ) |
Creates a reusable FFT plan for power-of-two sizes.
| std::vector<float> RADDsp::crossCorrelate | ( | const std::vector< float > & | a, |
| const std::vector< float > & | b | ||
| ) |
Cross-correlates a and b using FFT-based convolution with reversed b.
| std::vector<float> RADDsp::decimate | ( | const std::vector< float > & | samples, |
| size_t | factor | ||
| ) |
Keeps every factor-th sample after low-pass filtering should be applied by caller when needed.
| std::vector<std::vector<float> > RADDsp::deinterleave | ( | const std::vector< float > & | interleaved, |
| uint16_t | channels | ||
| ) |
Splits interleaved channel data into one vector per channel.
| BiquadCoefficients RADDsp::designBiquadBandPass | ( | float | centerHz, |
| uint32_t | sampleRate, | ||
| float | q = 1.0f |
||
| ) |
Designs an RBJ band-pass biquad.
| BiquadCoefficients RADDsp::designBiquadHighPass | ( | float | cutoffHz, |
| uint32_t | sampleRate, | ||
| float | q = 0.70710678f |
||
| ) |
Designs an RBJ high-pass biquad.
| BiquadCoefficients RADDsp::designBiquadLowPass | ( | float | cutoffHz, |
| uint32_t | sampleRate, | ||
| float | q = 0.70710678f |
||
| ) |
Designs an RBJ low-pass biquad.
| BiquadCoefficients RADDsp::designBiquadNotch | ( | float | centerHz, |
| uint32_t | sampleRate, | ||
| float | q = 1.0f |
||
| ) |
Designs an RBJ notch biquad.
| BiquadCoefficients RADDsp::designBiquadPeakingEQ | ( | float | centerHz, |
| uint32_t | sampleRate, | ||
| float | gainDb, | ||
| float | q = 1.0f |
||
| ) |
Designs an RBJ peaking equalizer biquad.
| std::vector<float> RADDsp::designLowPassFIR | ( | size_t | taps, |
| float | cutoffHz, | ||
| uint32_t | sampleRate | ||
| ) |
Designs a windowed-sinc low-pass FIR filter.
| MatrixF RADDsp::diagonalMatrix | ( | const std::vector< float > & | diagonal | ) |
Builds a diagonal matrix from diagonal values.
| float RADDsp::dot | ( | const std::vector< float > & | a, |
| const std::vector< float > & | b | ||
| ) |
Returns the dot product of equal-size vectors, or 0 for mismatched sizes.
| std::vector<ComplexSample> RADDsp::fft | ( | const std::vector< ComplexSample > & | samples, |
| bool | inverse = false |
||
| ) |
Computes a complex FFT for power-of-two sizes and DFT fallback otherwise.
| std::vector<ComplexSample> RADDsp::fftFrames | ( | const std::vector< ComplexSample > & | frames, |
| size_t | frameSize, | ||
| bool | inverse = false |
||
| ) |
Computes many contiguous equal-sized power-of-two FFT frames using one reusable plan.
| std::vector<std::vector<ComplexSample> > RADDsp::fftMany | ( | const std::vector< std::vector< ComplexSample >> & | frames, |
| bool | inverse = false |
||
| ) |
Computes many equal-sized power-of-two FFTs using one reusable plan.
| std::vector<float> RADDsp::firFilter | ( | const std::vector< float > & | samples, |
| const std::vector< float > & | taps | ||
| ) |
Applies an FIR filter using taps and returns filtered samples.
| std::vector<ComplexSample> RADDsp::frequencyShift | ( | const std::vector< ComplexSample > & | samples, |
| float | frequencyHz, | ||
| uint32_t | sampleRate | ||
| ) |
Frequency-shifts complex I/Q samples by frequencyHz at sampleRate.
Multiplies matching matrix elements, or returns an empty matrix.
| std::vector<float> RADDsp::hammingWindow | ( | size_t | count | ) |
Builds a Hamming window with count coefficients.
| std::vector<float> RADDsp::hannWindow | ( | size_t | count | ) |
Builds a Hann window with count coefficients.
| MatrixF RADDsp::identityMatrix | ( | size_t | size | ) |
Builds a square identity matrix.
| std::vector<float> RADDsp::interleave | ( | const std::vector< std::vector< float >> & | channels | ) |
Combines per-channel buffers into interleaved channel order.
| std::vector<float> RADDsp::interpolateZeros | ( | const std::vector< float > & | samples, |
| size_t | factor | ||
| ) |
Inserts factor-1 zeros between samples.
Computes the inverse of a square matrix with partial pivoting.
| float RADDsp::l2Norm | ( | const std::vector< float > & | vector | ) |
Returns the Euclidean norm of vector.
| std::vector<float> RADDsp::linearResample | ( | const std::vector< float > & | interleaved, |
| uint16_t | channels, | ||
| uint32_t | sourceRate, | ||
| uint32_t | targetRate | ||
| ) |
Resamples interleaved scalar audio using linear interpolation.
| std::vector<float> RADDsp::magnitude | ( | const std::vector< ComplexSample > & | samples | ) |
Converts complex I/Q samples to magnitude values.
| std::vector<float> RADDsp::magnitudeSpectrum | ( | const std::vector< ComplexSample > & | spectrum | ) |
Converts complex spectrum bins to magnitudes.
| std::vector<float> RADDsp::mix | ( | const std::vector< float > & | a, |
| const std::vector< float > & | b | ||
| ) |
Adds two scalar buffers sample-by-sample; extra tail samples are preserved from the longer input.
| std::vector<float> RADDsp::mixCosine | ( | const std::vector< float > & | samples, |
| float | frequencyHz, | ||
| uint32_t | sampleRate | ||
| ) |
Mixes scalar samples with a cosine oscillator.
Multiplies two dense matrices, or returns an empty matrix for incompatible dimensions.
| std::vector<float> RADDsp::multiply | ( | const MatrixF & | matrix, |
| const std::vector< float > & | vector | ||
| ) |
Multiplies a dense matrix by a vector, or returns an empty vector for incompatible dimensions.
| std::vector<float> RADDsp::multiply | ( | const MatrixF & | matrix, |
| std::initializer_list< float > | vector | ||
| ) |
Multiplies a dense matrix by an initializer-list vector.
| std::vector<float> RADDsp::normalizedCrossCorrelate | ( | const std::vector< float > & | a, |
| const std::vector< float > & | b | ||
| ) |
Cross-correlates and normalizes by signal energy when possible.
| void RADDsp::normalizePeak | ( | std::vector< float > & | samples, |
| float | targetPeak = 1.0f |
||
| ) |
Scales samples so their absolute peak equals targetPeak when possible.
| std::vector<float> RADDsp::normalizeVector | ( | const std::vector< float > & | vector | ) |
Returns a normalized copy of vector, or zeros for zero-length input energy.
| std::vector<float> RADDsp::onePoleLowPass | ( | const std::vector< float > & | samples, |
| float | alpha | ||
| ) |
Applies a simple one-pole low-pass filter with alpha in the 0..1 smoothing range.
| MatrixF RADDsp::outerProduct | ( | const std::vector< float > & | a, |
| const std::vector< float > & | b | ||
| ) |
Builds the outer product a * b^T.
| float RADDsp::peak | ( | const std::vector< float > & | samples | ) |
Returns the absolute peak amplitude in a scalar sample buffer.
| std::vector<float> RADDsp::phase | ( | const std::vector< ComplexSample > & | samples | ) |
Converts complex I/Q samples to phase values in radians.
| std::vector<float> RADDsp::powerSpectrum | ( | const std::vector< ComplexSample > & | spectrum | ) |
Converts complex spectrum bins to power values.
| std::vector<float> RADDsp::rectangularWindow | ( | size_t | count | ) |
Builds a rectangular window with count coefficients.
| float RADDsp::rms | ( | const std::vector< float > & | samples | ) |
Returns root-mean-square amplitude for a scalar sample buffer.
Multiplies every matrix value by scalar.
| std::vector<float> RADDsp::sine | ( | float | frequencyHz, |
| float | seconds, | ||
| uint32_t | sampleRate, | ||
| float | amplitude = 1.0f |
||
| ) |
Generates a sine wave at frequencyHz for seconds at sampleRate.
| bool RADDsp::solveLinearSystem | ( | const MatrixF & | matrix, |
| const std::vector< float > & | rhs, | ||
| std::vector< float > & | solution, | ||
| float | epsilon = 1.0e-6f |
||
| ) |
Solves matrix * x = rhs using Gaussian elimination with partial pivoting.
Subtracts matrices with matching dimensions, or returns an empty matrix.
| std::vector<float> RADDsp::whiteNoise | ( | size_t | count, |
| float | amplitude = 1.0f, |
||
| uint32_t | seed = 0x524144u |
||
| ) |
Generates deterministic white noise using seed for repeatable tests and examples.