HephAudio v3.1.0
A cross-platform C++ library for recording, playing, and processing audio on Windows, Android, Linux, iOS, and macOS.
Loading...
Searching...
No Matches
HephAudio::Resampler Class Reference

changes the sample rate. More...

#include <Resampler.h>

Inheritance diagram for HephAudio::Resampler:
HephAudio::DoubleBufferedAudioEffect HephAudio::AudioEffect

Public Member Functions

 Resampler ()
 
 Resampler (size_t outputSampleRate)
 
virtual ~Resampler ()=default
 
virtual std::string Name () const override
 
virtual size_t CalculateRequiredFrameCount (size_t outputFrameCount, const AudioFormatInfo &formatInfo) const override
 
virtual size_t CalculateOutputFrameCount (size_t inputFrameCount, const AudioFormatInfo &formatInfo) const override
 
virtual size_t CalculateAdvanceSize (size_t renderFrameCount, const AudioFormatInfo &formatInfo) const override
 
virtual size_t GetOutputSampleRate () const
 
virtual void SetOutputSampleRate (size_t outputSampleRate)
 
- Public Member Functions inherited from HephAudio::DoubleBufferedAudioEffect
virtual ~DoubleBufferedAudioEffect ()=default
 
virtual void Process (AudioBuffer &buffer, size_t startIndex, size_t frameCount) override
 
virtual void Process (AudioBuffer &buffer)
 
virtual void Process (AudioBuffer &buffer, size_t startIndex)
 
- Public Member Functions inherited from HephAudio::AudioEffect
virtual ~AudioEffect ()=default
 
virtual bool HasMTSupport () const
 
virtual bool HasRTSupport () const
 
virtual size_t GetThreadCount () const
 
virtual void SetThreadCount (size_t threadCount)
 
virtual void ResetInternalState ()
 

Protected Member Functions

virtual void ProcessST (const AudioBuffer &inputBuffer, AudioBuffer &outputBuffer, size_t startIndex, size_t frameCount) override
 
virtual AudioBuffer CreateOutputBuffer (const AudioBuffer &inputBuffer, size_t startIndex, size_t frameCount) const override
 
virtual void InitializeOutputBuffer (const AudioBuffer &inputBuffer, AudioBuffer &outputBuffer, size_t startIndex, size_t frameCount) const override
 
- Protected Member Functions inherited from HephAudio::DoubleBufferedAudioEffect
 DoubleBufferedAudioEffect ()
 
- Protected Member Functions inherited from HephAudio::AudioEffect
 AudioEffect ()
 
virtual void ProcessMT (const AudioBuffer &inputBuffer, AudioBuffer &outputBuffer, size_t startIndex, size_t frameCount)
 

Protected Attributes

size_t outputSampleRate
 
- Protected Attributes inherited from HephAudio::AudioEffect
size_t threadCount
 

Detailed Description

changes the sample rate.

Constructor & Destructor Documentation

◆ Resampler() [1/2]

HephAudio::Resampler::Resampler ( )

creates a new instance and initializes it with default values.

◆ Resampler() [2/2]

HephAudio::Resampler::Resampler ( size_t outputSampleRate)
explicit

creates a new instance and initializes it with the provided values.

Parameters
outputSampleRatethe sample rate the input will be converted to.

◆ ~Resampler()

virtual HephAudio::Resampler::~Resampler ( )
virtualdefault

releases the resources and destroys the instance.

Member Function Documentation

◆ Name()

virtual std::string HephAudio::Resampler::Name ( ) const
overridevirtual

gets the name of the audio effect.

Implements HephAudio::AudioEffect.

◆ CalculateRequiredFrameCount()

virtual size_t HephAudio::Resampler::CalculateRequiredFrameCount ( size_t outputFrameCount,
const AudioFormatInfo & formatInfo ) const
overridevirtual

calculates the number of frames required to obtain the number of frames desired for the output buffer.

Parameters
outputFrameCountthe number of frames desired for the output buffer.
formatInfothe format info of the input buffer.

Reimplemented from HephAudio::AudioEffect.

◆ CalculateOutputFrameCount()

virtual size_t HephAudio::Resampler::CalculateOutputFrameCount ( size_t inputFrameCount,
const AudioFormatInfo & formatInfo ) const
overridevirtual

calculates the number of frames the buffer will contain after applying the effect.

Parameters
inputFrameCountthe number of frames of the input buffer.
formatInfothe format info of the input buffer.

Reimplemented from HephAudio::AudioEffect.

◆ CalculateAdvanceSize()

virtual size_t HephAudio::Resampler::CalculateAdvanceSize ( size_t renderFrameCount,
const AudioFormatInfo & formatInfo ) const
overridevirtual

calculates the number of frames to process and advance for the current render event.

Parameters
renderFrameCountnumber of audio frames that will be rendered.
formatInfothe format info of the input buffer.

Reimplemented from HephAudio::AudioEffect.

◆ GetOutputSampleRate()

virtual size_t HephAudio::Resampler::GetOutputSampleRate ( ) const
virtual

gets the output sample rate.

◆ SetOutputSampleRate()

virtual void HephAudio::Resampler::SetOutputSampleRate ( size_t outputSampleRate)
virtual

sets the output sample rate.

Parameters
outputSampleRatethe sample rate the input will be converted to.

◆ ProcessST()

virtual void HephAudio::Resampler::ProcessST ( const AudioBuffer & inputBuffer,
AudioBuffer & outputBuffer,
size_t startIndex,
size_t frameCount )
overrideprotectedvirtual

applies the effect using single thread.

Parameters
inputBuffercontains the audio data which will be processed.
outputBuffercontains the processed audio data.
startIndexindex of the first sample to process.
frameCountnumber of frames to process.

Implements HephAudio::AudioEffect.

◆ CreateOutputBuffer()

virtual AudioBuffer HephAudio::Resampler::CreateOutputBuffer ( const AudioBuffer & inputBuffer,
size_t startIndex,
size_t frameCount ) const
overrideprotectedvirtual

creates the output buffer but does not initialize it.

Parameters
inputBuffercontains the audio data which will be processed.
startIndexindex of the first sample to process.
frameCountnumber of frames to process.

Reimplemented from HephAudio::DoubleBufferedAudioEffect.

◆ InitializeOutputBuffer()

virtual void HephAudio::Resampler::InitializeOutputBuffer ( const AudioBuffer & inputBuffer,
AudioBuffer & outputBuffer,
size_t startIndex,
size_t frameCount ) const
overrideprotectedvirtual

initializes the output buffer.

Parameters
inputBuffercontains the audio data which will be processed.
outputBuffercontains the processed audio data.
startIndexindex of the first sample to process.
frameCountnumber of frames to process.

Reimplemented from HephAudio::DoubleBufferedAudioEffect.

Member Data Documentation

◆ outputSampleRate

size_t HephAudio::Resampler::outputSampleRate
protected

the sample rate the input will be converted to.