OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
MWSound::Sound_Loudness Class Reference

#include <loudness.hpp>

Collaboration diagram for MWSound::Sound_Loudness:

Public Member Functions

 Sound_Loudness (float samplesPerSecond, int sampleRate, ChannelConfig chans, SampleType type)
 
void analyzeLoudness (const std::vector< char > &data)
 
float getLoudnessAtTime (float sec) const
 

Private Attributes

float mSamplesPerSec
 
int mSampleRate
 
ChannelConfig mChannelConfig
 
SampleType mSampleType
 
std::vector< float > mSamples
 
std::deque< char > mQueue
 

Constructor & Destructor Documentation

MWSound::Sound_Loudness::Sound_Loudness ( float  samplesPerSecond,
int  sampleRate,
ChannelConfig  chans,
SampleType  type 
)
inline
Parameters
samplesPerSecondHow many loudness values per second of audio to compute.
sampleRatethe sample rate of the sound buffer
chanschannel layout of the buffer
typesample type of the buffer

Member Function Documentation

void MWSound::Sound_Loudness::analyzeLoudness ( const std::vector< char > &  data)

Analyzes the energy (closely related to loudness) of a sound buffer. The buffer will be divided into segments according to valuesPerSecond, and for each segment a loudness value in the range of [0,1] will be computed. The computed values are then added to the mSamples vector. This method should be called continuously with chunks of audio until the whole audio file is processed. If the size of data does not exactly fit a number of loudness samples, the remainder will be kept in the mQueue and used in the next call to analyzeLoudness.

Parameters
datathe sound buffer to analyze, containing raw samples

Here is the call graph for this function:

float MWSound::Sound_Loudness::getLoudnessAtTime ( float  sec) const

Get loudness at a particular time. Before calling this, the stream has to be analyzed up to that point in time (see analyzeLoudness()).

Member Data Documentation

ChannelConfig MWSound::Sound_Loudness::mChannelConfig
private
std::deque<char> MWSound::Sound_Loudness::mQueue
private
int MWSound::Sound_Loudness::mSampleRate
private
std::vector<float> MWSound::Sound_Loudness::mSamples
private
float MWSound::Sound_Loudness::mSamplesPerSec
private
SampleType MWSound::Sound_Loudness::mSampleType
private

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