iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
RealtimeResampler< T, NCHANS, A > Class Template Reference

A multi-channel real-time resampling container that can be used to resample audio processing to a specified sample rate for the situation where you have some arbitary DSP code that requires a specific rate. More...

#include <RealtimeResampler.h>

Public Types

enum class  ESRCMode { kLinearInterpolation = 0 , kLancsoz , kNumResamplingModes }
 
using BlockProcessFunc = std::function< void(T **, T **, int, int)>
 
using LanczosResampler = LanczosResampler< T, NCHANS, A >
 

Public Member Functions

 RealtimeResampler (double innerSampleRate, ESRCMode mode=ESRCMode::kLancsoz)
 Constructor. More...
 
 RealtimeResampler (const RealtimeResampler &)=delete
 
RealtimeResampleroperator= (const RealtimeResampler &)=delete
 
void Reset (double inputSampleRate, int maxBlockSize=DEFAULT_BLOCK_SIZE)
 Reset the underlying DSP (when the samplerate or max expected block size changes) More...
 
void ProcessBlock (T **inputs, T **outputs, int nFrames, int nChans, BlockProcessFunc func)
 Resample an input block with a per-block function (resample input -> process with function -> resample back to external sample rate) More...
 
int GetLatency () const
 Get the latency of the resampling, not including any latency of the encapsulated DSP. More...
 

Detailed Description

template<typename T = double, int NCHANS = 2, size_t A = 12>
class RealtimeResampler< T, NCHANS, A >

A multi-channel real-time resampling container that can be used to resample audio processing to a specified sample rate for the situation where you have some arbitary DSP code that requires a specific rate.

Two modes are supported:

The Lanczos resampler has a configurable filter size (A) that affects the latency of the resampler. It can also optionally use SIMD instructions when T==float.

Template Parameters
Tthe sampletype float or double
NCHANSthe number of channels
AThe Lanczos filter size for the LanczosResampler resampler mode A higher value makes the filter closer to an ideal stop-band that rejects high-frequency content (anti-aliasing), but at the expense of higher latency

Definition at line 44 of file RealtimeResampler.h.

Member Typedef Documentation

◆ BlockProcessFunc

template<typename T = double, int NCHANS = 2, size_t A = 12>
using RealtimeResampler< T, NCHANS, A >::BlockProcessFunc = std::function<void(T**, T**, int, int)>

Definition at line 56 of file RealtimeResampler.h.

◆ LanczosResampler

template<typename T = double, int NCHANS = 2, size_t A = 12>
using RealtimeResampler< T, NCHANS, A >::LanczosResampler = LanczosResampler<T, NCHANS, A>

Definition at line 57 of file RealtimeResampler.h.

Member Enumeration Documentation

◆ ESRCMode

template<typename T = double, int NCHANS = 2, size_t A = 12>
enum class RealtimeResampler::ESRCMode
strong

Definition at line 49 of file RealtimeResampler.h.

Constructor & Destructor Documentation

◆ RealtimeResampler()

template<typename T = double, int NCHANS = 2, size_t A = 12>
RealtimeResampler< T, NCHANS, A >::RealtimeResampler ( double  innerSampleRate,
ESRCMode  mode = ESRCMode::kLancsoz 
)
inline

Constructor.

Parameters
innerSampleRateThe sample rate that the provided DSP block will process at
modeThe sample rate conversion mode

Definition at line 63 of file RealtimeResampler.h.

Member Function Documentation

◆ GetLatency()

template<typename T = double, int NCHANS = 2, size_t A = 12>
int RealtimeResampler< T, NCHANS, A >::GetLatency ( ) const
inline

Get the latency of the resampling, not including any latency of the encapsulated DSP.

Definition at line 174 of file RealtimeResampler.h.

◆ ProcessBlock()

template<typename T = double, int NCHANS = 2, size_t A = 12>
void RealtimeResampler< T, NCHANS, A >::ProcessBlock ( T **  inputs,
T **  outputs,
int  nFrames,
int  nChans,
BlockProcessFunc  func 
)
inline

Resample an input block with a per-block function (resample input -> process with function -> resample back to external sample rate)

Parameters
inputsTwo-dimensional array containing the non-interleaved input buffers of audio samples for all channels
outputsTwo-dimensional array for audio output (non-interleaved).
nFramesThe block size for this block: number of samples per channel.
funcThe function that processes the audio sample at the higher sampling rate. NOTE: std::function can call malloc if you pass in captures

Definition at line 128 of file RealtimeResampler.h.

◆ Reset()

template<typename T = double, int NCHANS = 2, size_t A = 12>
void RealtimeResampler< T, NCHANS, A >::Reset ( double  inputSampleRate,
int  maxBlockSize = DEFAULT_BLOCK_SIZE 
)
inline

Reset the underlying DSP (when the samplerate or max expected block size changes)

Parameters
inputSampleRateThe external sample rate interacting with this object.
maxBlockSizeThe largest block size expected to be passed via nFrames in processBlock

Definition at line 76 of file RealtimeResampler.h.


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