|
DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
|
Real-time partitioned convolution using overlap-save with FFT. More...
#include <Convolver.h>
Public Member Functions | |
| void | prepare (int blockSize, const T *irData, int irLength) |
| Prepares the convolver with an impulse response. | |
| void | reset () noexcept |
| Resets the convolution state (clears delay lines and buffers). | |
| void | process (const T *input, T *output, int numSamples) noexcept |
| Processes a block of audio through the convolver. | |
| void | processInPlace (T *data, int numSamples) noexcept |
| Processes audio in-place (output overwrites input). | |
| void | prepare (const AudioSpec &spec, const T *irData, int irLength) |
| Prepares with AudioSpec and IR data (unified API). | |
| void | processBlock (AudioBufferView< T > buffer) noexcept |
| Processes an audio buffer in-place (unified API). | |
| int | getLatency () const noexcept |
| Returns the processing latency in samples (= block size). | |
| int | getBlockSize () const noexcept |
| Returns the block size. | |
| int | getNumPartitions () const noexcept |
| Returns the number of IR partitions. | |
Real-time partitioned convolution using overlap-save with FFT.
The impulse response is divided into partitions of size blockSize. Each partition is pre-transformed to the frequency domain. During processing, each input block is also transformed, multiplied with all IR partitions, and the results are accumulated with appropriate delays.
The block size determines both the FFT size (2 * blockSize for overlap-save) and the processing latency (= blockSize samples).
| T | Sample type (float or double). |
Definition at line 67 of file Convolver.h.
|
inlinenoexcept |
Returns the block size.
Definition at line 248 of file Convolver.h.
|
inlinenoexcept |
Returns the processing latency in samples (= block size).
Definition at line 245 of file Convolver.h.
|
inlinenoexcept |
Returns the number of IR partitions.
Definition at line 251 of file Convolver.h.
|
inline |
Prepares with AudioSpec and IR data (unified API).
Uses spec.maxBlockSize as the convolution block size.
| spec | Audio environment specification. |
| irData | Impulse response samples. |
| irLength | Number of IR samples. |
spec.maxBlockSize is not already a power of two the effective FFT block rounds up silently (e.g. 300 -> 512), doubling the effective latency. Use getBlockSize() after prepare to inspect the resolved value, or pre-set maxBlockSize to a power of two. Definition at line 224 of file Convolver.h.
|
inline |
Prepares the convolver with an impulse response.
This is the only method that allocates memory. Call once during setup.
| blockSize | Processing block size. Should be a power of two >= 2 (anything else rounds UP release-safely; check getBlockSize()). Determines latency and FFT size. Typical: 128, 256, 512. |
| irData | Pointer to the impulse response samples. |
| irLength | Number of samples in the impulse response. |
Definition at line 82 of file Convolver.h.
|
inlinenoexcept |
Processes a block of audio through the convolver.
numSamples may exceed the convolution block size: the run loop fires a partition transform at every block boundary, so arbitrary lengths are handled. input and output may be the SAME buffer (full in-place); partially overlapping buffers are not supported.
| input | Input audio samples. |
| output | Output audio samples (convolved result). |
| numSamples | Number of samples to process. |
Definition at line 162 of file Convolver.h.
|
inlinenoexcept |
Processes an audio buffer in-place (unified API).
Important: Convolver is a mono processor. This method processes only channel 0. For multi-channel convolution, use separate Convolver instances per channel, or use the Reverb class.
| buffer | Audio data (only channel 0 is convolved). |
Definition at line 238 of file Convolver.h.
|
inlinenoexcept |
Processes audio in-place (output overwrites input).
| data | Audio samples (input and output). |
| numSamples | Number of samples. |
Definition at line 205 of file Convolver.h.
|
inlinenoexcept |
Resets the convolution state (clears delay lines and buffers).
Definition at line 139 of file Convolver.h.