50 static const unsigned int TY_SPECTRE_DEFAULT_NB_ELMT = 31;
53 static const unsigned int TY_SPECTRE_OCT_NB_ELMT = 9;
56 static const double TY_SPECTRE_DEFAULT_VALUE = -100.0;
66 #define CHECK_FORM_AND_GET_CONCRETE_INSTANCE \
68 if (this->getForm() != spectre.getForm()) \
70 throw tympan::invalid_data("Spectrums must be same form") << tympan_source_loc; \
72 OSpectreAbstract* sp = getConcreteInstance(); \
73 OSpectreAbstract& s = *sp;
188 void setDefaultValue(
double module[],
const unsigned int spectreNbElmt = TY_SPECTRE_DEFAULT_NB_ELMT,
189 const double& valeur = TY_SPECTRE_DEFAULT_VALUE);
198 void getRangeValueReal(
double* valeurs,
const short& nbVal,
const short& decalage);
268 const double sigma()
const;
343 OSpectre(
const double* valeurs,
unsigned nbVal,
unsigned decalage);
374 void setValue(
const double& freq,
const double& reel = 0.0);
529 void setValue(
const double& freq,
const double& reel,
const double& imag = 0.0);
555 void setPhase(
const double& valeur = 0.0);
577 double _phase[TY_SPECTRE_DEFAULT_NB_ELMT];
594 OSpectreOctave(
const double* valeurs,
unsigned nbVal,
unsigned decalage);
632 void setValue(
const double& freq,
const double& reel = 0.0);
Store acoustic power values for different frequencies.
OSpectreAbstract & power(const double &puissance) const
Return a spectrum as this spectrum raised to a double power.
OSpectreAbstract & sum(const OSpectreAbstract &spectre) const
Arithmetic sum of two spectrums in one-third Octave.
OSpectreAbstract & subst(const OSpectreAbstract &spectre) const
Arithmetic subtraction of two spectrums in one-third Octave.
virtual bool operator==(const OSpectreAbstract &other) const
operator==
const TYSpectreEtat getEtat()
bool _valid
Spectrum validity.
double valMax()
Return the maximum value of a spectrum.
double valGlobDBA() const
Compute the global value dB[A] of a one-third Octave spectrum.
static double _defaultValue
Default value for the spectrum.
void setForm(TYSpectreForm form)
Force the spectrum state (to use carefully ...)
OSpectreAbstract & toGPhy() const
Converts to physical quantity.
virtual double * getTabValReel()=0
Get the array of real values - Pure virtual method.
OSpectreAbstract & seuillage(const double &min=-200.0, const double max=200.0)
Limit the spectrum values (min and max)
OSpectreAbstract & exp(const double coef=1.0)
Compute e^(coef * spectre) of this spectrum.
OSpectreAbstract & operator+(const double &valeur) const
Add a constant value to all the spectrum.
OSpectreAbstract & log(const double &base=10.0) const
Compute the log base n of this spectrum (n=10 by default).
unsigned int getNbValues() const
Number of values in the spectrum.
OSpectreAbstract & invMult(const double &coefficient=1.0) const
Division of a double constant by this spectrum.
virtual const double * getTabValReel() const =0
double valGlobDBLin() const
Compute the global value dB[Lin] of a one-third Octave spectrum.
OSpectreAbstract & operator*(const OSpectreAbstract &spectre) const
Multiplication by a Spectre spectrum.
void setEtat(TYSpectreEtat etat)
Force the spectrum state (to use carefully ...)
OSpectreAbstract()
Methods.
void setType(TYSpectreType type)
Set the spectrum type.
double sigma()
Sum the values of the spectrum.
TYSpectreEtat getEtat() const
Get the spectrum state.
virtual void printme() const
Print the spectrum.
TYSpectreType getType() const
Get the spectrum type.
OSpectreAbstract & abs() const
Return the absolute value of this spectrum.
TYSpectreForm _form
Representation of the spectrum: one-third Octave, Octave, constant delta f, unstructured.
OSpectreAbstract & toTOct() const
Converts to one-third Octave.
OSpectreAbstract & div(const OSpectreAbstract &spectre) const
Division of two spectrums.
OSpectreAbstract & sqrt() const
Return the root square of a spectrum.
void setValid(const bool &valid=true)
OSpectreAbstract & racine() const
Compute the root square of this spectrum.
OSpectreAbstract & sin() const
Compute the sin of this spectrum.
void getRangeValueReal(double *valeurs, const short &nbVal, const short &decalage)
virtual OSpectreAbstract & operator=(const OSpectreAbstract &other)
operator=
virtual bool operator!=(const OSpectreAbstract &other) const
operator !=
void setDefaultValue(const double &valeur=TY_SPECTRE_DEFAULT_VALUE)
TYSpectreForm getForm() const
Get the spectrum form.
TYSpectreEtat _etat
Spectrum state (physical quantity or dB).
static OSpectreAbstract & makeOctSpect()
Make a spectrum in Octave.
OSpectreAbstract & operator-(const OSpectreAbstract &spectre) const
Arithmetic subtraction of two spectrums in one-third Octave.
OSpectreAbstract & cos() const
Compute the cos of this spectrum.
OSpectreAbstract & toDB() const
Converts to dB.
OSpectreAbstract & toOct() const
Converts to Octave.
OSpectreAbstract & round()
OSpectreAbstract & mult(const OSpectreAbstract &spectre) const
Multiplication of two spectrums.
TYSpectreType _type
Spectrum type.
bool isValid() const
Check the spectrum validity. Invalidity is caused by: corrupted data, impossible calculation.
OSpectreAbstract & sumdB(const OSpectreAbstract &spectre) const
Energetic sum of two spectrums.
virtual OSpectreAbstract * getConcreteInstance() const =0
Return an instance of a concrete class of the same type as current.
OSpectreAbstract & inv() const
Division of one by this spectrum.
OSpectreComplex & operator=(const OSpectreComplex &other)
operators
void setPhase(const OSpectre &spectre)
bool operator!=(const OSpectreComplex &other) const
double getValueImag(double freq, bool *pValid=0)
void setValue(const double &freq, const double &reel, const double &imag=0.0)
double _phase[TY_SPECTRE_DEFAULT_NB_ELMT]
Array of the imaginary numbers (phase)
OSpectre getModule() const
OSpectreComplex toModulePhase() const
Conversion to module/phase.
OSpectre getPhase() const
static OSpectreComplex getCplxSpectre(const double &valInit=1.0E-20)
Build a OSpectreComplex complex spectrum.
const double * getTabValImag() const
OSpectreComplex operator+(const OSpectreComplex &spectre) const
bool operator==(const OSpectreComplex &other) const
OSpectreComplex operator/(const OSpectreComplex &spectre) const
Divide a complex spectrum by another one.
OSpectreComplex operator*(const OSpectreComplex &spectre) const
Product of two complex spectrums (module/phase)
double * getTabValImag()
Get an array of the imaginary values of the spectrum.
virtual ~OSpectreComplex()
virtual ~OSpectreOctave()
OSpectreAbstract * getConcreteInstance() const override
Return an instance of a concrete class of the same type as current.
static OSpectreOctave getLambda(const double &c)
static OSpectreOctave pondA()
Build a weighted spectrum A.
double _module[TY_SPECTRE_OCT_NB_ELMT]
Real values array for module.
static const double _AWeighting[TY_SPECTRE_OCT_NB_ELMT]
A weighting for ponderation A computation.
static OSpectreOctave getEmptyLinSpectre(const double &valInit=1.0E-20)
Create a physical quantity spectrum.
bool operator!=(const OSpectreOctave &other) const
void setValue(const double &freq, const double &reel=0.0)
bool operator==(const OSpectreOctave &other) const
static OTabFreq getTabFreqExact()
static const double _freqNorm[TY_SPECTRE_OCT_NB_ELMT]
Array of center frequencies (Hz) normalized in one-third Octave.
static std::map< double, int > setMapFreqIndice()
Build frequency/index map.
const double * getTabValReel() const override
static std::map< double, int > _mapFreqIndice
Mapping between frequency and array index.
OSpectreOctave & operator=(const OSpectreOctave &other)
operators
double * getTabValReel() override
Get an array of the real values of the spectrum.
static OSpectre getOSpectreFreqExact()
Return the spectrum of the exact frequencies.
const double * getTabValReel() const override
virtual bool operator!=(const OSpectre &other) const
operator !=
OSpectre & operator=(const OSpectre &other)
operator=
static OSpectre getLambda(const double &c)
static std::map< double, int > _mapFreqIndice
Mapping between frequency and array index.
static std::map< double, int > setMapFreqIndice()
Construction du tableau frequence/indice.
void setValue(const double &freq, const double &reel=0.0)
double _module[TY_SPECTRE_DEFAULT_NB_ELMT]
Real values array for module.
OSpectreAbstract * getConcreteInstance() const override
Return an instance of a concrete class of the same type as current.
static double _fMin
Minimal frequency.
static OSpectre getEmptyLinSpectre(const double &valInit=1.0E-20)
Create a physical quantity spectrum.
double * getTabValReel() override
static void setFMax(const double &fMax)
Define maximal frequency.
static const double _freqNorm[]
Array of center frequencies (Hz) normalized in one-third Octave.
virtual ~OSpectre()
Destructor.
bool isTonalite() const
Existence d'une tonalite marquee.
static void setFMin(const double &fMin)
Define minimal frequency.
static OSpectre pondC()
Build a weighted spectrum C.
virtual bool operator==(const OSpectre &other) const
operator==
static OSpectre pondB()
Build a weighted spectrum B.
static OSpectre pondA()
Build a weighted spectrum A.
OSpectre()
Default constructor, the spectrum module is defined by the _defaultValue.
double getValueReal(double freq)
static double _fMax
Maximal frequency.
static OSpectre makeOctSpect()
Make a spectrum in Octave.
static int getIndice(const double &freq)
Return the index associated to a frequency.
static OTabFreq getTabFreqExact()
std::complex< double > TYComplex
std::vector< double > OTabFreq
Frequencies collection.
std::vector< std::vector< OSpectreComplex > > OTab2DSpectreComplex
OTabSpectreComplex 2D array.
TYSpectreEtat
Spectrum state (dB/Physical Measure).
::std::ostream & operator<<(::std::ostream &os, const OSpectre &s)
TYSpectreForm
Spectrum representation.
std::vector< OSpectre > OTabSpectre
Spectrums vector.
std::vector< OSpectreComplex > OTabSpectreComplex
OTabSpectreComplex vector.
TYSpectreType
Spectrum type.
std::vector< std::vector< OSpectre > > OTab2DSpectre
Spectrums 2D array.