Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Institute of Technical Acoustics (ITA)
ITABase
Commits
dda795f9
Commit
dda795f9
authored
Dec 06, 2018
by
Armin Erraji
Browse files
Added function Sub() in ITASpectrum and changed function names in ITAISO9613.
parent
d52c746c
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/ITAISO9613.h
View file @
dda795f9
...
...
@@ -67,10 +67,10 @@ namespace ITABase
* \param fHumidity Relative humidity [%]
* \param fStaticPressure Static air pressure [kPa]
*/
ITA_BASE_API
void
AtmosphericAbsorption
Level
(
ITABase
::
CThirdOctaveDecibelMagnitudeSpectrum
&
oA_atm_dB
,
double
dDistance
,
double
dTemperature
,
double
dHumidity
,
double
dStaticPressure
=
101.325
);
ITA_BASE_API
void
AtmosphericAbsorption
(
ITABase
::
CThirdOctaveDecibelMagnitudeSpectrum
&
oA_atm_dB
,
double
dDistance
,
double
dTemperature
,
double
dHumidity
,
double
dStaticPressure
=
101.325
);
//! Calculates the atmospheric absorption in linear factors (instead of decibels)
ITA_BASE_API
void
AtmosphericAbsorption
Factor
(
ITABase
::
CThirdOctaveFactorMagnitudeSpectrum
&
oA_atm_factor
,
double
dDistance
,
double
dTemperature
,
double
dHumidity
,
double
dStaticPressure
=
101.325
);
ITA_BASE_API
void
AtmosphericAbsorption
(
ITABase
::
CThirdOctaveFactorMagnitudeSpectrum
&
oA_atm_factor
,
double
dDistance
,
double
dTemperature
,
double
dHumidity
,
double
dStaticPressure
=
101.325
);
}
}
...
...
include/ITASpectrum.h
View file @
dda795f9
...
...
@@ -78,6 +78,9 @@ public:
//! Element-wise addition
void
Add
(
const
CITASpectrum
&
oOtherSpetrum
);
//! Element-wise subtraction
void
Sub
(
const
CITASpectrum
&
oOtherSpetrum
);
//! Compare equality of values (ignores center frequencies, but requires matching number of bands)
bool
CompareEqualValues
(
const
CITASpectrum
&
oOtherSpectrum
,
const
float
fThreshold
=
10.0e-10
)
const
;
...
...
src/ITAISO9613.cpp
View file @
dda795f9
...
...
@@ -68,13 +68,13 @@ double ISO9613::AtmosphericAbsorptionFactor(double dFrequency, double dDistance,
{
double
dAirAbsorptionDecibel
=
AtmosphericAbsorptionLevel
(
dFrequency
,
dDistance
,
dTemperature
,
dHumidity
,
dStaticPressure
);
//Factor of absor
p
ed signal energy [0:1]
//Factor of absor
b
ed signal energy [0:1]
double
dAirAbsorptionFactor
=
1
-
pow
(
10
,
-
dAirAbsorptionDecibel
/
10.0
);
return
dAirAbsorptionFactor
;
}
void
ISO9613
::
AtmosphericAbsorption
Level
(
ITABase
::
CThirdOctaveDecibelMagnitudeSpectrum
&
oA_atm_dB
,
double
dDistance
,
double
dTemperature
,
double
dHumidity
,
double
dStaticPressure
/*= 101.325*/
)
void
ISO9613
::
AtmosphericAbsorption
(
ITABase
::
CThirdOctaveDecibelMagnitudeSpectrum
&
oA_atm_dB
,
double
dDistance
,
double
dTemperature
,
double
dHumidity
,
double
dStaticPressure
/*= 101.325*/
)
{
// loop over all frequencies
for
(
int
i
=
0
;
i
<
oA_atm_dB
.
GetNumBands
();
i
++
)
...
...
@@ -85,7 +85,7 @@ void ISO9613::AtmosphericAbsorptionLevel(ITABase::CThirdOctaveDecibelMagnitudeSp
}
}
void
ISO9613
::
AtmosphericAbsorption
Factor
(
ITABase
::
CThirdOctaveFactorMagnitudeSpectrum
&
oA_atm_factor
,
double
dDistance
,
double
dTemperature
,
double
dHumidity
,
double
dStaticPressure
/*= 101.325*/
)
void
ISO9613
::
AtmosphericAbsorption
(
ITABase
::
CThirdOctaveFactorMagnitudeSpectrum
&
oA_atm_factor
,
double
dDistance
,
double
dTemperature
,
double
dHumidity
,
double
dStaticPressure
/*= 101.325*/
)
{
// loop over all frequencies and converting from decibel to a factor between 0 and 1
for
(
int
i
=
0
;
i
<
oA_atm_factor
.
GetNumBands
();
i
++
)
...
...
src/ITASpectrum.cpp
View file @
dda795f9
...
...
@@ -96,13 +96,22 @@ void CITASpectrum::Add( const float fSummand )
m_vfValues
[
n
]
+=
fSummand
;
}
void
CITASpectrum
::
Add
(
const
CITASpectrum
&
oOtherSpetrum
)
void
CITASpectrum
::
Add
(
const
CITASpectrum
&
oOtherSpe
c
trum
)
{
if
(
GetNumBands
()
!=
oOtherSpetrum
.
GetNumBands
()
)
if
(
GetNumBands
()
!=
oOtherSpe
c
trum
.
GetNumBands
()
)
ITA_EXCEPT1
(
INVALID_PARAMETER
,
"Number of bands mismatching, can not add spectra"
);
for
(
size_t
n
=
0
;
n
<
m_vfValues
.
size
();
n
++
)
m_vfValues
[
n
]
+=
oOtherSpetrum
[
int
(
n
)
];
m_vfValues
[
n
]
+=
oOtherSpectrum
[
int
(
n
)
];
}
void
CITASpectrum
::
Sub
(
const
CITASpectrum
&
oOtherSpectrum
)
{
if
(
GetNumBands
()
!=
oOtherSpectrum
.
GetNumBands
())
ITA_EXCEPT1
(
INVALID_PARAMETER
,
"Number of bands mismatching, can not sub spectra"
);
for
(
size_t
n
=
0
;
n
<
m_vfValues
.
size
();
n
++
)
m_vfValues
[
n
]
-=
oOtherSpectrum
[
int
(
n
)];
}
bool
CITASpectrum
::
CompareEqualValues
(
const
CITASpectrum
&
oOtherSpectrum
,
const
float
fThreshold
/*= 10.0e-10 */
)
const
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment