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

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

#include <RmsNormalizer.h>

Inheritance diagram for HephAudio::RmsNormalizer:
HephAudio::AudioEffect

Public Member Functions

 RmsNormalizer ()
 
 RmsNormalizer (heph_audio_sample_t targetRms)
 
 RmsNormalizer (heph_audio_sample_t peakAmplitude, double smoothingFactor)
 
virtual ~RmsNormalizer ()=default
 
virtual std::string Name () const override
 
virtual double GetTargetRms () const
 
virtual void SetTargetRms (double targetRms)
 
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

double targetRms
 
double currentRms
 
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 RMS.

Constructor & Destructor Documentation

◆ RmsNormalizer() [1/3]

HephAudio::RmsNormalizer::RmsNormalizer ( )

creates a new instance and initializes it with default values.

◆ RmsNormalizer() [2/3]

HephAudio::RmsNormalizer::RmsNormalizer ( heph_audio_sample_t targetRms)
explicit

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

Parameters
targetRmsdesired RMS value for the output signal.

◆ RmsNormalizer() [3/3]

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

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

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

◆ ~RmsNormalizer()

virtual HephAudio::RmsNormalizer::~RmsNormalizer ( )
virtualdefault

releases the resources and destroys the instance.

Member Function Documentation

◆ Name()

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

gets the name of the audio effect.

Implements HephAudio::AudioEffect.

◆ GetTargetRms()

virtual double HephAudio::RmsNormalizer::GetTargetRms ( ) const
virtual

gets the target RMS.

◆ SetTargetRms()

virtual void HephAudio::RmsNormalizer::SetTargetRms ( double targetRms)
virtual

sets the target RMS.

Parameters
targetRmsdesired RMS value for the output signal.

◆ GetSmoothingFactor()

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

gets the smoothing factor.

◆ SetSmoothingFactor()

virtual void HephAudio::RmsNormalizer::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::RmsNormalizer::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

◆ targetRms

double HephAudio::RmsNormalizer::targetRms
protected

desired RMS value for the output signal.

◆ currentRms

double HephAudio::RmsNormalizer::currentRms
protected

RMS value of the current input signal.

◆ lastGain

double HephAudio::RmsNormalizer::lastGain
protected

last gain for smooth transition.

◆ smoothingFactor

double HephAudio::RmsNormalizer::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::RmsNormalizer::mutex
protected

for editing the globalMaxSample.

◆ cv

std::condition_variable HephAudio::RmsNormalizer::cv
protected

for waiting all threads to finish updating the globalMaxSample.

◆ threadsCompleted

size_t HephAudio::RmsNormalizer::threadsCompleted
protected

number of threads completed updating the globalMaxSample.