eDSP  0.0.1
A cross-platform DSP library written in C++.
Public Types | Public Member Functions | Static Public Member Functions | List of all members
edsp::io::resampler< T > Class Template Reference

This class implements a resampler object to perform sample-rate conversion. More...

#include <resampler.hpp>

Public Types

using value_type = T
 
using size_type = long
 
using error_type = int
 

Public Member Functions

 resampler (size_type channels, resample_quality quality, value_type factor)
 Creates a resampler with the given configuration. More...
 
 ~resampler ()=default
 Default destructor. More...
 
template<typename InputIt , typename OutputIt >
size_type process (InputIt first, InputIt last, OutputIt d_first)
 Resamples the input elements in the range [first, last) and stores the result in another range, beginning at d_first. More...
 
resample_quality quality () const
 Returns the quality used in the resampling process. More...
 
error_type reset ()
 Resets the internal buffers. More...
 
error_type error () const
 Returns the internal error code. More...
 
const edsp::string_view error_string () const
 Returns a description of the internal error code. More...
 

Static Public Member Functions

static bool valid_ratio (value_type ratio)
 Checks if a ratio is valid. More...
 

Detailed Description

template<typename T>
class edsp::io::resampler< T >

This class implements a resampler object to perform sample-rate conversion.

The class resamples an input signal in a factor proportional to the desired sample-rate..

Member Typedef Documentation

◆ error_type

template<typename T >
using edsp::io::resampler< T >::error_type = int

◆ size_type

template<typename T >
using edsp::io::resampler< T >::size_type = long

◆ value_type

template<typename T >
using edsp::io::resampler< T >::value_type = T

Constructor & Destructor Documentation

◆ resampler()

template<typename T >
edsp::io::resampler< T >::resampler ( size_type  channels,
resample_quality  quality,
value_type  factor 
)
inline

Creates a resampler with the given configuration.

Parameters
channelsNumber of channels.
qualityQuality of the resampling process.
factorResampling factor (output samplerate / input samplerate)

◆ ~resampler()

template<typename T >
edsp::io::resampler< T >::~resampler ( )
default

Default destructor.

Member Function Documentation

◆ error()

template<typename T >
error_type edsp::io::resampler< T >::error ( ) const
inline

Returns the internal error code.

Returns
Return non zero on error.

◆ error_string()

template<typename T >
const edsp::string_view edsp::io::resampler< T >::error_string ( ) const
inline

Returns a description of the internal error code.

Returns
Description of the internal error code.

◆ process()

template<typename T >
template<typename InputIt , typename OutputIt >
size_type edsp::io::resampler< T >::process ( InputIt  first,
InputIt  last,
OutputIt  d_first 
)
inline

Resamples the input elements in the range [first, last) and stores the result in another range, beginning at d_first.

The output size is proportional to the input in a factor of \( \lambda \), where lambda is:

\[ \lambda = \frac{f_{si}}{f_{so}} \]

where \( f_{si} \) and \( f_{so} \) are the input size and the output size respectively.

Note
It is recommended to allocate at least \( \lambda N \) samples, where \( N \) is the input size. The user can use the returned counter to resize the output buffer after the processing.
Parameters
firstInput iterator defining the beginning of the input range.
lastInput iterator defining the ending of the input range.
d_firstOutput iterator defining the beginning of the destination range.
Returns
Number of samples computed in the output range.

◆ quality()

template<typename T >
resample_quality edsp::io::resampler< T >::quality ( ) const
inline

Returns the quality used in the resampling process.

Returns
Resampling quality.

◆ reset()

template<typename T >
error_type edsp::io::resampler< T >::reset ( )
inline

Resets the internal buffers.

Returns
Returns non zero on error.

◆ valid_ratio()

template<typename T >
static bool edsp::io::resampler< T >::valid_ratio ( value_type  ratio)
inlinestatic

Checks if a ratio is valid.

Parameters
ratioRatio to be tested
Returns
true if the ratio is valid, false otherwise.

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