Code_TYMPAN  4.2.0
Industrial site acoustic simulation
Public Member Functions | Static Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
OSpectre Class Reference

Store acoustic power values for different frequencies. More...

#include <spectre.h>

Inheritance diagram for OSpectre:
Inheritance graph
[legend]
Collaboration diagram for OSpectre:
Collaboration graph
[legend]

Public Member Functions

 OSpectre ()
 Default constructor, the spectrum module is defined by the _defaultValue. More...
 
 OSpectre (double defaultValue)
 Constructor, the spectrum module is defined by the defaultValue given in parameter. More...
 
 OSpectre (const OSpectre &other)
 Copy constructor. More...
 
 OSpectre (const double *valeurs, unsigned nbVal, unsigned decalage)
 Constructor from an array (needed for the Harmonoise model) More...
 
virtual ~OSpectre ()
 Destructor. More...
 
virtual OSpectreoperator= (const OSpectre &other)
 operator= More...
 
virtual bool operator== (const OSpectre &other) const
 operator== More...
 
virtual bool operator!= (const OSpectre &other) const
 operator != More...
 
OSpectre operator* (const OSpectre &spectre) const
 Multiplication by a Spectre spectrum. More...
 
OSpectre operator* (const double &coefficient) const
 Multiplication by a double coefficient. More...
 
virtual OSpectre operator+ (const double &valeur) const
 Add a constant value to all the spectrum. More...
 
virtual OSpectre operator+ (const OSpectre &spectre) const
 Arithmetic sum of two spectrums in one-third Octave. More...
 
virtual OSpectre operator- (const OSpectre &spectre) const
 Arithmetic subtraction of two spectrums in one-third Octave. More...
 
virtual bool isValid () const
 Check the spectrum validity. Invalidity is caused by: corrupted data, impossible calculation. More...
 
virtual void setValid (const bool &valid=true)
 
virtual TYSpectreType getType () const
 Get the spectrum type. More...
 
virtual void setType (TYSpectreType type)
 Set the spectrum type. More...
 
virtual TYSpectreEtat getEtat () const
 Get the spectrum state. More...
 
virtual const TYSpectreEtat getEtat ()
 
void setEtat (TYSpectreEtat etat)
 Force the spectrum state (to use carefully ...) More...
 
virtual double * getTabValReel ()
 
virtual const double * getTabValReel () const
 
virtual unsigned int getNbValues () const
 Number of values in the spectrum. More...
 
virtual void setDefaultValue (const double &valeur=TY_SPECTRE_DEFAULT_VALUE)
 
virtual void setValue (const float &freq, const double &reel=0.0)
 
virtual double getValueReal (double freq)
 
virtual void getRangeValueReal (double *valeurs, const short &nbVal, const short &decalage)
 
virtual double valGlobDBLin () const
 Compute the global value dB[Lin] of a one-third Octave spectrum. More...
 
virtual double valGlobDBA () const
 Compute the global value dB[A] of a one-third Octave spectrum. More...
 
virtual OSpectre toDB () const
 Converts to dB. More...
 
virtual OSpectre toGPhy () const
 Converts to physical quantity. More...
 
virtual OSpectre sum (const OSpectre &spectre) const
 Arithmetic sum of two spectrums in one-third Octave. More...
 
virtual OSpectre sum (const double &valeur) const
 Add a constant value to this spectrum. More...
 
virtual OSpectre sumdB (const OSpectre &spectre) const
 Energetic sum of two spectrums in one-third Octave. More...
 
virtual OSpectre subst (const OSpectre &spectre) const
 Arithmetic subtraction of two spectrums in one-third Octave. More...
 
virtual OSpectre subst (const double &valeur) const
 Subtract a constant value to this spectrum. More...
 
virtual OSpectre mult (const OSpectre &spectre) const
 Multiplication of two spectrums. More...
 
virtual OSpectre mult (const double &coefficient) const
 Multiply this spectrum par a double scalar. More...
 
virtual OSpectre div (const OSpectre &spectre) const
 Division of two spectrums. More...
 
virtual OSpectre div (const double &coefficient) const
 Division of this spectrum by a double scalar. More...
 
virtual OSpectre invMult (const double &coefficient=1.0) const
 Division of a double constant by this spectrum. More...
 
virtual OSpectre inv () const
 Division of one by this spectrum. More...
 
virtual OSpectre power (const double &puissance) const
 Return a spectrum as this spectrum raised to a double power. More...
 
virtual OSpectre log (const double &base=10.0) const
 Compute the log base n of this spectrum (n=10 by default). More...
 
virtual OSpectre racine () const
 Compute the root square of this spectrum. More...
 
virtual OSpectre exp (const double coef=1.0)
 Compute e^(coef * spectre) of this spectrum. More...
 
virtual OSpectre sin () const
 Compute the sin of this spectrum. More...
 
virtual OSpectre cos () const
 Compute the cos of this spectrum. More...
 
virtual OSpectre abs () const
 Return the absolute value of this spectrum. More...
 
virtual OSpectre sqrt () const
 Return the root square of a spectrum. More...
 
virtual double valMax ()
 Return the maximum value of a spectrum. More...
 
virtual OSpectre seuillage (const double &min=-200.0, const double max=200.0)
 Limit the spectrum values (min and max) More...
 
virtual double sigma ()
 Sum the values of the spectrum. More...
 
virtual const double sigma () const
 
virtual bool isTonalite () const
 Existence d'une tonalite marquee. More...
 
virtual OSpectre toTOct () const
 Converts to one-third Octave. More...
 
virtual OSpectre toOct () const
 Converts to Octave. More...
 
virtual void printme () const
 Print the spectrum. More...
 

Static Public Member Functions

static OSpectre getEmptyLinSpectre (const double &valInit=1.0E-20)
 Create a physical quantity spectrum. More...
 
static OSpectre makeOctSpect ()
 Make a spectrum in Octave. More...
 
static int getIndice (const float &freq)
 Return the index associated to a frequency. More...
 
static void setFMin (const float &fMin)
 Define minimal frequency. More...
 
static void setFMax (const float &fMax)
 Define maximal frequency. More...
 
static OTabFreq getTabFreqExact ()
 
static OSpectre getOSpectreFreqExact ()
 Return the spectrum of the exact frequencies. More...
 
static std::map< double, int > setMapFreqIndice ()
 Construction du tableau frequence/indice. More...
 
static OSpectre pondA ()
 Build a weighted spectrum A. More...
 
static OSpectre pondB ()
 Build a weighted spectrum B. More...
 
static OSpectre pondC ()
 Build a weighted spectrum C. More...
 
static OSpectre getLambda (const double &c)
 

Protected Attributes

bool _valid
 Spectrum validity. More...
 
TYSpectreType _type
 Spectrum type. More...
 
TYSpectreEtat _etat
 Spectrum state (physical quantity or dB). More...
 
TYSpectreForm _form
 Representation of the spectrum: one-third Octave, Octave, constant delta f, unstructured. More...
 
double _module [TY_SPECTRE_DEFAULT_NB_ELMT]
 Real values array for module. More...
 

Static Protected Attributes

static const double _freqNorm []
 Array of center frequencies (Hz) normalized in one-third Octave. More...
 
static double _fMin = 16
 Minimal frequency. More...
 
static double _fMax = 16000
 Maximal frequency. More...
 
static double _defaultValue = TY_SPECTRE_DEFAULT_VALUE
 Default value for the spectrum. More...
 
static std::map< double, int > _mapFreqIndice = setMapFreqIndice()
 Mapping between frequency and array index. More...
 

Detailed Description

Store acoustic power values for different frequencies.

Author
Projet_Tympan

Definition at line 49 of file spectre.h.

Constructor & Destructor Documentation

◆ OSpectre() [1/4]

OSpectre::OSpectre ( )

Default constructor, the spectrum module is defined by the _defaultValue.

Definition at line 53 of file spectre.cpp.

◆ OSpectre() [2/4]

OSpectre::OSpectre ( double  defaultValue)

Constructor, the spectrum module is defined by the defaultValue given in parameter.

Definition at line 61 of file spectre.cpp.

◆ OSpectre() [3/4]

OSpectre::OSpectre ( const OSpectre other)

Copy constructor.

Definition at line 89 of file spectre.cpp.

◆ OSpectre() [4/4]

OSpectre::OSpectre ( const double *  valeurs,
unsigned  nbVal,
unsigned  decalage 
)

Constructor from an array (needed for the Harmonoise model)

Parameters
valeursArray of values per frequency
nbValArray size
decalageFrequency offset relative to the standard band TYMPAN (16-16000)

Definition at line 69 of file spectre.cpp.

◆ ~OSpectre()

OSpectre::~OSpectre ( )
virtual

Destructor.

Definition at line 94 of file spectre.cpp.

Member Function Documentation

◆ abs()

OSpectre OSpectre::abs ( ) const
virtual

Return the absolute value of this spectrum.

Definition at line 573 of file spectre.cpp.

◆ cos()

OSpectre OSpectre::cos ( ) const
virtual

Compute the cos of this spectrum.

Definition at line 561 of file spectre.cpp.

Here is the caller graph for this function:

◆ div() [1/2]

OSpectre OSpectre::div ( const OSpectre spectre) const
virtual

Division of two spectrums.

Definition at line 407 of file spectre.cpp.

Here is the caller graph for this function:

◆ div() [2/2]

OSpectre OSpectre::div ( const double &  coefficient) const
virtual

Division of this spectrum by a double scalar.

Definition at line 426 of file spectre.cpp.

◆ exp()

OSpectre OSpectre::exp ( const double  coef = 1.0)
virtual

Compute e^(coef * spectre) of this spectrum.

Definition at line 537 of file spectre.cpp.

Here is the caller graph for this function:

◆ getEmptyLinSpectre()

OSpectre OSpectre::getEmptyLinSpectre ( const double &  valInit = 1.0E-20)
static

Create a physical quantity spectrum.

Definition at line 637 of file spectre.cpp.

Here is the caller graph for this function:

◆ getEtat() [1/2]

virtual TYSpectreEtat OSpectre::getEtat ( ) const
inlinevirtual

Get the spectrum state.

Definition at line 104 of file spectre.h.

Here is the caller graph for this function:

◆ getEtat() [2/2]

virtual const TYSpectreEtat OSpectre::getEtat ( )
inlinevirtual

Definition at line 105 of file spectre.h.

◆ getIndice()

static int OSpectre::getIndice ( const float &  freq)
inlinestatic

Return the index associated to a frequency.

Definition at line 253 of file spectre.h.

Here is the caller graph for this function:

◆ getLambda()

OSpectre OSpectre::getLambda ( const double &  c)
static

Return a spectrum representating the wavelength associated to each frequency

Parameters
cWave propagating speed
Returns
An OSpectre

Definition at line 726 of file spectre.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getNbValues()

unsigned int OSpectre::getNbValues ( ) const
virtual

Number of values in the spectrum.

Definition at line 789 of file spectre.cpp.

Here is the caller graph for this function:

◆ getOSpectreFreqExact()

OSpectre OSpectre::getOSpectreFreqExact ( )
static

Return the spectrum of the exact frequencies.

Returns
An OSpectre

Definition at line 654 of file spectre.cpp.

Here is the caller graph for this function:

◆ getRangeValueReal()

void OSpectre::getRangeValueReal ( double *  valeurs,
const short &  nbVal,
const short &  decalage 
)
virtual

Get an interval of real values from the frequencies/complex array

Parameters
[out]valeursValues array. It should be allocated before.
[in]nbValNumber of values to retrieve from the spectrum
[in]decalageIndex of the first value to retrieve

Definition at line 212 of file spectre.cpp.

◆ getTabFreqExact()

OTabFreq OSpectre::getTabFreqExact ( )
static

Return the array of exact frequencies. The calling method should free the allocated memory for this array.

Returns
The array of exact frequencies.

Definition at line 644 of file spectre.cpp.

Here is the caller graph for this function:

◆ getTabValReel() [1/2]

virtual double* OSpectre::getTabValReel ( )
inlinevirtual

XXX These are the modulus to put into the solver model. Get the array of real values

Reimplemented in OSpectreComplex.

Definition at line 112 of file spectre.h.

Here is the caller graph for this function:

◆ getTabValReel() [2/2]

virtual const double* OSpectre::getTabValReel ( ) const
inlinevirtual

Reimplemented in OSpectreComplex.

Definition at line 113 of file spectre.h.

Here is the call graph for this function:

◆ getType()

virtual TYSpectreType OSpectre::getType ( ) const
inlinevirtual

Get the spectrum type.

Definition at line 99 of file spectre.h.

Here is the caller graph for this function:

◆ getValueReal()

double OSpectre::getValueReal ( double  freq)
virtual

Get the value for a frequency.

Parameters
freqFrequency.
Returns
The real number.

Definition at line 206 of file spectre.cpp.

Here is the caller graph for this function:

◆ inv()

OSpectre OSpectre::inv ( ) const
virtual

Division of one by this spectrum.

Definition at line 467 of file spectre.cpp.

◆ invMult()

OSpectre OSpectre::invMult ( const double &  coefficient = 1.0) const
virtual

Division of a double constant by this spectrum.

Definition at line 446 of file spectre.cpp.

Here is the caller graph for this function:

◆ isTonalite()

bool OSpectre::isTonalite ( ) const
virtual

Existence d'une tonalite marquee.

Definition at line 760 of file spectre.cpp.

Here is the caller graph for this function:

◆ isValid()

virtual bool OSpectre::isValid ( ) const
inlinevirtual

Check the spectrum validity. Invalidity is caused by: corrupted data, impossible calculation.

Returns
Spectrum state (valid = true / non valid = false).

Definition at line 91 of file spectre.h.

Here is the caller graph for this function:

◆ log()

OSpectre OSpectre::log ( const double &  base = 10.0) const
virtual

Compute the log base n of this spectrum (n=10 by default).

Definition at line 498 of file spectre.cpp.

Here is the caller graph for this function:

◆ makeOctSpect()

OSpectre OSpectre::makeOctSpect ( )
static

Make a spectrum in Octave.

Definition at line 804 of file spectre.cpp.

Here is the caller graph for this function:

◆ mult() [1/2]

OSpectre OSpectre::mult ( const OSpectre spectre) const
virtual

Multiplication of two spectrums.

Definition at line 383 of file spectre.cpp.

Here is the caller graph for this function:

◆ mult() [2/2]

OSpectre OSpectre::mult ( const double &  coefficient) const
virtual

Multiply this spectrum par a double scalar.

Definition at line 395 of file spectre.cpp.

◆ operator!=()

bool OSpectre::operator!= ( const OSpectre other) const
virtual

operator !=

Definition at line 132 of file spectre.cpp.

Here is the call graph for this function:

◆ operator*() [1/2]

OSpectre OSpectre::operator* ( const OSpectre spectre) const

Multiplication by a Spectre spectrum.

Definition at line 137 of file spectre.cpp.

◆ operator*() [2/2]

OSpectre OSpectre::operator* ( const double &  coefficient) const

Multiplication by a double coefficient.

Definition at line 148 of file spectre.cpp.

◆ operator+() [1/2]

OSpectre OSpectre::operator+ ( const double &  valeur) const
virtual

Add a constant value to all the spectrum.

Definition at line 159 of file spectre.cpp.

◆ operator+() [2/2]

OSpectre OSpectre::operator+ ( const OSpectre spectre) const
virtual

Arithmetic sum of two spectrums in one-third Octave.

Definition at line 170 of file spectre.cpp.

◆ operator-()

OSpectre OSpectre::operator- ( const OSpectre spectre) const
virtual

Arithmetic subtraction of two spectrums in one-third Octave.

Definition at line 181 of file spectre.cpp.

◆ operator=()

OSpectre & OSpectre::operator= ( const OSpectre other)
virtual

operator=

Reimplemented in TYSpectre.

Definition at line 98 of file spectre.cpp.

Here is the caller graph for this function:

◆ operator==()

bool OSpectre::operator== ( const OSpectre other) const
virtual

operator==

Definition at line 115 of file spectre.cpp.

Here is the caller graph for this function:

◆ pondA()

OSpectre OSpectre::pondA ( )
static

Build a weighted spectrum A.

Definition at line 664 of file spectre.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pondB()

OSpectre OSpectre::pondB ( )
static

Build a weighted spectrum B.

Definition at line 685 of file spectre.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pondC()

OSpectre OSpectre::pondC ( )
static

Build a weighted spectrum C.

Definition at line 707 of file spectre.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ power()

OSpectre OSpectre::power ( const double &  puissance) const
virtual

Return a spectrum as this spectrum raised to a double power.

Definition at line 486 of file spectre.cpp.

Here is the caller graph for this function:

◆ printme()

void OSpectre::printme ( ) const
virtual

Print the spectrum.

Definition at line 326 of file spectre.cpp.

Here is the caller graph for this function:

◆ racine()

OSpectre OSpectre::racine ( ) const
virtual

Compute the root square of this spectrum.

Definition at line 518 of file spectre.cpp.

Here is the caller graph for this function:

◆ setDefaultValue()

void OSpectre::setDefaultValue ( const double &  valeur = TY_SPECTRE_DEFAULT_VALUE)
virtual

Initialize a spectrum to a default value.

Parameters
valeurValue by default.

Definition at line 192 of file spectre.cpp.

Here is the caller graph for this function:

◆ setEtat()

void OSpectre::setEtat ( TYSpectreEtat  etat)
inline

Force the spectrum state (to use carefully ...)

Definition at line 108 of file spectre.h.

Here is the caller graph for this function:

◆ setFMax()

static void OSpectre::setFMax ( const float &  fMax)
inlinestatic

Define maximal frequency.

Definition at line 258 of file spectre.h.

Here is the call graph for this function:

◆ setFMin()

static void OSpectre::setFMin ( const float &  fMin)
inlinestatic

Define minimal frequency.

Definition at line 256 of file spectre.h.

◆ setMapFreqIndice()

std::map< double, int > OSpectre::setMapFreqIndice ( )
static

Construction du tableau frequence/indice.

Definition at line 625 of file spectre.cpp.

Here is the caller graph for this function:

◆ setType()

virtual void OSpectre::setType ( TYSpectreType  type)
inlinevirtual

Set the spectrum type.

Definition at line 101 of file spectre.h.

Here is the caller graph for this function:

◆ setValid()

virtual void OSpectre::setValid ( const bool &  valid = true)
inlinevirtual

Force the validity state of the spectrum.

Definition at line 96 of file spectre.h.

Here is the caller graph for this function:

◆ setValue()

void OSpectre::setValue ( const float &  freq,
const double &  reel = 0.0 
)
virtual

Set a new value to the frequencies array.

Parameters
freqFrequency to which a new value is given.
reelValue.

Definition at line 200 of file spectre.cpp.

Here is the caller graph for this function:

◆ seuillage()

OSpectre OSpectre::seuillage ( const double &  min = -200.0,
const double  max = 200.0 
)
virtual

Limit the spectrum values (min and max)

Definition at line 608 of file spectre.cpp.

Here is the caller graph for this function:

◆ sigma() [1/2]

double OSpectre::sigma ( )
virtual

Sum the values of the spectrum.

Definition at line 740 of file spectre.cpp.

Here is the caller graph for this function:

◆ sigma() [2/2]

const double OSpectre::sigma ( ) const
virtual

Definition at line 750 of file spectre.cpp.

◆ sin()

OSpectre OSpectre::sin ( ) const
virtual

Compute the sin of this spectrum.

Definition at line 549 of file spectre.cpp.

Here is the caller graph for this function:

◆ sqrt()

OSpectre OSpectre::sqrt ( ) const
virtual

Return the root square of a spectrum.

Definition at line 585 of file spectre.cpp.

Here is the caller graph for this function:

◆ subst() [1/2]

OSpectre OSpectre::subst ( const OSpectre spectre) const
virtual

Arithmetic subtraction of two spectrums in one-third Octave.

Definition at line 359 of file spectre.cpp.

Here is the caller graph for this function:

◆ subst() [2/2]

OSpectre OSpectre::subst ( const double &  valeur) const
virtual

Subtract a constant value to this spectrum.

Definition at line 371 of file spectre.cpp.

◆ sum() [1/2]

OSpectre OSpectre::sum ( const OSpectre spectre) const
virtual

Arithmetic sum of two spectrums in one-third Octave.

Definition at line 314 of file spectre.cpp.

Here is the caller graph for this function:

◆ sum() [2/2]

OSpectre OSpectre::sum ( const double &  valeur) const
virtual

Add a constant value to this spectrum.

Definition at line 336 of file spectre.cpp.

◆ sumdB()

OSpectre OSpectre::sumdB ( const OSpectre spectre) const
virtual

Energetic sum of two spectrums in one-third Octave.

Definition at line 348 of file spectre.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toDB()

OSpectre OSpectre::toDB ( ) const
virtual

Converts to dB.

Definition at line 238 of file spectre.cpp.

Here is the caller graph for this function:

◆ toGPhy()

OSpectre OSpectre::toGPhy ( ) const
virtual

Converts to physical quantity.

Definition at line 279 of file spectre.cpp.

Here is the caller graph for this function:

◆ toOct()

OSpectre OSpectre::toOct ( ) const
virtual

Converts to Octave.

Definition at line 872 of file spectre.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toTOct()

OSpectre OSpectre::toTOct ( ) const
virtual

Converts to one-third Octave.

Definition at line 811 of file spectre.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ valGlobDBA()

double OSpectre::valGlobDBA ( ) const
virtual

Compute the global value dB[A] of a one-third Octave spectrum.

Definition at line 232 of file spectre.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ valGlobDBLin()

double OSpectre::valGlobDBLin ( ) const
virtual

Compute the global value dB[Lin] of a one-third Octave spectrum.

Definition at line 220 of file spectre.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ valMax()

double OSpectre::valMax ( )
virtual

Return the maximum value of a spectrum.

Definition at line 597 of file spectre.cpp.

Member Data Documentation

◆ _defaultValue

double OSpectre::_defaultValue = TY_SPECTRE_DEFAULT_VALUE
staticprotected

Default value for the spectrum.

Definition at line 314 of file spectre.h.

◆ _etat

TYSpectreEtat OSpectre::_etat
protected

Spectrum state (physical quantity or dB).

Definition at line 328 of file spectre.h.

◆ _fMax

double OSpectre::_fMax = 16000
staticprotected

Maximal frequency.

Definition at line 311 of file spectre.h.

◆ _fMin

double OSpectre::_fMin = 16
staticprotected

Minimal frequency.

Definition at line 308 of file spectre.h.

◆ _form

TYSpectreForm OSpectre::_form
protected

Representation of the spectrum: one-third Octave, Octave, constant delta f, unstructured.

Definition at line 331 of file spectre.h.

◆ _freqNorm

const double OSpectre::_freqNorm
staticprotected
Initial value:
= { 16.0, 20.0, 25.0,
31.5, 40.0, 50.0,
63.0, 80.0, 100.0,
125.0, 160.0, 200.0,
250.0, 315.0, 400.0,
500.0, 630.0, 800.0,
1000.0, 1250.0, 1600.0,
2000.0, 2500.0, 3150.0,
4000.0, 5000.0, 6300.0,
8000.0, 10000.0, 12500.0,
16000.0
}

Array of center frequencies (Hz) normalized in one-third Octave.

Definition at line 305 of file spectre.h.

◆ _mapFreqIndice

std::map< double, int > OSpectre::_mapFreqIndice = setMapFreqIndice()
staticprotected

Mapping between frequency and array index.

Definition at line 317 of file spectre.h.

◆ _module

double OSpectre::_module[TY_SPECTRE_DEFAULT_NB_ELMT]
protected

Real values array for module.

Definition at line 334 of file spectre.h.

◆ _type

TYSpectreType OSpectre::_type
protected

Spectrum type.

Definition at line 325 of file spectre.h.

◆ _valid

bool OSpectre::_valid
protected

Spectrum validity.

Definition at line 322 of file spectre.h.


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