Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
roc::audio::ResamplerReader Class Reference

Resamples audio stream with non-integer dynamically changing factor. More...

#include <resampler_reader.h>

Inheritance diagram for roc::audio::ResamplerReader:
Collaboration diagram for roc::audio::ResamplerReader:

Public Member Functions

 ResamplerReader (IReader &reader, core::BufferPool< sample_t > &buffer_pool, core::IAllocator &allocator, const ResamplerConfig &config, packet::channel_mask_t channels, size_t frame_size)
 Initialize. More...
bool valid () const
 Check if object is successfully constructed. More...
virtual void read (Frame &)
 Read audio frame. More...
bool set_scaling (float)
 Set new resample factor. More...
- Public Member Functions inherited from roc::core::ListNode
ListNodeDatalist_node_data () const
 Get list node data. More...

Detailed Description

Resamples audio stream with non-integer dynamically changing factor.

Typicaly being used with factor close to 1 ( 0.9 < factor < 1.1 ).

Definition at line 31 of file resampler_reader.h.

Constructor & Destructor Documentation

roc::audio::ResamplerReader::ResamplerReader ( IReader reader,
core::BufferPool< sample_t > &  buffer_pool,
core::IAllocator allocator,
const ResamplerConfig config,
packet::channel_mask_t  channels,
size_t  frame_size 



  • reader specifies input audio stream used in read()
  • buffer_pool is used to allocate temporary buffers
  • frame_size is number of samples per resampler frame per audio channel
  • channels is the bitmask of audio channels

Member Function Documentation

virtual void roc::audio::ResamplerReader::read ( Frame )

Read audio frame.

Calculates everything during this call so it may take time.

Implements roc::audio::IReader.

bool roc::audio::ResamplerReader::set_scaling ( float  )

Set new resample factor.

Resampling algorithm needs some window of input samples. The length of the window (length of sinc impulse response) is a compromise between SNR and speed. It depends on current resampling factor. So we choose length of input buffers to let it handle maximum length of input. If new scaling factor breaks equation this function returns false.
bool roc::audio::ResamplerReader::valid ( ) const

Check if object is successfully constructed.

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