OpenShot Audio Library | OpenShotAudio: juce::dsp::Oversampling< SampleType > Class Template Reference

OpenShot Audio Library | OpenShotAudio 0.3.0

Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
juce::dsp::Oversampling< SampleType > Class Template Reference

`#include <juce_Oversampling.h>`

## Classes
struct | OversamplingStage

## Public Types
enum | FilterType { filterHalfBandFIREquiripple = 0 , filterHalfBandPolyphaseIIR , numFilterTypes }

## Public Member Functions
| Oversampling (size_t numChannels, size_t factor, FilterType type, bool isMaxQuality=true)
| Oversampling (size_t numChannels=1)
| ~Oversampling ()
SampleType | getLatencyInSamples () noexcept
size_t | getOversamplingFactor () noexcept
void | initProcessing (size_t maximumNumberOfSamplesBeforeOversampling)
void | reset () noexcept
AudioBlock< SampleType > | processSamplesUp (const AudioBlock< const SampleType > &inputBlock) noexcept
void | processSamplesDown (AudioBlock< SampleType > &outputBlock) noexcept
void | addOversamplingStage (FilterType, float normalisedTransitionWidthUp, float stopbandAmplitudedBUp, float normalisedTransitionWidthDown, float stopbandAmplitudedBDown)
void | addDummyOversamplingStage ()
void | clearOversamplingStages ()

## Public Attributes
size_t | factorOversampling = 1
size_t | numChannels = 1

## Detailed Description

template<typename SampleType>
class juce::dsp::Oversampling< SampleType >

A processing class performing multi-channel oversampling.

It can be configured to do 2 times, 4 times, 8 times or 16 times oversampling using a multi-stage approach, either polyphase allpass IIR filters or FIR filters for the filtering, and reports successfully the latency added by the filter stages.

The principle of oversampling is to increase the sample rate of a given non-linear process, to prevent it from creating aliasing. Oversampling works by upsampling N times the input signal, processing the upsampled signal with the increased internal sample rate, and downsampling the result to get back the original processing sample rate.

Choose between FIR or IIR filtering depending on your needs in term of latency and phase distortion. With FIR filters, the phase is linear but the latency is maximised. With IIR filtering, the phase is compromised around the Nyquist frequency but the latency is minimised.

See also
  FilterDesign.

Definition at line 57 of file juce_Oversampling.h.

## Member Enumeration Documentation

## ◆ FilterType

template<typename SampleType >

enum juce::dsp::Oversampling::FilterType

The type of filter that can be used for the oversampling processing.

Definition at line 61 of file juce_Oversampling.h.

## Constructor & Destructor Documentation

## ◆ Oversampling() [1/2]

template<typename SampleType >

juce::dsp::Oversampling< SampleType >::Oversampling | ( | size_t | numChannels,
|  | size_t | factor,
|  | FilterType | type,
|  | bool | isMaxQuality = `true`
| ) |  |

Constructor of the oversampling class. All the processing parameters must be provided at the creation of the oversampling object.

Parameters

  numChannels | the number of channels to process with this object
  factor | the processing will perform 2 ^ factor times oversampling
  type | the type of filter design employed for filtering during oversampling
  isMaxQuality | if the oversampling is done using the maximum quality, the filters will be more efficient, but the CPU load will increase as well

Definition at line 541 of file juce_Oversampling.cpp.

## ◆ Oversampling() [2/2]

template<typename SampleType >

juce::dsp::Oversampling< SampleType >::Oversampling | ( | size_t | numChannels = `1` | ) |
| explicit

The default constructor of the oversampling class, which can be used to create an empty object and then add the appropriate stages.

Note: This creates a "dummy" oversampling stage, which needs to be removed first before adding proper oversampling stages.

See also
  clearOversamplingStages, addOversamplingStage

Definition at line 532 of file juce_Oversampling.cpp.

## ◆ ~Oversampling()

template<typename SampleType >

juce::dsp::Oversampling< SampleType >::~Oversampling

Destructor.

Definition at line 588 of file juce_Oversampling.cpp.

## Member Function Documentation

## ◆ addDummyOversamplingStage()

template<typename SampleType >

void juce::dsp::Oversampling< SampleType >::addDummyOversamplingStage

Adds a new "dummy" oversampling stage, which does nothing to the signal. Using one can be useful if your application features a customisable oversampling factor and if you want to select the current one from an OwnedArray without changing anything in the processing code.

See also
  OwnedArray, clearOversamplingStages, addOversamplingStage

Definition at line 595 of file juce_Oversampling.cpp.

Referenced by juce::dsp::Oversampling< SampleType >::Oversampling().

## ◆ addOversamplingStage()

template<typename SampleType >

void juce::dsp::Oversampling< SampleType >::addOversamplingStage | ( | FilterType | type,
|  | float | normalisedTransitionWidthUp,
|  | float | stopbandAmplitudedBUp,
|  | float | normalisedTransitionWidthDown,
|  | float | stopbandAmplitudedBDown
| ) |  |

Adds a new oversampling stage to the Oversampling class, multiplying the current oversampling factor by two. This is used with the default constructor to create custom oversampling chains, requiring a call to the clearOversamplingStages before any addition.

Note: Upsampling and downsampling filtering have different purposes, the former removes upsampling artefacts while the latter removes useless frequency content created by the oversampled process, so usually the attenuation is increased when upsampling compared to downsampling.

Parameters

  normalisedTransitionWidthUp | a value between 0 and 0.5 which specifies how much the transition between passband and stopband is steep, for upsampling filtering (the lower the better)
  stopbandAmplitudedBUp | the amplitude in dB in the stopband for upsampling filtering, must be negative
  normalisedTransitionWidthDown | a value between 0 and 0.5 which specifies how much the transition between passband and stopband is steep, for downsampling filtering (the lower the better)
  stopbandAmplitudedBDown | the amplitude in dB in the stopband for downsampling filtering, must be negative

See also
  clearOversamplingStages

Definition at line 601 of file juce_Oversampling.cpp.

Referenced by juce::dsp::Oversampling< SampleType >::Oversampling().

## ◆ clearOversamplingStages()

template<typename SampleType >

void juce::dsp::Oversampling< SampleType >::clearOversamplingStages

Removes all the previously registered oversampling stages, so you can add your own from scratch.

See also
  addOversamplingStage, addDummyOversamplingStage

Definition at line 624 of file juce_Oversampling.cpp.

## ◆ getLatencyInSamples()

template<typename SampleType >

SampleType juce::dsp::Oversampling< SampleType >::getLatencyInSamples
| noexcept

Returns the latency in samples of the whole processing. Use this information in your main processor to compensate the additional latency involved with the oversampling, for example with a dry / wet functionality, and to report the latency to the DAW.

Note: The latency might not be integer, so you might need to round its value or to compensate it properly in your processing code.

Definition at line 632 of file juce_Oversampling.cpp.

## ◆ getOversamplingFactor()

template<typename SampleType >

size_t juce::dsp::Oversampling< SampleType >::getOversamplingFactor
| noexcept

Returns the current oversampling factor.

Definition at line 647 of file juce_Oversampling.cpp.

## ◆ initProcessing()

template<typename SampleType >

void juce::dsp::Oversampling< SampleType >::initProcessing | ( | size_t | maximumNumberOfSamplesBeforeOversampling | ) |

Must be called before any processing, to set the buffer sizes of the internal buffers of the oversampling processing.

Definition at line 654 of file juce_Oversampling.cpp.

## ◆ processSamplesDown()

template<typename SampleType >

void juce::dsp::Oversampling< SampleType >::processSamplesDown | ( | AudioBlock< SampleType > & | outputBlock | ) |
| noexcept

Must be called to perform the downsampling, after the upsampling and the non-linear processing. The output signal is probably delayed by the internal latency of the whole oversampling behaviour, so don't forget to take this into account.

Definition at line 701 of file juce_Oversampling.cpp.

## ◆ processSamplesUp()

template<typename SampleType >

AudioBlock< SampleType > juce::dsp::Oversampling< SampleType >::processSamplesUp | ( | const AudioBlock< const SampleType > & | inputBlock | ) |
| noexcept

Must be called to perform the upsampling, prior to any oversampled processing.

Returns an AudioBlock referencing the oversampled input signal, which must be used to perform the non-linear processing which needs the higher sample rate. Don't forget to set the sample rate of that processing to N times the original sample rate.

Definition at line 680 of file juce_Oversampling.cpp.

## ◆ reset()

template<typename SampleType >

void juce::dsp::Oversampling< SampleType >::reset
| noexcept

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

Definition at line 670 of file juce_Oversampling.cpp.

## Member Data Documentation

## ◆ factorOversampling

template<typename SampleType >

size_t juce::dsp::Oversampling< SampleType >::factorOversampling = 1

Definition at line 183 of file juce_Oversampling.h.

## ◆ numChannels

template<typename SampleType >

size_t juce::dsp::Oversampling< SampleType >::numChannels = 1

Definition at line 184 of file juce_Oversampling.h.

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

- juce_Oversampling.h
- juce_Oversampling.cpp