Performs stereo partitioned convolution of an input signal with an impulse response in the frequency domain, using the JUCE FFT class.
More...
|
| Convolution () |
| Initialises an object for performing convolution in the frequency domain. More...
|
|
| Convolution (ConvolutionMessageQueue &queue) |
| Initialises a convolution engine using a shared background message queue. More...
|
|
| Convolution (const Latency &requiredLatency) |
| Initialises an object for performing convolution with a fixed latency. More...
|
|
| Convolution (const NonUniform &requiredHeadSize) |
| Initialises an object for performing convolution in the frequency domain using a non-uniform partitioned algorithm. More...
|
|
| Convolution (const Latency &, ConvolutionMessageQueue &) |
| Behaves the same as the constructor taking a single Latency argument, but with a shared background message queue. More...
|
|
| Convolution (const NonUniform &, ConvolutionMessageQueue &) |
| Behaves the same as the constructor taking a single NonUniform argument, but with a shared background message queue. More...
|
|
| ~Convolution () noexcept |
|
void | prepare (const ProcessSpec &) |
| Must be called before loading any impulse response. More...
|
|
void | reset () noexcept |
| Resets the processing pipeline ready to start a new stream of data. More...
|
|
template<typename ProcessContext , std::enable_if_t< std::is_same< typename ProcessContext::SampleType, float >::value, int > = 0> |
void | process (const ProcessContext &context) noexcept |
| Performs the filter operation on the given set of samples with optional stereo processing. More...
|
|
void | loadImpulseResponse (const void *sourceData, size_t sourceDataSize, Stereo isStereo, Trim requiresTrimming, size_t size, Normalise requiresNormalisation=Normalise::yes) |
| This function loads an impulse response audio file from memory, added in a JUCE project with the Projucer as binary data. More...
|
|
void | loadImpulseResponse (const File &fileImpulseResponse, Stereo isStereo, Trim requiresTrimming, size_t size, Normalise requiresNormalisation=Normalise::yes) |
| This function loads an impulse response from an audio file. More...
|
|
void | loadImpulseResponse (AudioBuffer< float > &&buffer, double bufferSampleRate, Stereo isStereo, Trim requiresTrimming, Normalise requiresNormalisation) |
| This function loads an impulse response from an audio buffer. More...
|
|
int | getCurrentIRSize () const |
| This function returns the size of the current IR in samples. More...
|
|
int | getLatency () const |
| This function returns the current latency of the process in samples. More...
|
|
Performs stereo partitioned convolution of an input signal with an impulse response in the frequency domain, using the JUCE FFT class.
This class provides some thread-safe functions to load impulse responses from audio files or memory on-the-fly without noticeable artefacts, performing resampling and trimming if necessary.
The processing performed by this class is equivalent to the time domain convolution done in the FIRFilter class, with a FIRFilter::Coefficients object having the samples of the impulse response as its coefficients. However, in general it is more efficient to do frequency domain convolution when the size of the impulse response is 64 samples or greater.
Note: The default operation of this class uses zero latency and a uniform partitioned algorithm. If the impulse response size is large, or if the algorithm is too CPU intensive, it is possible to use either a fixed latency version of the algorithm, or a simple non-uniform partitioned convolution algorithm.
Threading: It is not safe to interleave calls to the methods of this class. If you need to load new impulse responses during processing the load
calls must be synchronised with process
calls, which in practice means making the load
call from the audio thread. The loadImpulseResponse
functions are wait-free and are therefore suitable for use in a realtime context.
- See also
- FIRFilter, FIRFilter::Coefficients, FFT
void dsp::Convolution::loadImpulseResponse |
( |
const void * |
sourceData, |
|
|
size_t |
sourceDataSize, |
|
|
Stereo |
isStereo, |
|
|
Trim |
requiresTrimming, |
|
|
size_t |
size, |
|
|
Normalise |
requiresNormalisation = Normalise::yes |
|
) |
| |
This function loads an impulse response audio file from memory, added in a JUCE project with the Projucer as binary data.
It can load any of the audio formats registered in JUCE, and performs some resampling and pre-processing as well if needed.
Note: Don't try to use this function on float samples, since the data is expected to be an audio file in its binary format. Be sure that the original data remains constant throughout the lifetime of the Convolution object, as the loading process will happen on a background thread once this function has returned.
- Parameters
-
sourceData | the block of data to use as the stream's source |
sourceDataSize | the number of bytes in the source data block |
isStereo | selects either stereo or mono |
requiresTrimming | optionally trim the start and the end of the impulse response |
size | the expected size for the impulse response after loading, can be set to 0 to requesting the original impulse response size |
requiresNormalisation | optionally normalise the impulse response amplitude |