Commit 39b9ef19 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Removing internal sound speed handling and substituting with core-provided...

Removing internal sound speed handling and substituting with core-provided homogeneous medium information
parent 7113667d
......@@ -77,6 +77,8 @@ OutputRecordFilePath = $(ProjectName)_out.wav
# Set log level: 0 = quiet; 1 = errors; 2 = warnings (default); 3 = info; 4 = verbose; 5 = trace;
LogLevel = @ITA_VACORE_DEFAULT_DEBUG_LEVEL@
# Controls the core update rate for pushed events (like level meters)
TriggerUpdateMilliseconds = 100
[Audio driver]
......@@ -114,6 +116,15 @@ Buffersize = AUTO
#
[HomogeneousMedium]
DefaultSoundSpeed = 344.0 # m/s
DefaultStaticPressure = 101125.0 # [Pa]
DefaultTemperature = 20.0 # [Degree centigrade]
DefaultRelativeHumidity = 20.0 # [Percent]
DefaultShiftSpeed = 0.0, 0.0, 0.0 # 3D vector in m/s
[Renderer:MyBinauralFreeField]
Enabled = true
Class = BinauralFreeField
......@@ -152,7 +163,6 @@ SoundPowerCorrectionFactor = 0.05
TimeSlotResolution = 0.005
MaxReflectionDensity = 12000.0
ScatteringCoefficient = 0.1
SpeedOfSound = 344.0
[Renderer:MyBinauralRoomAcoustics]
Class = BinauralRoomAcoustics
......@@ -183,7 +193,6 @@ MotionModelLogInputSources = false
MotionModelLogEstimatedOutputSources = false
DumpListeners = false
DumpListenersGain = 1.0
SpeedOfSound = 344.0
SwitchingAlgorithm = linear
[Renderer:MyHearingAidRenderer]
......
......@@ -289,7 +289,6 @@ void CVAAmbisonicsFreeFieldAudioRenderer::Init( const CVAStruct& oArgs )
{
CVAConfigInterpreter conf( oArgs );
conf.OptNumber( "SpeedOfSound", m_dSpeedOfSound, 344.0f );
conf.ReqInteger( "TruncationOrder", m_iMaxOrder );
m_iNumChannels = ( m_iMaxOrder + 1 )*( m_iMaxOrder + 1 );
......@@ -704,7 +703,7 @@ void CVAAmbisonicsFreeFieldAudioRenderer::HandleProcessStream( ITADatasourceReal
{
pPath->pVariableDelayLineCh->SetAlgorithm( !bDPEnabledCurrent ? m_iDefaultVDLSwitchingAlgorithm : CITAVariableDelayLine::SWITCH );
}
pPath->UpdateMediumPropagation( m_dSpeedOfSound, m_dAdditionalStaticDelaySeconds );
pPath->UpdateMediumPropagation( m_pCore->oHomogeneousMedium.dSoundSpeed, m_dAdditionalStaticDelaySeconds );
// Spherical spreading loss
bool bSSLEnabledSource = ( pSourceState->GetAuralizationMode() & IVAInterface::VA_AURAMODE_SPREADING_LOSS ) > 0;
......
......@@ -291,7 +291,6 @@ private:
int m_iMaxOrder;
int m_iNumChannels;
double m_dSpeedOfSound;
bool m_bDumpListeners;
double m_dDumpListenersGain;
ITAAtomicInt m_iDumpListenersFlag;
......
......@@ -347,7 +347,6 @@ void CVABinauralAirTrafficNoiseAudioRenderer::Init( const CVAStruct& oArgs )
{
CVAConfigInterpreter conf( oArgs );
conf.OptNumber( "SpeedOfSound", m_dSpeedOfSound, 344.0f );
conf.OptNumber( "GroundPlanePosition", m_dGroundPlanePosition, 0.0f );
conf.OptBool( "PropagationDelayExternalSimulation", m_bPropagationDelayExternalSimulation, false );
......@@ -762,7 +761,7 @@ void CVABinauralAirTrafficNoiseAudioRenderer::ProcessStream( const ITAStreamInfo
}
if( !m_bPropagationDelayExternalSimulation )
pPath->UpdateMediumPropagation( m_dSpeedOfSound );
pPath->UpdateMediumPropagation( m_pCore->oHomogeneousMedium.dSoundSpeed );
// DSP: set VDL delay time
pPath->oDirSoundPath.pVariableDelayLine->SetDelayTime( pPath->oDirSoundPath.dPropagationTime );
......
......@@ -237,7 +237,6 @@ private:
std::map< int, CVABATNSource* > m_mSources; //!< Interne Abbildung der verfgbaren Quellen
std::map< int, CVABATNSoundReceiver* > m_mListeners; //!< Interne Abbildung der verfgbaren Hrer
double m_dSpeedOfSound; //!< Schallgeschwindigkeit zur Berechnung von Verzgerungen @todo take from homogeneous medium info
double m_dGroundPlanePosition; //!< Position of ground plane (height) for reflection calculation
int m_iHRIRFilterLength; //!< Length of the HRIR filter DSP module
......
......@@ -265,9 +265,7 @@ void CVABinauralArtificialReverbAudioRenderer::Init( const CVAStruct& oArgs )
conf.OptNumber( "TimeSlotResolution", m_dTimeSlotResolution, 0.005f );
conf.OptNumber( "MaxReflectionDensity", m_dMaxReflectionDensity, 12000.0f );
conf.OptNumber( "ScatteringCoefficient", m_dScatteringCoefficient, 0.1f );
conf.OptNumber( "SpeedOfSound", m_dSpeedOfSound, 344.0f );
std::string sVLDInterpolationAlgorithm;
conf.OptString( "VDLSwitchingAlgorithm", sVLDInterpolationAlgorithm, "linear" );
sVLDInterpolationAlgorithm = toLowercase( sVLDInterpolationAlgorithm );
......@@ -771,7 +769,7 @@ void CVABinauralArtificialReverbAudioRenderer::ProcessStream( const ITAStreamInf
// VDL delay
assert( m_dSpeedOfSound > 0 );
double dDelay = pPath->oRelations.dDistance / m_dSpeedOfSound;
double dDelay = pPath->oRelations.dDistance / m_pCore->oHomogeneousMedium.dSoundSpeed;
pPath->pVariableDelayLine->SetDelayTime( float( dDelay ) );
// VDL Doppler shift
......@@ -1254,7 +1252,6 @@ void CVABinauralArtificialReverbAudioRenderer::UpdateArtificialReverbFilter( Lis
assert( dRoomSurfaceArea > 0.0f );
assert( dRoomVolume > 0.0f );
assert( dReverberationTime > 0.0f );
assert( m_dSpeedOfSound > 0.0f );
assert( m_dTimeSlotResolution > 0.0f );
// START LAS -----------------------------------------------------------------------------------------
......@@ -1269,7 +1266,7 @@ void CVABinauralArtificialReverbAudioRenderer::UpdateArtificialReverbFilter( Lis
const double dSamplesPerTimeSlot = GetSampleRate() * m_dTimeSlotResolution;
// get time of last image source
const double dTimeLastImageSource = dMeanfreePath / m_dSpeedOfSound;
const double dTimeLastImageSource = dMeanfreePath / m_pCore->oHomogeneousMedium.dSoundSpeed;
// calc critical distances and initial reverberation energies
const double dTimeConst = -13.816f / dReverberationTime;
......@@ -1285,7 +1282,7 @@ void CVABinauralArtificialReverbAudioRenderer::UpdateArtificialReverbFilter( Lis
// calc initial energy (formula see diploma thesis Lukas Aspck)
// correction factor as envelope curve has approx 3 times the energy the synth ir has
double dInitialEnergy = 3.0f / pow( dCriticalDistance, 2 ) / m_dSpeedOfSound / dAreaNormIntegral;
double dInitialEnergy = 3.0f / pow( dCriticalDistance, 2 ) / m_pCore->oHomogeneousMedium.dSoundSpeed / dAreaNormIntegral;
assert( dInitialEnergy > 0.0f );
double dCurrentScaleFactor; // PROBLEM
......@@ -1303,7 +1300,7 @@ void CVABinauralArtificialReverbAudioRenderer::UpdateArtificialReverbFilter( Lis
// calculates reflection density according to kuttruffs equation
double dTime = ( iTimeSlot * iBlockLength + 1 ) / GetSampleRate();
double dCurrentReflectionDensity = 4.0f * ITAConstants::PI_D * m_dSpeedOfSound * m_dSpeedOfSound * m_dSpeedOfSound * dTime * dTime / dRoomVolume;
double dCurrentReflectionDensity = 4.0f * ITAConstants::PI_D * m_pCore->oHomogeneousMedium.dSoundSpeed* m_pCore->oHomogeneousMedium.dSoundSpeed* m_pCore->oHomogeneousMedium.dSoundSpeed * dTime * dTime / dRoomVolume;
// if the density exceeds maximumReflectionDensity it will be kept constant at this value
if( dCurrentReflectionDensity > m_dMaxReflectionDensity )
......@@ -1370,7 +1367,7 @@ void CVABinauralArtificialReverbAudioRenderer::UpdateArtificialReverbFilter( Lis
// insert scattered energy
for( int k = 0; k < iNumberOfScatteredPulses; k++ )
{
int iScatterDelayInSamples = int( ( ( k + 1 ) / double( iNumberOfScatteredPulses ) ) * ( 2.0f * dAverageLengthRoom / m_dSpeedOfSound * GetSampleRate() ) + rand() % 30 );
int iScatterDelayInSamples = int( ( ( k + 1 ) / double( iNumberOfScatteredPulses ) ) * ( 2.0f * dAverageLengthRoom / m_pCore->oHomogeneousMedium.dSoundSpeed * GetSampleRate() ) + rand() % 30 );
assert( dSpectralEnergyThisSample > 0.0f );
double dCurrentScatterFactor = iRandomSign *
......
......@@ -195,7 +195,6 @@ private:
double m_dMaxReflectionDensity;
double m_dScatteringCoefficient;
double m_dSpeedOfSound; //!< Speed of Sound for delay calculation [m/s]
int m_iMaxReverbFilterLengthSamples; //!< Maximum length of the artificial reverb filter DSP module
int m_iDefaultVDLSwitchingAlgorithm; //!< Switching algorithm of variable delay lines
......
......@@ -296,9 +296,7 @@ CVABinauralFreeFieldAudioRenderer::~CVABinauralFreeFieldAudioRenderer()
void CVABinauralFreeFieldAudioRenderer::Init( const CVAStruct& oArgs )
{
CVAConfigInterpreter conf( oArgs );
conf.OptNumber( "SpeedOfSound", m_dSpeedOfSound, 344.0f );
std::string sVLDInterpolationAlgorithm;
conf.OptString( "SwitchingAlgorithm", sVLDInterpolationAlgorithm, "linear" );
sVLDInterpolationAlgorithm = toLowercase( sVLDInterpolationAlgorithm );
......@@ -707,7 +705,7 @@ void CVABinauralFreeFieldAudioRenderer::ProcessStream( const ITAStreamInfo* pStr
pPath->pVariableDelayLineChL->SetAlgorithm( !bDPEnabledCurrent ? m_iDefaultVDLSwitchingAlgorithm : CITAVariableDelayLine::SWITCH );
pPath->pVariableDelayLineChR->SetAlgorithm( !bDPEnabledCurrent ? m_iDefaultVDLSwitchingAlgorithm : CITAVariableDelayLine::SWITCH );
}
pPath->UpdateMediumPropagation( m_dSpeedOfSound, m_dAdditionalStaticDelaySeconds );
pPath->UpdateMediumPropagation( m_pCore->oHomogeneousMedium.dSoundSpeed, m_dAdditionalStaticDelaySeconds );
// Spherical spreading loss
bool bSSLEnabledSource = ( pSourceState->GetAuralizationMode() & IVAInterface::VA_AURAMODE_SPREADING_LOSS ) > 0;
......
......@@ -290,7 +290,6 @@ private:
std::map< int, CVABFFSource* > m_mSources; //!< Internal list of sources
std::map< int, CVABFFListener* > m_mListeners; //!< Internal list of listener
double m_dSpeedOfSound;
bool m_bDumpListeners;
double m_dDumpListenersGain;
ITAAtomicInt m_iDumpListenersFlag;
......
......@@ -258,8 +258,6 @@ void CVAMonauralFreeFieldAudioRenderer::Init( const CVAStruct& oArgs )
{
CVAConfigInterpreter conf( oArgs );
conf.OptNumber( "SpeedOfSound", m_dSpeedOfSound, 344.0f );
std::string sVLDInterpolationAlgorithm;
conf.OptString( "SwitchingAlgorithm", sVLDInterpolationAlgorithm, "linear" );
sVLDInterpolationAlgorithm = toLowercase( sVLDInterpolationAlgorithm );
......@@ -668,7 +666,7 @@ void CVAMonauralFreeFieldAudioRenderer::ProcessStream( const ITAStreamInfo* pStr
bool bDPStatusChanged = ( bDPEnabledCurrent != ( bDPEnabledGlobal && bDPEnabledListener && bDPEnabledSource ) );
if( bDPStatusChanged )
pPath->pVariableDelayLine->SetAlgorithm( !bDPEnabledCurrent ? m_iDefaultVDLSwitchingAlgorithm : CITAVariableDelayLine::SWITCH );
pPath->UpdateMediumPropagation( m_dSpeedOfSound );
pPath->UpdateMediumPropagation( m_pCore->oHomogeneousMedium.dSoundSpeed );
// Spherical spreading loss
bool bSSLEnabledSource = ( pSourceState->GetAuralizationMode() & IVAInterface::VA_AURAMODE_SPREADING_LOSS ) > 0;
......
......@@ -265,9 +265,7 @@ private:
std::map< int, CVAMFFSource* > m_mSources; //!< Internal list of sources
std::map< int, CVAMFFListener* > m_mListeners; //!< Internal list of listener
double m_dSpeedOfSound;
int m_iDefaultVDLSwitchingAlgorithm;
bool m_bDumpListenerOutputSignals; //!< Listener dumping enabled
......
......@@ -317,9 +317,7 @@ CVAPTHearingAidRenderer::~CVAPTHearingAidRenderer()
void CVAPTHearingAidRenderer::Init( const CVAStruct& oArgs )
{
CVAConfigInterpreter conf( oArgs );
conf.OptNumber( "SpeedOfSound", m_dSpeedOfSound, 344.0f );
// update rates
conf.OptNumber( "UpdateRateDS", m_dUpdateRateDS, 120.0f );
conf.OptNumber( "UpdateRateIS", m_dUpdateRateIS, 10.0f );
......@@ -703,7 +701,7 @@ void CVAPTHearingAidRenderer::ProcessStream( const ITAStreamInfo* pStreamInfo )
if( bDPStatusChanged )
pPath->pVariableDelayLine->SetAlgorithm( !bDPEnabledCurrent ? m_iDefaultVDLSwitchingAlgorithm : CITAVariableDelayLine::SWITCH );
pPath->UpdateMediumPropagation( m_dSpeedOfSound );
pPath->UpdateMediumPropagation( m_pCore->oHomogeneousMedium.dSoundSpeed );
double dDistanceDecrease = pPath->CalculateInverseDistanceDecrease();
bool bDIREnabledSoure = ( pSourceState->GetAuralizationMode() & IVAInterface::VA_AURAMODE_SOURCE_DIRECTIVITY ) > 0;
......
......@@ -294,7 +294,6 @@ private:
std::vector<int> m_viHARIRChannels; //!< Vector containing the input channel selection of the HARIR daff files [default: 1,2,3,4]
double m_dSpeedOfSound;
bool m_bDumpListeners;
//std::string m_sDumpListenersFilenameFormat;
double m_dDumpListenersGain;
......
......@@ -153,7 +153,6 @@ private:
VistaVector3D m_vecCaveCenterOrientYPR; //!< Mittelpunkt der CAVE Umgebung relativ zu Szene
int m_iSetupDimension; //!< Dimension of setup, see \DIMENSIONS
double m_dSpeedOfSound; //!< Speed of sound in medium, m/s
const CVAHardwareOutput* m_pOutput; //!< Hardware output group with information on devices
std::vector< CSection > m_voSectionList; //!< List of all sections for the VBAP setup (DIM_3D only)
......
......@@ -3652,7 +3652,7 @@ void CVACoreImpl::SetHomogeneousMediumSoundSpeed( const double dSoundSpeed )
{
if( dSoundSpeed <= 0.0f )
VA_EXCEPT2( INVALID_PARAMETER, "Speed of sound can not be zero or negative" );
m_oHomogeneousMedium.dSoundSpeed = dSoundSpeed;
oHomogeneousMedium.dSoundSpeed = dSoundSpeed;
}
VA_RETHROW;
}
......@@ -3660,7 +3660,7 @@ void CVACoreImpl::SetHomogeneousMediumSoundSpeed( const double dSoundSpeed )
double CVACoreImpl::GetHomogeneousMediumSoundSpeed() const
{
VA_NO_REENTRANCE;
return m_oHomogeneousMedium.dSoundSpeed;
return oHomogeneousMedium.dSoundSpeed;
}
void CVACoreImpl::SetHomogeneousMediumTemperature( const double dDegreesCentigrade )
......@@ -3670,7 +3670,7 @@ void CVACoreImpl::SetHomogeneousMediumTemperature( const double dDegreesCentigra
{
if( dDegreesCentigrade <= -270.0f )
VA_EXCEPT2( INVALID_PARAMETER, "Temperature can not be below total zero" );
m_oHomogeneousMedium.dTemperatureDegreeCentigrade = dDegreesCentigrade;
oHomogeneousMedium.dTemperatureDegreeCentigrade = dDegreesCentigrade;
}
VA_RETHROW;
}
......@@ -3678,7 +3678,7 @@ void CVACoreImpl::SetHomogeneousMediumTemperature( const double dDegreesCentigra
double CVACoreImpl::GetHomogeneousMediumTemperature() const
{
VA_NO_REENTRANCE;
return m_oHomogeneousMedium.dTemperatureDegreeCentigrade;
return oHomogeneousMedium.dTemperatureDegreeCentigrade;
}
void CVACoreImpl::SetHomogeneousMediumStaticPressure( const double dPressurePascal )
......@@ -3688,7 +3688,7 @@ void CVACoreImpl::SetHomogeneousMediumStaticPressure( const double dPressurePasc
{
if( dPressurePascal <= 0.0f )
VA_EXCEPT2( INVALID_PARAMETER, "Static pressure can not be zero or negative" );
m_oHomogeneousMedium.dStaticPressurePascal = dPressurePascal;
oHomogeneousMedium.dStaticPressurePascal = dPressurePascal;
}
VA_RETHROW;
}
......@@ -3696,7 +3696,7 @@ void CVACoreImpl::SetHomogeneousMediumStaticPressure( const double dPressurePasc
double CVACoreImpl::GetHomogeneousMediumStaticPressure() const
{
VA_NO_REENTRANCE;
return m_oHomogeneousMedium.dStaticPressurePascal;
return oHomogeneousMedium.dStaticPressurePascal;
}
void CVACoreImpl::SetHomogeneousMediumRelativeHumidity( const double dRelativeHumidityPercent )
......@@ -3706,7 +3706,7 @@ void CVACoreImpl::SetHomogeneousMediumRelativeHumidity( const double dRelativeHu
{
if( dRelativeHumidityPercent < 0.0f )
VA_EXCEPT2( INVALID_PARAMETER, "Relative humidity can not be negative" );
m_oHomogeneousMedium.dRelativeHumidityPercent = dRelativeHumidityPercent;
oHomogeneousMedium.dRelativeHumidityPercent = dRelativeHumidityPercent;
}
VA_RETHROW;
}
......@@ -3714,7 +3714,7 @@ void CVACoreImpl::SetHomogeneousMediumRelativeHumidity( const double dRelativeHu
double CVACoreImpl::GetHomogeneousMediumRelativeHumidity()
{
VA_NO_REENTRANCE;
return m_oHomogeneousMedium.dRelativeHumidityPercent;
return oHomogeneousMedium.dRelativeHumidityPercent;
}
void CVACoreImpl::SetHomogeneousMediumShiftSpeed( const VAVec3& v3TranslationSpeed )
......@@ -3722,9 +3722,9 @@ void CVACoreImpl::SetHomogeneousMediumShiftSpeed( const VAVec3& v3TranslationSpe
VA_NO_REENTRANCE;
VA_TRY
{
if( v3TranslationSpeed.Length() >= m_oHomogeneousMedium.dSoundSpeed )
if( v3TranslationSpeed.Length() >= oHomogeneousMedium.dSoundSpeed )
VA_EXCEPT2( INVALID_PARAMETER, "Medium shift can not be equal or faster than sound speed" );
m_oHomogeneousMedium.v3ShiftSpeed = v3TranslationSpeed;
oHomogeneousMedium.v3ShiftSpeed = v3TranslationSpeed;
}
VA_RETHROW;
}
......@@ -3732,19 +3732,19 @@ void CVACoreImpl::SetHomogeneousMediumShiftSpeed( const VAVec3& v3TranslationSpe
VAVec3 CVACoreImpl::GetHomogeneousMediumShiftSpeed() const
{
VA_NO_REENTRANCE;
return m_oHomogeneousMedium.v3ShiftSpeed;
return oHomogeneousMedium.v3ShiftSpeed;
}
void CVACoreImpl::SetHomogeneousMediumParameters( const CVAStruct& oParams )
{
VA_NO_REENTRANCE;
m_oHomogeneousMedium.oParameters = oParams;
oHomogeneousMedium.oParameters = oParams;
}
CVAStruct CVACoreImpl::GetHomogeneousMediumParameters( const CVAStruct& oArgs )
{
VA_NO_REENTRANCE;
return m_oHomogeneousMedium.oParameters;
return oHomogeneousMedium.oParameters;
}
std::string CVACoreImpl::CreateScene( const CVAStruct& oParams, const std::string& sSceneName )
......
......@@ -309,6 +309,29 @@ public:
bool IsStreaming() const;
//! Homogeneous medium definitions
struct CVAHomogeneousMedium
{
double dSoundSpeed; //!< Speed of sound in m/s
double dStaticPressurePascal; //!< Static pressure in Pascal
double dTemperatureDegreeCentigrade; //!< Temperature in degree centigrade
double dRelativeHumidityPercent; //!< Relative humidity
VAVec3 v3ShiftSpeed; //!< Medium shift speed in m/s
CVAStruct oParameters; //!< Special parameters, for prototyping
inline CVAHomogeneousMedium()
{
dSoundSpeed = g_dDefaultSpeedOfSound;
dStaticPressurePascal = g_dDefaultStaticPressure;
dTemperatureDegreeCentigrade = g_dDefaultTemperature;
dRelativeHumidityPercent = g_dDefaultRelativeHumidity;
v3ShiftSpeed.Set( 0.0f, 0.0f, 0.0f );
}
} oHomogeneousMedium;
private:
ITACriticalSection m_csReentrance; //!< Lock for reentrance check
ITACriticalSection m_csSyncMod; //!< Lock fr synchronisierte Szene-Modifikationen
......@@ -460,27 +483,6 @@ private:
CVACoreEventManager* m_pEventManager;
//! Homogeneous medium definitions
struct CVAHomogeneousMedium
{
double dSoundSpeed; //!< Speed of sound in m/s
double dStaticPressurePascal; //!< Static pressure in Pascal
double dTemperatureDegreeCentigrade; //!< Temperature in degree centigrade
double dRelativeHumidityPercent; //!< Relative humidity
VAVec3 v3ShiftSpeed; //!< Medium shift speed in m/s
CVAStruct oParameters; //!< Special parameters, for prototyping
inline CVAHomogeneousMedium()
{
dSoundSpeed = 344.0f;
dStaticPressurePascal = 105125.0f;
dTemperatureDegreeCentigrade = 20.0f;
dRelativeHumidityPercent = 20.0f;
v3ShiftSpeed.Set( 0.0f, 0.0f, 0.0f );
}
} m_oHomogeneousMedium;
// Diese Hilfsmethoden bedienen die Locks um die serielle Ausfhrung
// externer Methoden zu gewhrleisten und die Reentrance zu blockieren
// (siehe externe Methoden).
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment