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::Normalizer Class Reference

normalizes the audio data at the provided amplitude. More...

#include <Normalizer.h>

Inheritance diagram for HephAudio::Normalizer:
HephAudio::AudioEffect

Public Member Functions

 Normalizer ()
 
 Normalizer (heph_audio_sample_t peakAmplitude)
 
 Normalizer (heph_audio_sample_t peakAmplitude, double smoothingFactor)
 
virtual ~Normalizer ()=default
 
virtual std::string Name () const override
 
virtual heph_audio_sample_t GetPeakAmplitude () const
 
virtual void SetPeakAmplitude (heph_audio_sample_t peakAmplitude)
 
virtual double GetSmoothingFactor () const
 
virtual void SetSmoothingFactor (double smoothingFactor)
 
- 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 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

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

Protected Attributes

heph_audio_sample_t peakAmplitude
 
heph_audio_sample_t globalMaxSample
 
double lastGain
 
double smoothingFactor
 
std::mutex mutex
 
std::condition_variable cv
 
size_t threadsCompleted
 
- Protected Attributes inherited from HephAudio::AudioEffect
size_t threadCount
 

Detailed Description

normalizes the audio data at the provided amplitude.

Constructor & Destructor Documentation

◆ Normalizer() [1/3]

HephAudio::Normalizer::Normalizer ( )

creates a new instance and initializes it with default values.

◆ Normalizer() [2/3]

HephAudio::Normalizer::Normalizer ( heph_audio_sample_t peakAmplitude)
explicit

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

Parameters
peakAmplitudemaximum amplitude of the output signal.

◆ Normalizer() [3/3]

HephAudio::Normalizer::Normalizer ( heph_audio_sample_t peakAmplitude,
double smoothingFactor )

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

Parameters
peakAmplitudemaximum amplitude of the output signal.
smoothingFactorfactor for smoothing the gain transition. In the range of [0, 1) where 0 means no smoothing is applied.

◆ ~Normalizer()

virtual HephAudio::Normalizer::~Normalizer ( )
virtualdefault

releases the resources and destroys the instance.

Member Function Documentation

◆ Name()

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

gets the name of the audio effect.

Implements HephAudio::AudioEffect.

◆ GetPeakAmplitude()

virtual heph_audio_sample_t HephAudio::Normalizer::GetPeakAmplitude ( ) const
virtual

gets the peak amplitude

◆ SetPeakAmplitude()

virtual void HephAudio::Normalizer::SetPeakAmplitude ( heph_audio_sample_t peakAmplitude)
virtual

sets the peak amplitude.

Parameters
peakAmplitudemaximum amplitude of the output signal.

◆ GetSmoothingFactor()

virtual double HephAudio::Normalizer::GetSmoothingFactor ( ) const
virtual

gets the smoothing factor.

◆ SetSmoothingFactor()

virtual void HephAudio::Normalizer::SetSmoothingFactor ( double smoothingFactor)
virtual

sets the smoothing factor.

Parameters
smoothingFactorfactor for smoothing the gain transition. In the range of [0, 1) where 0 means no smoothing is applied.

◆ ProcessST()

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

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.

Implements HephAudio::AudioEffect.

Member Data Documentation

◆ peakAmplitude

heph_audio_sample_t HephAudio::Normalizer::peakAmplitude
protected

maximum amplitude of the output signal.

◆ globalMaxSample

heph_audio_sample_t HephAudio::Normalizer::globalMaxSample
protected

the maximum sample the input buffer contains.

◆ lastGain

double HephAudio::Normalizer::lastGain
protected

last gain for smooth transition.

◆ smoothingFactor

double HephAudio::Normalizer::smoothingFactor
protected

factor for smoothing the gain transition. In the range of [0, 1) where 0 means no smoothing is applied.

◆ mutex

std::mutex HephAudio::Normalizer::mutex
protected

for editing the globalMaxSample.

◆ cv

std::condition_variable HephAudio::Normalizer::cv
protected

for waiting all threads to finish updating the globalMaxSample.

◆ threadsCompleted

size_t HephAudio::Normalizer::threadsCompleted
protected

number of threads completed updating the globalMaxSample.