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

base class for the audio effects. More...

#include <AudioEffect.h>

Inheritance diagram for HephAudio::AudioEffect:
HephAudio::ArctanDistortion HephAudio::CubicDistortion HephAudio::DoubleBufferedAudioEffect HephAudio::Echo HephAudio::HardClipDistortion HephAudio::LinearFadeIn HephAudio::LinearFadeOut HephAudio::Normalizer HephAudio::Overdrive HephAudio::PanningEffect HephAudio::RmsNormalizer

Public Member Functions

virtual ~AudioEffect ()=default
 
virtual std::string Name () const =0
 
virtual bool HasMTSupport () const
 
virtual bool HasRTSupport () const
 
virtual size_t GetThreadCount () const
 
virtual void SetThreadCount (size_t threadCount)
 
virtual size_t CalculateRequiredFrameCount (size_t outputFrameCount, const AudioFormatInfo &formatInfo) const
 
virtual size_t CalculateOutputFrameCount (const AudioBuffer &buffer) const
 
virtual void Process (AudioBuffer &buffer)
 
virtual void Process (AudioBuffer &buffer, size_t startIndex)
 
virtual void Process (AudioBuffer &buffer, size_t startIndex, size_t frameCount)
 

Protected Member Functions

 AudioEffect ()
 
virtual void ProcessST (const AudioBuffer &inputBuffer, AudioBuffer &outputBuffer, size_t startIndex, size_t frameCount)=0
 
virtual void ProcessMT (const AudioBuffer &inputBuffer, AudioBuffer &outputBuffer, size_t startIndex, size_t frameCount)
 

Protected Attributes

size_t threadCount
 

Detailed Description

base class for the audio effects.

Constructor & Destructor Documentation

◆ AudioEffect()

HephAudio::AudioEffect::AudioEffect ( )
protected

creates a new instance and initializes it with default values.

◆ ~AudioEffect()

virtual HephAudio::AudioEffect::~AudioEffect ( )
virtualdefault

releases the resources and destroys the instance.

Member Function Documentation

◆ Name()

◆ HasMTSupport()

virtual bool HephAudio::AudioEffect::HasMTSupport ( ) const
virtual

checks whether the effect can be applied using multiple threads.

◆ HasRTSupport()

virtual bool HephAudio::AudioEffect::HasRTSupport ( ) const
virtual

checks whether the effect can be applied in real-time.

◆ GetThreadCount()

virtual size_t HephAudio::AudioEffect::GetThreadCount ( ) const
virtual

gets the number of threads that will be used.

◆ SetThreadCount()

virtual void HephAudio::AudioEffect::SetThreadCount ( size_t threadCount)
virtual

sets the number of threads that will be used.

Parameters
threadCountnumber of threads that will be used.

◆ CalculateRequiredFrameCount()

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

calculates the number of frames required to obtain the number of frames desired for the output buffer. Useful for applying effects that depend on past and/or future samples in real-time.

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

Reimplemented in HephAudio::Chorus, and HephAudio::Vibrato.

◆ CalculateOutputFrameCount()

virtual size_t HephAudio::AudioEffect::CalculateOutputFrameCount ( const AudioBuffer & buffer) const
virtual

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

Parameters
buffercontains the audio data which will be processed.

◆ Process() [1/3]

virtual void HephAudio::AudioEffect::Process ( AudioBuffer & buffer)
virtual

Applies the effect.

Parameters
buffercontains the audio data which will be processed.

Reimplemented in HephAudio::DoubleBufferedAudioEffect, HephAudio::Echo, HephAudio::LinearFadeIn, HephAudio::LinearFadeOut, HephAudio::ModulationEffect, HephAudio::PanningEffect, HephAudio::Tremolo, and HephAudio::Vibrato.

◆ Process() [2/3]

virtual void HephAudio::AudioEffect::Process ( AudioBuffer & buffer,
size_t startIndex )
virtual

Applies the effect.

Parameters
buffercontains the audio data which will be processed.
startIndexindex of the first audio frame to process.

Reimplemented in HephAudio::DoubleBufferedAudioEffect, HephAudio::Echo, HephAudio::LinearFadeIn, HephAudio::LinearFadeOut, HephAudio::ModulationEffect, HephAudio::PanningEffect, HephAudio::Tremolo, and HephAudio::Vibrato.

◆ Process() [3/3]

virtual void HephAudio::AudioEffect::Process ( AudioBuffer & buffer,
size_t startIndex,
size_t frameCount )
virtual

Applies the effect.

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

Reimplemented in HephAudio::DoubleBufferedAudioEffect, HephAudio::Echo, HephAudio::Flanger, HephAudio::LinearFadeIn, HephAudio::LinearFadeOut, HephAudio::ModulationEffect, HephAudio::PanningEffect, HephAudio::Tremolo, and HephAudio::Vibrato.

◆ ProcessST()

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

applies the effect using single thread.

Parameters
inputBuffercontains the dry data.
outputBuffercontains the wet data.
startIndexindex of the first sample to process.
frameCountnumber of frames to process.

Implemented in HephAudio::ArctanDistortion, HephAudio::Chorus, HephAudio::CubicDistortion, HephAudio::Echo, HephAudio::Flanger, HephAudio::HardClipDistortion, HephAudio::LinearFadeIn, HephAudio::LinearFadeOut, HephAudio::Normalizer, HephAudio::Overdrive, HephAudio::PanningEffect, HephAudio::RmsNormalizer, HephAudio::Tremolo, and HephAudio::Vibrato.

◆ ProcessMT()

virtual void HephAudio::AudioEffect::ProcessMT ( const AudioBuffer & inputBuffer,
AudioBuffer & outputBuffer,
size_t startIndex,
size_t frameCount )
protectedvirtual

applies the effect using multiple threads.

Parameters
inputBuffercontains the dry data.
outputBuffercontains the wet data.
startIndexindex of the first sample to process.
frameCountnumber of frames to process.

Member Data Documentation

◆ threadCount

size_t HephAudio::AudioEffect::threadCount
protected

number of threads that will be used.