JUCE  v5.1.1-3-g1a0b28c73
JUCE API
Convolution Class Reference

Performs stereo uniform-partitioned convolution of an input signal with an impulse response in the frequency domain, using the juce FFT class. More...

#include <juce_Convolution.h>

Collaboration diagram for Convolution:

Public Member Functions

 Convolution ()
 Initialises an object for performing convolution in the frequency domain. More...
 
 ~Convolution ()
 Destructor. More...
 
void copyAndLoadImpulseResponseFromBuffer (const AudioBuffer< float > &buffer, double bufferSampleRate, bool wantsStereo, size_t size)
 This function loads an impulse response from an audio buffer, which is copied before doing anything else. More...
 
void loadImpulseResponse (const void *sourceData, size_t sourceDataSize, bool wantsStereo, size_t size)
 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, bool wantsStereo, size_t size)
 This function loads an impulse response from an audio file on any drive. More...
 
void prepare (const ProcessSpec &)
 Must be called before loading any impulse response, to provide to the convolution the maximumBufferSize to handle, and the sample rate useful for optional resampling. More...
 
template<typename ProcessContext >
void process (const ProcessContext &context) noexcept
 Performs the filter operation on the given set of samples, with optional stereo processing. More...
 
void reset () noexcept
 Resets the processing pipeline, ready to start a new stream of data. More...
 

Private Member Functions

void processSamples (const AudioBlock< float > &, AudioBlock< float > &, bool isBypassed) noexcept
 

Private Attributes

bool currentIsBypassed = false
 
AudioBlock< float > dryBuffer
 
HeapBlock< char > dryBufferStorage
 
ScopedPointer< Pimpl > pimpl
 
double sampleRate
 
LinearSmoothedValue< float > volumeDry [2]
 
LinearSmoothedValue< float > volumeWet [2]
 

Detailed Description

Performs stereo uniform-partitioned convolution of an input signal with an impulse response in the frequency domain, using the juce FFT class.

It provides some thread-safe functions to load impulse responses as well, from audio files or memory on the fly without any noticeable artefacts, performing resampling and trimming if necessary.

The processing is equivalent to the time domain convolution done in the class FIRFilter, with a FIRFilter::Coefficients object having as coefficients the samples of the impulse response. However, it is more efficient in general to do frequency domain convolution when the size of the impulse response is higher than 64 samples.

See also
FIRFilter, FIRFilter::Coefficients, FFT

Constructor & Destructor Documentation

◆ Convolution()

Convolution::Convolution ( )

Initialises an object for performing convolution in the frequency domain.

◆ ~Convolution()

Convolution::~Convolution ( )

Destructor.

Member Function Documentation

◆ copyAndLoadImpulseResponseFromBuffer()

void Convolution::copyAndLoadImpulseResponseFromBuffer ( const AudioBuffer< float > &  buffer,
double  bufferSampleRate,
bool  wantsStereo,
size_t  size 
)

This function loads an impulse response from an audio buffer, which is copied before doing anything else.

Performs some resampling and pre-processing as well if needed.

Parameters
bufferthe AudioBuffer to use
bufferSampleRatethe sampleRate of the data in the AudioBuffer
wantsStereorequests to load both stereo channels or only one mono channel
sizethe expected size for the impulse response after loading

◆ loadImpulseResponse() [1/2]

void Convolution::loadImpulseResponse ( const void *  sourceData,
size_t  sourceDataSize,
bool  wantsStereo,
size_t  size 
)

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 : obviously, don't try to use this function on float samples, since the data is supposed to be an audio file in its binary format, and be sure that the original data is not going to move at all its memory location during the process !!

Parameters
sourceDatathe block of data to use as the stream's source
sourceDataSizethe number of bytes in the source data block
wantsStereorequests to load both stereo channels or only one mono channel
sizethe expected size for the impulse response after loading

◆ loadImpulseResponse() [2/2]

void Convolution::loadImpulseResponse ( const File fileImpulseResponse,
bool  wantsStereo,
size_t  size 
)

This function loads an impulse response from an audio file on any drive.

It can load any of the audio formats registered in JUCE, and performs some resampling and pre-processing as well if needed.

Parameters
fileImpulseResponsethe location of the audio file
wantsStereorequests to load both stereo channels or only one mono channel
sizethe expected size for the impulse response after loading

◆ prepare()

void Convolution::prepare ( const ProcessSpec )

Must be called before loading any impulse response, to provide to the convolution the maximumBufferSize to handle, and the sample rate useful for optional resampling.

◆ process()

template<typename ProcessContext >
void Convolution::process ( const ProcessContext context)
inlinenoexcept

Performs the filter operation on the given set of samples, with optional stereo processing.

◆ processSamples()

void Convolution::processSamples ( const AudioBlock< float > &  ,
AudioBlock< float > &  ,
bool  isBypassed 
)
privatenoexcept

◆ reset()

void Convolution::reset ( )
noexcept

Resets the processing pipeline, ready to start a new stream of data.

Member Data Documentation

◆ currentIsBypassed

bool Convolution::currentIsBypassed = false
private

◆ dryBuffer

AudioBlock<float> Convolution::dryBuffer
private

◆ dryBufferStorage

HeapBlock<char> Convolution::dryBufferStorage
private

◆ pimpl

ScopedPointer<Pimpl> Convolution::pimpl
private

◆ sampleRate

double Convolution::sampleRate
private

◆ volumeDry

LinearSmoothedValue<float> Convolution::volumeDry[2]
private

◆ volumeWet

LinearSmoothedValue<float> Convolution::volumeWet[2]
private

The documentation for this class was generated from the following file: