Commit 7e95613c authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Merging develop and style changes on binaural real-time renderer, which is due to renaming

parents 5c06f998 462e4ad8
......@@ -48,8 +48,8 @@ vista_use_package( ITABase REQUIRED FIND_DEPENDENCIES )
vista_use_package( ITADSP REQUIRED FIND_DEPENDENCIES )
vista_use_package( ITADataSources REQUIRED FIND_DEPENDENCIES )
vista_use_package( ITAConvolution REQUIRED FIND_DEPENDENCIES )
vista_use_package( ITACTC REQUIRED FIND_DEPENDENCIES )
vista_use_package( ITASampler REQUIRED FIND_DEPENDENCIES )
vista_use_package( ITACTC REQUIRED FIND_DEPENDENCIES )
vista_use_package( OpenDAFF REQUIRED )
vista_use_package( SPLINE REQUIRED )
vista_use_package( Eigen REQUIRED )
......@@ -175,6 +175,9 @@ endif( )
if( NOT DEFINED ITA_VACORE_WITH_RENDERER_PROTOTYPE_GENERIC_PATH )
set( ITA_VACORE_WITH_RENDERER_PROTOTYPE_GENERIC_PATH ON CACHE BOOL "Build VACore with rendering module: prototype generic path" )
endif( )
if( NOT DEFINED ITA_VACORE_WITH_RENDERER_PROTOTYPE_IMAGE_SOURCE )
set( ITA_VACORE_WITH_RENDERER_PROTOTYPE_IMAGE_SOURCE ON CACHE BOOL "Build VACore with rendering module: prototype image source" )
endif( )
if( NOT DEFINED ITA_VACORE_WITH_RENDERER_VBAP_FREE_FIELD )
set( ITA_VACORE_WITH_RENDERER_VBAP_FREE_FIELD ON CACHE BOOL "Build VACore with rendering module: vector-base amplitude panning free-field" )
......@@ -305,6 +308,9 @@ endif( )
if( ITA_VACORE_WITH_RENDERER_PROTOTYPE_GENERIC_PATH )
add_definitions( "-DVACORE_WITH_RENDERER_PROTOTYPE_GENERIC_PATH" )
endif( )
if( ITA_VACORE_WITH_RENDERER_PROTOTYPE_IMAGE_SOURCE )
add_definitions( "-DVACORE_WITH_RENDERER_PROTOTYPE_IMAGE_SOURCE" )
endif( )
if( ITA_VACORE_WITH_RENDERER_VBAP_FREE_FIELD )
add_definitions( "-DVACORE_WITH_RENDERER_VBAP_FREE_FIELD" )
endif( )
......@@ -384,6 +390,7 @@ if( ITA_VACORE_DEPLOY_WITH_COMMON_DATA )
install( FILES "data/Singer.v17.ms.daff" DESTINATION "data" )
install( FILES "data/Trumpet1.v17.ms.daff" DESTINATION "data" )
install( FILES "data/WelcomeToVA.wav" DESTINATION "data" )
install( FILES "data/ambeo_rir_ita_doorway.wav" DESTINATION "data" )
endif( )
if( ITA_VACORE_DEPLOY_WITH_COMMON_CONFIGS )
......@@ -394,6 +401,9 @@ if( ITA_VACORE_DEPLOY_WITH_COMMON_SCRIPTS )
# nothing yet
endif( )
if( ITA_VA_INSTALL_WITH_DLLS )
vista_install_all_dlls( bin )
endif( )
# tests
if( ITA_VA_WITH_TESTS OR ITA_VACORE_WITH_TESTS )
......
......@@ -238,6 +238,29 @@ RecordOutputEnabled = false
RecordOutputFileName = renderer_out.wav
RecordOutputBaseFolder = recordings/$(ProjectName)/renderer/MyGenericRenderer
[Renderer:MyImageSourceRenderer]
Class = PrototypeImageSource
Enabled = false
Reproductions = MyTalkthroughHeadphones
NumChannels = 2
RoomLength = 5
RoomWidth = 5
RoomHeight = 5
MaxOrder = 2
Betax1 = 0.1
Betax2 = 0.1
Betay1 = 0.1
Betay2 = 0.1
Betaz1 = 0.1
Betaz2 = 0.1
DirectSound = true
HRIRFilterLength = 256
IRFilterLengthSamples = 88200
OutputMonitoring = true
RecordOutputEnabled = false
RecordOutputFileName = renderer_out.wav
RecordOutputBaseFolder = recordings/$(ProjectName)/renderer/MyImageSourceRenderer
[Renderer:MyAirTrafficNoiseRenderer]
Class = BinauralAirTrafficNoise
Enabled = false
......
......@@ -6,7 +6,6 @@
[Output:HOAIdeal]
Description = Equiangular placed loudspeaker
Enabled = true
Devices = LS1, LS2, LS3, LS4, LS5, LS6, LS7, LS8, LS9, LS10, LS11, LS12, LS13, LS14, LS15, LS16, LS17, LS18, LS19, LS20, LS21, LS22, LS23, LS24, LS25
[OutputDevice:LS1]
......
......@@ -12,5 +12,6 @@ The following files are licensed under Creative Commons BY-NC-SA 4.0 by the Inst
- Singer.v17.ms.daff
- Trumpet1.v17.ms.daff
- HD650_all_inv.wav
- ambeo_rir_ita_doorway.wav
For more information, higher resolutions for academic purposes and commercial use, please contact us.
......@@ -472,6 +472,7 @@ void CVAAudioSignalSourceManager::SyncSignalSources()
int iEntryCount = m_iStreamCounter;
// Warten bis tatschlich incrementiert (mittels energiesparendem Event)
#pragma warning( disable : 4127 ) // We allow for a constant expression in this infinite while loop
while( true )
{
// [fwe] Fix: Falls das Streaming nicht gestartet wurde. Direkt aus dem Wait raus.
......@@ -487,6 +488,7 @@ void CVAAudioSignalSourceManager::SyncSignalSources()
return;
}
#pragma warning( default : 4127 )
}
void CVAAudioSignalSourceManager::FetchInputData( const CVAAudiostreamState* pStreamInfo )
......
......@@ -23,12 +23,12 @@
#include <ITACriticalSection.h>
#include <ITASampleBuffer.h>
#include <ITAAtomicPrimitives.h>
#include <VistaInterProcComm/Concurrency/VistaThreadEvent.h>
#include <tbb/concurrent_queue.h>
#include <atomic>
#include <map>
#include <string>
#include <vector>
......@@ -182,7 +182,7 @@ private:
tbb::concurrent_queue<CAudioSignalSource*> m_qpNewSources; //!< Lock-free queue: New sources
tbb::concurrent_queue<CAudioSignalSource*> m_qpDelReqSources; //!< Lock-free queue: Request delete sources
ITAAtomicInt m_iStreamCounter; //!< Counts the number of processed stream blocks
std::atomic< int > m_iStreamCounter; //!< Counts the number of processed stream blocks
VistaThreadEvent m_evStreamCounterInc; //!< Event: Stream counter incremented
//! Signal source find by ID
......
......@@ -16,11 +16,11 @@
#include <VAAudioSignalSource.h>
#include <ITAAtomicPrimitives.h>
#include <ITADataSourceDelegator.h>
#include <ITASampleBuffer.h>
#include <ITASampleFrame.h>
#include <atomic>
#include <string>
class ITABufferDatasource;
......@@ -57,8 +57,8 @@ public:
private:
IVAInterface* m_pAssociatedCore;
ITABufferDatasource* m_pBufferDataSource;
ITAAtomicInt m_iCurrentPlayState;
ITAAtomicInt m_iRequestedPlaybackAction; //!< User-triggered playback action
std::atomic< int > m_iCurrentPlayState;
std::atomic< int > m_iRequestedPlaybackAction; //!< User-triggered playback action
ITASampleBuffer m_sbOutBuffer;
ITASampleFrame m_sfAudioBuffer; //!< Audio buffer with multiple channels for smooth switching on update
int m_iActiveAudioBufferChannel;
......
......@@ -19,8 +19,8 @@
#include <ITADataSourceRealization.h>
#include <ITASampleBuffer.h>
#include <ITAAtomicPrimitives.h>
#include <atomic>
#include <map>
class CVACoreImpl;
......@@ -62,7 +62,7 @@ private:
Config m_oConfig;
ITASampleBuffer m_sbBuffer;
std::map< double, double > m_lFreqModesPhase;
ITAAtomicFloat m_fK; // engine number
std::atomic< float > m_fK; // engine number
};
#endif // IW_VACORE_ENGINESIGNALSOURCE
......@@ -246,7 +246,8 @@ void CVAMachineSignalSource::HandleUnregistration( IVAInterface* )
std::string CVAMachineSignalSource::GetStateString() const
{
return GetMachineStateString( MachineState( m_iCurrentState.get() ) );
MachineState iState = (MachineState) (int) m_iCurrentState;
return GetMachineStateString( iState );
}
std::string CVAMachineSignalSource::GetMachineStateString( MachineState iState ) const
......
......@@ -19,7 +19,8 @@
#include <ITADataSourceRealization.h>
#include <ITASampleBuffer.h>
#include <ITAAtomicPrimitives.h>
#include <atomic>
class CVACoreImpl;
class IITASampleInterpolationRoutine;
......@@ -145,15 +146,15 @@ private:
ITASampleBuffer m_sbIdleSound, m_sbIdleSoundNew;
ITASampleBuffer m_sbStopSound, m_sbStopSoundNew;
ITASampleBuffer m_sbInterpolationSrc;
ITAAtomicBool m_bStartSoundNew, m_bIdleSoundNew, m_bStopSoundNew;
std::atomic< bool > m_bStartSoundNew, m_bIdleSoundNew, m_bStopSoundNew;
ITASampleBuffer m_sbOut;
ITAAtomicInt m_iCurrentState;
ITAAtomicInt m_iNewTransition;
ITAAtomicFloat m_fMachineSpeed;
ITAAtomicBool m_bHasStartSound;
ITAAtomicBool m_bHasIdleSound;
ITAAtomicBool m_bHasStopSound;
ITAAtomicBool m_bCrossfadeSounds;
std::atomic< int > m_iCurrentState;
std::atomic< int > m_iNewTransition;
std::atomic< float > m_fMachineSpeed;
std::atomic< bool > m_bHasStartSound;
std::atomic< bool > m_bHasIdleSound;
std::atomic< bool > m_bHasStopSound;
std::atomic< bool > m_bCrossfadeSounds;
int m_iStartingSoundCursor;
int m_iIdlingSoundCursor;
......
......@@ -22,8 +22,8 @@
#include <ITADataSourceRealization.h>
#include <ITASampleBuffer.h>
#include <ITAAudioSample.h>
#include <ITAAtomicPrimitives.h>
#include <atomic>
#include <unordered_set>
class ITABufferDatasource;
......@@ -137,7 +137,7 @@ private:
ITASampleBuffer m_sbOut;
//this mutable keyword here is necessary since the inherited method GetParameters() is const, however we want to be able to change some parts (not very clean code, sorry)
ITAAtomicInt m_iCurrentPlayState;
std::atomic< int > m_iCurrentPlayState;
ITABufferDatasource* m_pBufferDataSource;
ITASampleFrame* m_pFrameToDelete;//this is set if the sample should be freed after playback
......
......@@ -17,13 +17,14 @@
#include "VAAudioDriverBackend.h"
#include "VAAudioDriverConfig.h"
#include <ITAAtomicPrimitives.h>
#include <ITAException.h>
#include <ITAStreamProperties.h>
#include <VistaInterProcComm/Concurrency/VistaThreadLoop.h>
#include <VistaInterProcComm/Concurrency/VistaThreadEvent.h>
#include <atomic>
/**
* Diese Klasse implementiert die Schnittstelle IVAAudioDriverArchBackend
* fr ASIO mittels des ITAsioInterface
......@@ -91,7 +92,7 @@ private:
};
CVAASIOBackend* m_pParent;
ITAAtomicInt m_iOperation;
std::atomic< int > m_iOperation;
int m_iResult;
ITAException m_oException;
VistaThreadEvent m_evStart;
......@@ -107,7 +108,7 @@ private:
MediatorThread* m_pMediator;
CVAAudioDriverConfig* m_pConfig;
ITAStreamProperties m_oOutputStreamProps;
ITAAtomicBool m_bStreaming;
std::atomic< bool > m_bStreaming;
};
#endif // IW_VACORE_ASIOBACKEND
......@@ -17,12 +17,13 @@
#include "VAAudioDriverBackend.h"
#include "VAAudioDriverConfig.h"
#include <ITAAtomicPrimitives.h>
#include <ITAException.h>
#include <ITAStreamProperties.h>
#include <VistaInterProcComm/Concurrency/VistaThreadLoop.h>
#include <VistaInterProcComm/Concurrency/VistaThreadEvent.h>
#include <atomic>
class ITAPortaudioInterface;
//! VA Portaudio Backend Klasse
......@@ -83,7 +84,7 @@ private:
CVAPortaudioBackend* m_pParent;
ITAPortaudioInterface* m_pPA;
ITAAtomicInt m_iOperation;
std::atomic< int > m_iOperation;
int m_iResult;
ITAException m_oException;
VistaThreadEvent m_evStart;
......@@ -100,7 +101,7 @@ private:
ITAPortaudioInterface* m_pITAPA;
CVAAudioDriverConfig* m_pConfig;
ITAStreamProperties m_oOutputStreamProps;
ITAAtomicBool m_bStreaming;
std::atomic< bool > m_bStreaming;
};
#endif // IW_VACORE_PORTAUDIOBACKEND
/*
* --------------------------------------------------------------------------------------------
*
* VVV VVV A Virtual Acoustics (VA) | http://www.virtualacoustics.org
* VVV VVV AAA Licensed under the Apache License, Version 2.0
* VVV VVV AAA
* VVV VVV AAA Copyright 2015-2018
* VVVVVV AAA Institute of Technical Acoustics (ITA)
* VVVV AAA RWTH Aachen University
*
* --------------------------------------------------------------------------------------------
*/
#include "VAAtmosphere.h"
// VA includes
#include "../Utils/VADebug.h"
// ITA includes
#include <ITAException.h>
#include <ITANumericUtils.h>
// STL includes
#include <cassert>
#include <cmath>
// Aus Raven Defines
const float DEF_CENTER_FREQUENCY_OCTAVE[ 10 ] =
{
31.5f, 63.0f, 125.0f, 250.0f, 500.0f, 1000.0f, 2000.0f, 4000.0f, 8000.0f, 16000.0f
};
const float DEF_CENTER_FREQUENCY_THIRDS[ 31 ] =
{
20, 25, 31.5, 40, 50, 63, 80, 100, 125, 160, 200, 250, 315, 400, 500, 630, 800,
1000, 1250, 1600, 2000, 2500, 3150, 4000, 5000, 6300, 8000, 10000, 12500, 16000, 20000
};
void GetAirAbsorptionMagnitudes( ITABase::CThirdOctaveFactorMagnitudeSpectrum& oMags, double dDistance, double dTemperature, double dPressure, double dHumidity )
{
// ISO 9613-1 Acoustics - Attenuation of sound during propagation outdoors
// Noch nicht fertig ....
ITA_EXCEPT0( NOT_IMPLEMENTED );
// Reference ambient atmospheric pressure (Standard Ambient Atmosphere) [kPa]
// (Referenzatmosphrendruck Umgebung nach ISO Standard)
const double p_r = 101.325f;
const double p_a = 101.325f;
// Inital sound pressure amplitude [kPa]
const double p_i = p_r + 0.0f;
// Sound pressure amplitude [Pa]
const double p_t = 1.0f;
// Reference air temperature [K]
const double T_0 = 273.15f + 20.0f;
// Temperature [K]
const double T = 273.15f + dTemperature;
// Molar concentration dry air
const double tmp = ( 10.79586f * ( 1.0f - ( ( T_0 - 20.0f ) / T ) ) ) -
( 5.02808f * log10( ( T / ( T_0 - 20.0f ) ) ) ) +
( 1.50474f * 0.0001f * ( 1.0f - pow( ( double ) 10.0f, ( -8.29692f*( ( T / ( T_0 - 20.0f ) ) - 1.0f ) ) ) ) ) +
( 0.42873f * 0.001f * ( -1.0f + pow( ( double ) 10.0f, ( -4.76955f*( 1.0f - ( ( T_0 - 20.0f ) / T ) ) ) ) ) ) -
2.2195983f;
// Molar concentration of water vapour [%] (Molekldichte Wasserdampf)
assert( 0.0f <= dHumidity && dHumidity <= 100.0f );
const double h = dHumidity * pow( ( double ) 10.0f, tmp ) / ( p_a / p_r );
// Equation (3)
const double f_r_o = ( p_a / p_r ) * ( 24.0f + 4.04f*10.0e4*h*( 0.02f + h ) / ( 0.391f + h ) );
// Equation (4)
const double f_r_n = ( p_a / p_r ) * pow( T / T_0, ( double ) -1.0f / 2.0f ) * ( 9.0f + 280.0f*h*exp( -4.710f * ( pow( T / T_0, ( double ) -( 1 / 3.0f ) ) - 1.0f ) ) );
// Calculate for frequency bands
for( int i = 0; i < oMags.GetNumBands(); i++ )
{
// Frequency
double f = oMags.GetCenterFrequencies()[ i ];
// Parts of Equation (5)
double dAlpha1 = 8.686f * pow( f, ( double ) 2.0f );
double dAlpha2 = 1.84f * 10e-11 * pow( p_a / p_r, ( double ) -1.0f ) * pow( T / T_0, ( double ) -1.0f / 2.0f );
double dAlpha3 = pow( T / T_0, ( double ) -5.0f / 2.0f );
double dAlpha4 = 0.01275f * exp( -2239.1f / T ) * pow( f_r_o + pow( f, ( double ) 2.0f ) / f_r_o, ( double ) -1.0f );
double dAlpha5 = 0.10680f * exp( -3352.0f / T ) * pow( f_r_n + pow( f, ( double ) 2.0f ) / f_r_n, ( double ) -1.0f );
// Attenuation coefficient [dB/m], ~f, as assembly of Equation (5) parts
double dAlpha = dAlpha1 * ( dAlpha2 + dAlpha3 * ( dAlpha4 + dAlpha5 ) );
// Resulting attenuation [dB], ~alpha (~f)
float fAttenuationAirAbsorptionDecibel = ( float ) dAlpha * dDistance;
// Attenuation factor
//float fAttenuationAirAbsorptionFactor = 1 / exp( fAttenuationAirAbsorptionDecibel / 10 );
// Store decibel
oMags.SetMagnitude( i, fAttenuationAirAbsorptionDecibel );
//printf("Frequency [%4.2f Hz]: %f * 10^-3[dB/m], m = %f * 10^-3\n",DEF_CENTER_FREQUENCY_THIRDS[i], dAlpha*1000.0f*4.33f,fAttenuationAirAbsorptionFactor*1000.0f); // 4.33 -> in dB
}
return;
}
void CalculateAirAbsorptionAttenuation( ITABase::CThirdOctaveFactorMagnitudeSpectrum& oAirAbsMags, double dDistance, double dTemperature, double dStaticPressure, double dHumidity )
{
std::vector< float > vfGains( oAirAbsMags.GetNumBands() );
GetAirAbsorptionMagnitudesThirdOctave( &vfGains[ 0 ], dDistance, dTemperature, dStaticPressure, dHumidity );
oAirAbsMags.SetMagnitudes( vfGains );
return;
}
void GetAirAbsorptionMagnitudesThirdOctave( float* pfAirAbsCoeffs, // Zielarray (31 Werte)
double dDistance, // Abstand [m]
double dTemperature, // Temperatur [C]
double dPressure, // Statischer Luftdruck [Pa]
double dHumidity ) // Luftfeuchtigkeit [%]
{
// Code kopiert aus RE_Ops.cpp ;-)
//// init frequency bands
//std::vector<float> frequencies(31);
//frequencies[0] = 20; frequencies[1] = 25; frequencies[2] = 31,5;
//frequencies[3] = 40; frequencies[4] = 50; frequencies[5] = 63;
//frequencies[6] = 80; frequencies[7] = 100; frequencies[8] = 125;
//frequencies[9] = 160; frequencies[10]= 200; frequencies[11] = 250;
//frequencies[12]= 315; frequencies[13]= 400; frequencies[14] = 500;
//frequencies[15]= 630; frequencies[16]= 800; frequencies[17] = 1000;
//frequencies[18]= 1250; frequencies[19]= 1600; frequencies[20] = 2000;
//frequencies[21]= 2500; frequencies[22]= 3150; frequencies[23] = 4000;
//frequencies[24]= 5000; frequencies[25]= 6300; frequencies[26] = 8000;
//frequencies[27]= 10000; frequencies[28]= 12500; frequencies[29] = 16000;
//frequencies[30]= 20000;
float roomTemperatureKelvin = dTemperature + 273.16f;
float referencePressureKPa = 101.325f;
float pressureKPa = dPressure / 1000.0f;
float molarConcentrationWaterVaporPercent;
float relaxationFrequencyOxygen;
float relaxationFrequencyNitrogen;
float tmp;
// determine molar concentration of water vapor
tmp = ( 10.79586f * ( 1.0f - ( 273.16f / roomTemperatureKelvin ) ) ) -
( 5.02808f * log10( ( roomTemperatureKelvin / 273.16f ) ) ) +
( 1.50474f * 0.0001f * ( 1.0f - pow( 10.0f, ( -8.29692f*( ( roomTemperatureKelvin / 273.16f ) - 1.0f ) ) ) ) ) +
( 0.42873f * 0.001f * ( -1.0f + pow( 10.0f, ( -4.76955f*( 1.0f - ( 273.16f / roomTemperatureKelvin ) ) ) ) ) ) -
2.2195983f;
molarConcentrationWaterVaporPercent = ( dHumidity * pow( 10.0f, tmp ) ) / ( pressureKPa / referencePressureKPa );
// determine relaxation frequencies of oxygen and nitrogen
relaxationFrequencyOxygen = ( pressureKPa / referencePressureKPa ) *
( 24.0f + ( 4.04f * 10000.0f * molarConcentrationWaterVaporPercent *
( ( 0.02f + molarConcentrationWaterVaporPercent ) / ( 0.391f + molarConcentrationWaterVaporPercent ) ) ) );
relaxationFrequencyNitrogen = ( pressureKPa / referencePressureKPa ) *
( pow( ( roomTemperatureKelvin / 293.16f ), -0.5f ) ) *
( 9.0f + 280.0f * molarConcentrationWaterVaporPercent *
exp( -4.17f * ( ( pow( ( roomTemperatureKelvin / 293.16f ), -0.3333333f ) ) - 1.0f ) ) );
// determine air absorption for desired filter resolution
//unsigned int numberOfParameters = frequencies.size();
unsigned int numberOfParameters = 31;
for( unsigned int i = 0; i < numberOfParameters; ++i )
{
/* airAbsorptionCoeffs[i] =
(
pow(frequencies[i], 2.0f) *
((1.84f * pow(10.0f, -11.0f) * ( referencePressureKPa / pressureKPa) * pow((roomTemperatureKelvin/293.16f), 0.5f)) +
(pow((roomTemperatureKelvin/293.16f), -2.5f) * (
((1.278f * 0.01f * exp( (-2239.1f/roomTemperatureKelvin))) /
(relaxationFrequencyOxygen + (pow(frequencies[i], 2.0f)/relaxationFrequencyOxygen))) +
((1.068f * 0.1f * exp((-3352.0f/roomTemperatureKelvin))/
(relaxationFrequencyNitrogen + (pow(frequencies[i], 2.0f)/relaxationFrequencyNitrogen)))))))
)* 2000.0f * log10(exp(1.0f)); // Neper/m -> dB/100m
*/
/* airAbsorptionCoeffs[i] =
(
pow(frequencies[i], 2.0f) *
((1.84f * pow(10.0f, -11.0f) * ( referencePressureKPa / pressureKPa) * pow((roomTemperatureKelvin/293.16f), 0.5f)) +
(pow((roomTemperatureKelvin/293.16f), -2.5f) * (
((1.278f * 0.01f * exp( (-2239.1f/roomTemperatureKelvin))) /
(relaxationFrequencyOxygen + (pow(frequencies[i], 2.0f)/relaxationFrequencyOxygen))) +
((1.068f * 0.1f * exp((-3352.0f/roomTemperatureKelvin))/
(relaxationFrequencyNitrogen + (pow(frequencies[i], 2.0f)/relaxationFrequencyNitrogen)))))))
)* (20.0f / log(10.0f)) / ((log10(exp(1.0f))) * 10.0f); // Neper/m -> dB/m
*/
float alpha_dbm =
(
pow( DEF_CENTER_FREQUENCY_THIRDS[ i ], 2.0f ) *
( ( 1.84f * pow( 10.0f, -11.0f ) * ( referencePressureKPa / pressureKPa ) * pow( ( roomTemperatureKelvin / 293.16f ), 0.5f ) ) +
( pow( ( roomTemperatureKelvin / 293.16f ), -2.5f ) * (
( ( 1.278f * 0.01f * exp( ( -2239.1f / roomTemperatureKelvin ) ) ) /
( relaxationFrequencyOxygen + ( pow( DEF_CENTER_FREQUENCY_THIRDS[ i ], 2.0f ) / relaxationFrequencyOxygen ) ) ) +
( ( 1.068f * 0.1f * exp( ( -3352.0f / roomTemperatureKelvin ) ) /
( relaxationFrequencyNitrogen + ( pow( DEF_CENTER_FREQUENCY_THIRDS[ i ], 2.0f ) / relaxationFrequencyNitrogen ) ) ) ) ) ) )
)* ( 20.0f / log( 10.0f ) ) / ( ( log10( exp( 1.0f ) ) ) * 10.0f ); // Neper/m -> dB/m
pfAirAbsCoeffs[ i ] = alpha_dbm;
//printf("Frequency [%4.2f Hz]: %f * 10^-3[dB/m], m = %f * 10^-3\n",DEF_CENTER_FREQUENCY_THIRDS[i], pfAirAbsCoeffs[i]*1000.0f*4.33f,pfAirAbsCoeffs[i]*1000.0f); // 4.33 -> in dB
float alpha_db = dDistance * alpha_dbm;
float fGain = pow( 10, -alpha_db / 10 );
/*
double dDifference = 1-x;
if (dDifference > 0 )
fGain = (float) exp(log(dDifference)*fDistance);
*/
pfAirAbsCoeffs[ i ] = fGain;
//printf("Frequency [%4.2f Hz]: %f * 10^-3[dB/m], m = %f * 10^-3\n",DEF_CENTER_FREQUENCY_THIRDS[i], alpha_dbm*1000.0f*4.33f,fGain*1000.0f); // 4.33 -> in dB
}
}
void GetAirAbsorptionAttenuationThirdOctaveDecibel( float* pfAirAbsCoeffs, // Zielarray (31 Werte)
double dDistance, // Abstand [m]
double dTemperature, // Temperatur [C]
double dPressure, // Statischer Luftdruck [Pa]
double dHumidity ) // Luftfeuchtigkeit [%]
{
// Code kopiert aus RE_Ops.cpp ;-)
//// init frequency bands
//std::vector<float> frequencies(31);
//frequencies[0] = 20; frequencies[1] = 25; frequencies[2] = 31,5;
//frequencies[3] = 40; frequencies[4] = 50; frequencies[5] = 63;
//frequencies[6] = 80; frequencies[7] = 100; frequencies[8] = 125;
//frequencies[9] = 160; frequencies[10]= 200; frequencies[11] = 250;
//frequencies[12]= 315; frequencies[13]= 400; frequencies[14] = 500;
//frequencies[15]= 630; frequencies[16]= 800; frequencies[17] = 1000;
//frequencies[18]= 1250; frequencies[19]= 1600; frequencies[20] = 2000;
//frequencies[21]= 2500; frequencies[22]= 3150; frequencies[23] = 4000;
//frequencies[24]= 5000; frequencies[25]= 6300; frequencies[26] = 8000;
//frequencies[27]= 10000; frequencies[28]= 12500; frequencies[29] = 16000;
//frequencies[30]= 20000;
float roomTemperatureKelvin = dTemperature + 273.16f;
float referencePressureKPa = 101.325f;
float pressureKPa = dPressure / 1000.0f;
float molarConcentrationWaterVaporPercent;
float relaxationFrequencyOxygen;
float relaxationFrequencyNitrogen;
float tmp;
// determine molar concentration of water vapor
tmp = ( 10.79586f * ( 1.0f - ( 273.16f / roomTemperatureKelvin ) ) ) -
( 5.02808f * log10( ( roomTemperatureKelvin / 273.16f ) ) ) +
( 1.50474f * 0.0001f * ( 1.0f - pow( 10.0f, ( -8.29692f*( ( roomTemperatureKelvin / 273.16f ) - 1.0f ) ) ) ) ) +
( 0.42873f * 0.001f * ( -1.0f + pow( 10.0f, ( -4.76955f*( 1.0f - ( 273.16f / roomTemperatureKelvin ) ) ) ) ) ) -
2.2195983f;
molarConcentrationWaterVaporPercent = ( dHumidity * pow( 10.0f, tmp ) ) / ( pressureKPa / referencePressureKPa );
// determine relaxation frequencies of oxygen and nitrogen
relaxationFrequencyOxygen = ( pressureKPa / referencePressureKPa ) *
( 24.0f + ( 4.04f * 10000.0f * molarConcentrationWaterVaporPercent *
( ( 0.02f + molarConcentrationWaterVaporPercent ) / ( 0.391f + molarConcentrationWaterVaporPercent ) ) ) );
relaxationFrequencyNitrogen = ( pressureKPa / referencePressureKPa ) *
( pow( ( roomTemperatureKelvin / 293.16f ), -0.5f ) ) *
( 9.0f + 280.0f * molarConcentrationWaterVaporPercent *
exp( -4.17f * ( ( pow( ( roomTemperatureKelvin / 293.16f ), -0.3333333f ) ) - 1.0f ) ) );
// determine air absorption for desired filter resolution
//unsigned int numberOfParameters = frequencies.size();
unsigned int numberOfParameters = 31;
for( unsigned int i = 0; i < numberOfParameters; ++i )
{
/* airAbsorptionCoeffs[i] =
(
pow(frequencies[i], 2.0f) *
((1.84f * pow(10.0f, -11.0f) * ( referencePressureKPa / pressureKPa) * pow((roomTemperatureKelvin/293.16f), 0.5f)) +
(pow((roomTemperatureKelvin/293.16f), -2.5f) * (
((1.278f * 0.01f * exp( (-2239.1f/roomTemperatureKelvin))) /
(relaxationFrequencyOxygen + (pow(frequencies[i], 2.0f)/relaxationFrequencyOxygen))) +
((1.068f * 0.1f * exp((-3352.0f/roomTemperatureKelvin))/
(relaxationFrequencyNitrogen + (pow(frequencies[i], 2.0f)/relaxationFrequencyNitrogen)))))))
)* 2000.0f * log10(exp(1.0f)); // Neper/m -> dB/100m
*/
/* airAbsorptionCoeffs[i] =
(
pow(frequencies[i], 2.0f) *
((1.84f * pow(10.0f, -11.0f) * ( referencePressureKPa / pressureKPa) * pow((roomTemperatureKelvin/293.16f), 0.5f)) +