Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
roc::audio::IResampler Class Referenceabstract

Audio writer interface. More...

#include <iresampler.h>

Inheritance diagram for roc::audio::IResampler:
Collaboration diagram for roc::audio::IResampler:

Public Member Functions

 IResampler (core::IArena &arena)
 Initialization. More...
 
virtual ~IResampler ()
 Deinitialization. More...
 
virtual bool is_valid () const =0
 Check if object is successfully constructed. More...
 
virtual bool set_scaling (size_t input_rate, size_t output_rate, float multiplier)=0
 Set new resample factor. More...
 
virtual const core::Slice< sample_t > & begin_push_input ()=0
 Get buffer to be filled with input data. More...
 
virtual void end_push_input ()=0
 Commit buffer with input data. More...
 
virtual size_t pop_output (sample_t *out_data, size_t out_size)=0
 Read samples from input buffer and fill output frame. More...
 
virtual float n_left_to_process () const =0
 How many samples were pushed but not processed yet. More...
 
- Public Member Functions inherited from roc::core::RefCounted< IResampler, core::ArenaAllocation >
 RefCounted ()
 Initialize. More...
 
 RefCounted (const core::ArenaAllocation &policy)
 Initialize. More...
 
int getref () const
 Get reference counter. More...
 
void incref () const
 Increment reference counter. More...
 
void decref () const
 Decrement reference counter. More...
 

Additional Inherited Members

- Protected Member Functions inherited from roc::core::ArenaAllocation
IArenaarena () const
 Get arena. More...
 
 ArenaAllocation (IArena &arena)
 Initialize. More...
 
template<class T >
void destroy (T &object)
 Destroy object and return memory to arena. More...
 

Detailed Description

Audio writer interface.

Definition at line 24 of file iresampler.h.

Constructor & Destructor Documentation

◆ IResampler()

roc::audio::IResampler::IResampler ( core::IArena arena)

Initialization.

◆ ~IResampler()

virtual roc::audio::IResampler::~IResampler ( )
virtual

Deinitialization.

Member Function Documentation

◆ begin_push_input()

virtual const core::Slice<sample_t>& roc::audio::IResampler::begin_push_input ( )
pure virtual

Get buffer to be filled with input data.

Remarks
After this call, the caller should fill returned buffer with input data and invoke end_push_input().

Implemented in roc::audio::SpeexResampler, roc::audio::DecimationResampler, and roc::audio::BuiltinResampler.

◆ end_push_input()

virtual void roc::audio::IResampler::end_push_input ( )
pure virtual

Commit buffer with input data.

Remarks
Should be called after begin_push_input() to commit the push operation.

Implemented in roc::audio::SpeexResampler, roc::audio::DecimationResampler, and roc::audio::BuiltinResampler.

◆ is_valid()

virtual bool roc::audio::IResampler::is_valid ( ) const
pure virtual

Check if object is successfully constructed.

Implemented in roc::audio::SpeexResampler, roc::audio::DecimationResampler, and roc::audio::BuiltinResampler.

◆ n_left_to_process()

virtual float roc::audio::IResampler::n_left_to_process ( ) const
pure virtual

How many samples were pushed but not processed yet.

Remarks
If last input sample pushed to resampler has number N, then last output sample popped from resampler corresponds to input sample number N - n_left_to_process().
Note
It is float, as a resampler backend could possibly keep track of current position from output stream perspective.
Returns
Number of samples multiplied by channel count.

Implemented in roc::audio::SpeexResampler, roc::audio::DecimationResampler, and roc::audio::BuiltinResampler.

◆ pop_output()

virtual size_t roc::audio::IResampler::pop_output ( sample_t out_data,
size_t  out_size 
)
pure virtual

Read samples from input buffer and fill output frame.

Remarks
May return lesser samples than requested if there are no more samples in the input ring buffer. In this case the caller should provide resampler with more input samples using begin_push_input() and end_push_input().

Implemented in roc::audio::SpeexResampler, roc::audio::DecimationResampler, and roc::audio::BuiltinResampler.

◆ set_scaling()

virtual bool roc::audio::IResampler::set_scaling ( size_t  input_rate,
size_t  output_rate,
float  multiplier 
)
pure virtual

Set new resample factor.

Remarks
Returns false if the scaling is invalid or out of bounds.

Implemented in roc::audio::SpeexResampler, roc::audio::DecimationResampler, and roc::audio::BuiltinResampler.


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