|
miniDSP
A small C library for audio DSP
|
FIR filtering and convolution: direct time-domain methods and FFT overlap-add fast convolution. More...
#include "minidsp.h"
Go to the source code of this file.
Functions | |
| static unsigned | next_pow2 (unsigned n) |
| Return the next power-of-two >= n (n must be > 0). | |
| unsigned | MD_convolution_num_samples (unsigned signal_len, unsigned kernel_len) |
| Compute the output length of a full linear convolution. | |
| void | MD_convolution_time (const double *signal, unsigned signal_len, const double *kernel, unsigned kernel_len, double *out) |
| Time-domain full linear convolution (direct sum-of-products). | |
| void | MD_moving_average (const double *signal, unsigned signal_len, unsigned window_len, double *out) |
| Causal moving-average FIR filter with zero-padded startup. | |
| void | MD_fir_filter (const double *signal, unsigned signal_len, const double *coeffs, unsigned num_taps, double *out) |
| Apply a causal FIR filter with arbitrary coefficients. | |
| void | MD_convolution_fft_ola (const double *signal, unsigned signal_len, const double *kernel, unsigned kernel_len, double *out) |
| Full linear convolution using FFT overlap-add (offline). | |
FIR filtering and convolution: direct time-domain methods and FFT overlap-add fast convolution.
Definition in file minidsp_fir.c.
| void MD_convolution_fft_ola | ( | const double * | signal, |
| unsigned | signal_len, | ||
| const double * | kernel, | ||
| unsigned | kernel_len, | ||
| double * | out | ||
| ) |
Full linear convolution using FFT overlap-add (offline).
Produces the same output as MD_convolution_time() but is faster for longer kernels by processing blocks in the frequency domain.
| signal | Input signal of length signal_len. |
| signal_len | Number of input samples (must be > 0). |
| kernel | FIR kernel of length kernel_len. |
| kernel_len | Number of FIR taps (must be > 0). |
| out | Output buffer of length signal_len + kernel_len - 1. |
Definition at line 87 of file minidsp_fir.c.
| unsigned MD_convolution_num_samples | ( | unsigned | signal_len, |
| unsigned | kernel_len | ||
| ) |
Compute the output length of a full linear convolution.
For input length N and kernel length M, full convolution length is N+M-1.
Definition at line 17 of file minidsp_fir.c.
| void MD_convolution_time | ( | const double * | signal, |
| unsigned | signal_len, | ||
| const double * | kernel, | ||
| unsigned | kernel_len, | ||
| double * | out | ||
| ) |
Time-domain full linear convolution (direct sum-of-products).
Computes: out[n] = sum_{k=0}^{kernel_len-1} signal[n-k] * kernel[k] with out-of-range signal samples treated as zero.
| signal | Input signal of length signal_len. |
| signal_len | Number of input samples (must be > 0). |
| kernel | FIR kernel of length kernel_len. |
| kernel_len | Number of FIR taps (must be > 0). |
| out | Output buffer of length signal_len + kernel_len - 1. |
Definition at line 24 of file minidsp_fir.c.
| void MD_fir_filter | ( | const double * | signal, |
| unsigned | signal_len, | ||
| const double * | coeffs, | ||
| unsigned | num_taps, | ||
| double * | out | ||
| ) |
Apply a causal FIR filter with arbitrary coefficients.
Computes: out[n] = sum_{k=0}^{num_taps-1} coeffs[k] * signal[n-k] with out-of-range signal samples treated as zero.
| signal | Input signal of length signal_len. |
| signal_len | Number of input samples (must be > 0). |
| coeffs | FIR coefficients of length num_taps. |
| num_taps | Number of FIR taps (must be > 0). |
| out | Output buffer of length signal_len. |
Definition at line 67 of file minidsp_fir.c.
| void MD_moving_average | ( | const double * | signal, |
| unsigned | signal_len, | ||
| unsigned | window_len, | ||
| double * | out | ||
| ) |
Causal moving-average FIR filter with zero-padded startup.
Computes: out[n] = (1/window_len) * sum_{k=0}^{window_len-1} signal[n-k] where out-of-range samples (n-k < 0) are treated as zero.
| signal | Input signal of length signal_len. |
| signal_len | Number of input samples (must be > 0). |
| window_len | Moving-average window length (must be > 0). |
| out | Output buffer of length signal_len. |
Definition at line 47 of file minidsp_fir.c.
|
static |
Return the next power-of-two >= n (n must be > 0).
Definition at line 10 of file minidsp_fir.c.