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

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

#include <resampler_writer.h>

Inheritance diagram for roc::audio::ResamplerWriter:
Collaboration diagram for roc::audio::ResamplerWriter:

Public Member Functions

 ResamplerWriter (IWriter &writer, 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 write (Frame &)
 Read audio frame. More...
 
bool set_scaling (float)
 Set new resample factor. More...
 

Detailed Description

Resamples audio stream with non-integer dynamically changing factor.

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

Definition at line 31 of file resampler_writer.h.

Constructor & Destructor Documentation

roc::audio::ResamplerWriter::ResamplerWriter ( IWriter writer,
core::BufferPool< sample_t > &  buffer_pool,
core::IAllocator allocator,
const ResamplerConfig config,
packet::channel_mask_t  channels,
size_t  frame_size 
)

Initialize.

Parameters

  • writer specifies output audio stream used in write()
  • 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

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

Set new resample factor.

Remarks
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::ResamplerWriter::valid ( ) const

Check if object is successfully constructed.

virtual void roc::audio::ResamplerWriter::write ( Frame )
virtual

Read audio frame.

Remarks
Calculates everything during this call so it may take time.

Implements roc::audio::IWriter.


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