OpenShot Audio Library | OpenShotAudio: juce::dsp::Convolution Class Reference

OpenShot Audio Library | OpenShotAudio 0.3.2

Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
juce::dsp::Convolution Class Reference

`#include <juce_Convolution.h>`

## Classes
struct | Pimpl

## Public Member Functions
| Convolution ()
| ~Convolution ()
void | prepare (const ProcessSpec &)
void | reset () noexcept
template<typename ProcessContext >
void | process (const ProcessContext &context) noexcept
void | loadImpulseResponse (const void *sourceData, size_t sourceDataSize, bool wantsStereo, bool wantsTrimming, size_t size, bool wantsNormalisation=true)
void | loadImpulseResponse (const File &fileImpulseResponse, bool wantsStereo, bool wantsTrimming, size_t size, bool wantsNormalisation=true)
void | copyAndLoadImpulseResponseFromBuffer (AudioBuffer< float > &buffer, double bufferSampleRate, bool wantsStereo, bool wantsTrimming, bool wantsNormalisation, size_t size)
void | copyAndLoadImpulseResponseFromBlock (AudioBlock< float > block, double bufferSampleRate, bool wantsStereo, bool wantsTrimming, bool wantsNormalisation, size_t size)

## 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

Definition at line 50 of file juce_Convolution.h.

## Constructor & Destructor Documentation

## ◆ Convolution()

juce::dsp::Convolution::Convolution | ( |  | ) |

Initialises an object for performing convolution in the frequency domain.

Definition at line 1059 of file juce_Convolution.cpp.

## ◆ ~Convolution()

juce::dsp::Convolution::~Convolution | ( |  | ) |

Destructor.

Definition at line 1065 of file juce_Convolution.cpp.

## Member Function Documentation

## ◆ copyAndLoadImpulseResponseFromBlock()

void juce::dsp::Convolution::copyAndLoadImpulseResponseFromBlock | ( | AudioBlock< float > | block,
|  | double | bufferSampleRate,
|  | bool | wantsStereo,
|  | bool | wantsTrimming,
|  | bool | wantsNormalisation,
|  | size_t | size
| ) |  |

This function loads an impulse response from an audio block, which is copied before doing anything else. Performs some resampling and pre-processing as well if needed.

Parameters

  block | the AudioBlock to use
  bufferSampleRate | the sampleRate of the data in the AudioBuffer
  wantsStereo | requests to process both stereo channels or only one channel
  wantsTrimming | requests to trim the start and the end of the impulse response
  wantsNormalisation | requests to normalise the impulse response amplitude
  size | the expected size for the impulse response after loading, -1 for maximum length

Definition at line 1135 of file juce_Convolution.cpp.

Referenced by copyAndLoadImpulseResponseFromBuffer().

## ◆ copyAndLoadImpulseResponseFromBuffer()

void juce::dsp::Convolution::copyAndLoadImpulseResponseFromBuffer | ( | AudioBuffer< float > & | buffer,
|  | double | bufferSampleRate,
|  | bool | wantsStereo,
|  | bool | wantsTrimming,
|  | bool | wantsNormalisation,
|  | 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

  buffer | the AudioBuffer to use
  bufferSampleRate | the sampleRate of the data in the AudioBuffer
  wantsStereo | requests to process both stereo channels or only one mono channel
  wantsTrimming | requests to trim the start and the end of the impulse response
  wantsNormalisation | requests to normalise the impulse response amplitude
  size | the expected size for the impulse response after loading, can be set to 0 for requesting maximum original impulse response size

Definition at line 1128 of file juce_Convolution.cpp.

## ◆ loadImpulseResponse() [1/2]

void juce::dsp::Convolution::loadImpulseResponse | ( | const File & | fileImpulseResponse,
|  | bool | wantsStereo,
|  | bool | wantsTrimming,
|  | size_t | size,
|  | bool | wantsNormalisation = `true`
| ) |  |

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

  fileImpulseResponse | the location of the audio file
  wantsStereo | requests to process both stereo channels or only one mono channel
  wantsTrimming | requests to 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 for requesting maximum original impulse response size
  wantsNormalisation | requests to normalise the impulse response amplitude

Definition at line 1099 of file juce_Convolution.cpp.

## ◆ loadImpulseResponse() [2/2]

void juce::dsp::Convolution::loadImpulseResponse | ( | const void * | sourceData,
|  | size_t | sourceDataSize,
|  | bool | wantsStereo,
|  | bool | wantsTrimming,
|  | size_t | size,
|  | bool | wantsNormalisation = `true`
| ) |  |

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

  sourceData | the block of data to use as the stream's source
  sourceDataSize | the number of bytes in the source data block
  wantsStereo | requests to process both stereo channels or only one mono channel
  wantsTrimming | requests to 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 for requesting maximum original impulse response size
  wantsNormalisation | requests to normalise the impulse response amplitude

Definition at line 1069 of file juce_Convolution.cpp.

## ◆ prepare()

void juce::dsp::Convolution::prepare | ( | const ProcessSpec & | spec | ) |

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.

Definition at line 1167 of file juce_Convolution.cpp.

## ◆ process()

template<typename ProcessContext >

void juce::dsp::Convolution::process | ( | const ProcessContext & | context | ) |
| inlinenoexcept

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

Definition at line 74 of file juce_Convolution.h.

## ◆ reset()

void juce::dsp::Convolution::reset | ( |  | ) |
| noexcept

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

Definition at line 1194 of file juce_Convolution.cpp.

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

- juce_Convolution.h
- juce_Convolution.cpp