Commit 8735d5be authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Avoiding a lot of C4512 errors and introducing volume getter with calibration...

Avoiding a lot of C4512 errors and introducing volume getter with calibration mode from core in all rendering modules
parent a966ab23
......@@ -104,16 +104,16 @@ Samplerate = 44100
# Note: Adjust this to your latency requirements
Buffersize = AUTO
# --= Audio renderers =--
# Syntax [Renderer:<ID>] <ID> can be freely chosen, but must be unique
#
# Fields:
#
# Enabled = (true|false) Create the renderer or skip it (default: true)
# Class = <TYPE> Renderer type/class to create [MANDATORY]
# Outputs = <LIST> Modules the renderer sends its output samples to (hardware output or reproduction module) [MANDATORY]
#
[Calibration]
# The amplitude calibration mode either sets the internal conversion from
# sound pressure to an electrical or digital amplitude signal (audio stream)
# to 94dB (default) or to 124dB. The rendering modules will use this calibration
# mode to calculate from physical values to an amplitude that can be forwarded
# to the reproduction modules. If a reproduction module operates in calibrated
# mode, the resulting physical sound pressure at receiver location can be maintained.
DefaultAmplitudeCalibrationMode = 94dB
[HomogeneousMedium]
......
......@@ -17,6 +17,7 @@
#include "VAMotionModel.h"
#include <VABase.h>
#include <VAStruct.h>
#include <VAException.h>
#include <ITADataLog.h>
......@@ -171,6 +172,7 @@ protected:
private:
const Config m_oConf;
CVABasicMotionModel & operator=( const CVABasicMotionModel & ) { VA_EXCEPT_NOT_IMPLEMENTED; };
};
#endif // IW_VACORE_MOTIONMODELBASE
......@@ -105,7 +105,7 @@ void CVAAmbientMixerAudioRenderer::HandleProcessStream( ITADatasourceRealization
continue;
const ITASampleBuffer* psbInput = pDesc->pSignalSourceInputBuf;
double dGainFactor = pState->GetVolume();
double dGainFactor = pState->GetVolume( m_oParams.pCore->GetCoreConfig()->dDefaultAmplitudeCalibration );
// Add samples to out buffer
for( int n=0; n < int( m_pDataSource->GetNumberOfChannels() ); n++ )
......
......@@ -52,6 +52,7 @@ private:
CVASceneState* m_pNewSceneState;
CVASceneState* m_pCurSceneState;
ITAAtomicBool m_bIndicateReset, m_bResetAck;
CVAAmbientMixerAudioRenderer operator=( const CVAAmbientMixerAudioRenderer & ) { VA_EXCEPT_NOT_IMPLEMENTED; };
};
#endif // ( VACORE_WITH_RENDERER_AMBIENT_MIXER == 1 )
......
......@@ -728,7 +728,7 @@ void CVAAmbisonicsFreeFieldAudioRenderer::HandleProcessStream( ITADatasourceReal
bool bDSGlobalStatusEnabled = ( m_iCurGlobalAuralizationMode & IVAInterface::VA_AURAMODE_DIRECT_SOUND );
bool bDSEnabled = bDSSourceStatusEnabled && bDSListenerStatusEnabled && bDSGlobalStatusEnabled;
float fSoundSourceGain = float( dDistanceDecrease * pSourceState->GetVolume() );
float fSoundSourceGain = float( dDistanceDecrease * pSourceState->GetVolume( m_oParams.pCore->GetCoreConfig()->dDefaultAmplitudeCalibration ) );
if( pPath->pSource->pData->bMuted || ( bDSEnabled == false ) )
fSoundSourceGain = 0.0f;
......
......@@ -806,7 +806,7 @@ void CVABinauralArtificialReverbAudioRenderer::ProcessStream( const ITAStreamInf
pPath->pVariableDelayLine->Process( psbSourceInput, &ctxAudio.m_sbTempBuf1 );
float fSoundSourceGain = pPath->pSource->pData->bMuted ? 0.0f : float( pSourceState->GetVolume() );
float fSoundSourceGain = pPath->pSource->pData->bMuted ? 0.0f : float( pSourceState->GetVolume( m_oParams.pCore->GetCoreConfig()->dDefaultAmplitudeCalibration ) );
// Diffuse decay auralization mode, react upon source aura mode here
bool bDDEnabledSource = ( pSourceState->GetAuralizationMode() & IVAInterface::VA_AURAMODE_DIFFUSE_DECAY ) > 0;
......
......@@ -279,6 +279,9 @@ private:
friend class CBARPath;
friend class CBARSimulator;
//! Not for use, avoid C4512
CVABinauralArtificialReverbAudioRenderer operator=( const CVABinauralArtificialReverbAudioRenderer & ) { VA_EXCEPT_NOT_IMPLEMENTED; };
};
#endif // ( VACORE_WITH_RENDERER_BINAURAL_ARTIFICIAL_REVERB == 1 )
......
......@@ -730,7 +730,7 @@ void CVABinauralFreeFieldAudioRenderer::ProcessStream( const ITAStreamInfo* pStr
bool bDSGlobalStatusEnabled = ( m_iCurGlobalAuralizationMode & IVAInterface::VA_AURAMODE_DIRECT_SOUND );
bool bDSEnabled = bDSSourceStatusEnabled && bDSListenerStatusEnabled && bDSGlobalStatusEnabled;
float fSoundSourceGain = float( dDistanceDecrease * pSourceState->GetVolume() );
float fSoundSourceGain = float( dDistanceDecrease * pSourceState->GetVolume( m_oParams.pCore->GetCoreConfig()->dDefaultAmplitudeCalibration ) );
if( pPath->pSource->pData->bMuted || ( bDSEnabled == false ) )
fSoundSourceGain = 0.0f;
pPath->pFIRConvolverChL->SetGain( fSoundSourceGain );
......
......@@ -84,7 +84,7 @@ public:
/**
* This method loads a scene, usually a file path to geometry data.
*/
inline void LoadScene( const std::string& sFilename ) {};
inline void LoadScene( const std::string& ) {};
//! Handle a scene state change
/**
......@@ -361,6 +361,9 @@ private:
friend class CVABFFSoundPath;
friend class CVABFFListenerPoolFactory;
friend class CVABFFSourcePoolFactory;
//! Not for use, avoid C4512
CVABinauralFreeFieldAudioRenderer operator=( const CVABinauralFreeFieldAudioRenderer & ) { VA_EXCEPT_NOT_IMPLEMENTED; };
};
#endif // ( VACORE_WITH_RENDERER_BINAURAL_FREE_FIELD==1 )
......
......@@ -1839,7 +1839,7 @@ void CVARoomAcousticsAudioRenderer::ProcessStream( const ITAStreamInfo* pStreamI
CVASoundSourceState* pSourceStateCur = m_pCurSceneState ? m_pCurSceneState->GetSoundSourceState( pSourceData->iID ) : nullptr;
if( pSourceStateCur != nullptr )
{
double dVolume = pSourceStateCur->GetVolume();
double dVolume = pSourceStateCur->GetVolume( m_oParams.pCore->GetCoreConfig()->dDefaultAmplitudeCalibration );
if( dVolume != 1.0f )
psbInput->mul_scalar( ( float ) dVolume );
}
......
......@@ -80,23 +80,23 @@ public:
class CDirectivityState
{
public:
CDirectivityState()
: pData( NULL )
, iRecord( -1 )
, bDirectivityEnabled( true ) {}
inline CDirectivityState()
: pData( NULL )
, iRecord( -1 )
, bDirectivityEnabled( true ) {};
IVADirectivity* pData; //!< Directivity data, may be NULL
int iRecord; //!< Directivity index
bool bDirectivityEnabled;
bool operator==( const CDirectivityState& rhs ) const
inline bool operator==( const CDirectivityState& rhs ) const
{
bool bBothEnabled = ( bDirectivityEnabled == rhs.bDirectivityEnabled );
bool bSameRecordIndex = ( iRecord == rhs.iRecord );
bool bSameData = ( pData == rhs.pData );
return ( bBothEnabled && bSameRecordIndex && bSameData );
}
};
};
CVAMonauralFreeFieldAudioRenderer::CVAMFFSource* pSource;
......@@ -113,7 +113,7 @@ public:
CITAVariableDelayLine* pVariableDelayLine;
float fPrevGain;
void PreRequest()
inline void PreRequest()
{
pSource = nullptr;
pListener = nullptr;
......@@ -156,15 +156,15 @@ private:
class CVAMFFSoundPathFactory : public IVAPoolObjectFactory{
public:
CVAMFFSoundPathFactory( double dSamplerate, int iBlocklength, int iDirFilterLength )
: m_dSamplerate(dSamplerate)
, m_iBlocklength(iBlocklength)
, m_iDirFilterLength(iDirFilterLength)
{}
: m_dSamplerate( dSamplerate )
, m_iBlocklength( iBlocklength )
, m_iDirFilterLength( iDirFilterLength )
{};
CVAPoolObject* CreatePoolObject()
inline CVAPoolObject* CreatePoolObject()
{
return new CVAMFFSoundPath( m_dSamplerate, m_iBlocklength, m_iDirFilterLength );
}
};
private:
double m_dSamplerate; //!< Abtastrate
......@@ -175,12 +175,12 @@ private:
class CVAMFFListenerPoolFactory : public IVAPoolObjectFactory
{
public:
CVAMFFListenerPoolFactory( CVACoreImpl* pCore, const CVAMonauralFreeFieldAudioRenderer::CVAMFFListener::Config& oConf )
inline CVAMFFListenerPoolFactory( CVACoreImpl* pCore, const CVAMonauralFreeFieldAudioRenderer::CVAMFFListener::Config& oConf )
: m_pCore( pCore ), m_oListenerConf( oConf )
{
};
CVAPoolObject* CreatePoolObject()
inline CVAPoolObject* CreatePoolObject()
{
CVAMonauralFreeFieldAudioRenderer::CVAMFFListener * pListener;
pListener = new CVAMonauralFreeFieldAudioRenderer::CVAMFFListener( m_pCore, m_oListenerConf );
......@@ -195,12 +195,12 @@ private:
class CVAMFFSourcePoolFactory : public IVAPoolObjectFactory
{
public:
CVAMFFSourcePoolFactory( const CVAMonauralFreeFieldAudioRenderer::CVAMFFSource::Config& oConf )
inline CVAMFFSourcePoolFactory( const CVAMonauralFreeFieldAudioRenderer::CVAMFFSource::Config& oConf )
: m_oSourceConf( oConf )
{
};
CVAPoolObject* CreatePoolObject()
inline CVAPoolObject* CreatePoolObject()
{
CVAMonauralFreeFieldAudioRenderer::CVAMFFSource * pSource;
pSource = new CVAMonauralFreeFieldAudioRenderer::CVAMFFSource( m_oSourceConf );
......@@ -689,7 +689,7 @@ void CVAMonauralFreeFieldAudioRenderer::ProcessStream( const ITAStreamInfo* pStr
bool bDSGlobalStatusEnabled = ( m_iCurGlobalAuralizationMode & IVAInterface::VA_AURAMODE_DIRECT_SOUND );
bool bDSEnabled = bDSSourceStatusEnabled && bDSListenerStatusEnabled && bDSGlobalStatusEnabled;
float fSoundSourceGain = float( dDistanceDecrease * pSourceState->GetVolume() );
float fSoundSourceGain = float( dDistanceDecrease * pSourceState->GetVolume( m_oParams.pCore->GetCoreConfig()->dDefaultAmplitudeCalibration ) );
if( pPath->pSource->pData->bMuted || ( bDSEnabled == false ) )
fSoundSourceGain = 0.0f;
......
......@@ -335,6 +335,9 @@ private:
friend class CVAMFFSoundPath;
friend class CVAMFFListenerPoolFactory;
friend class CVAMFFSourcePoolFactory;
//! Not for use, avoid C4512
CVAMonauralFreeFieldAudioRenderer operator=( const CVAMonauralFreeFieldAudioRenderer & ) { VA_EXCEPT_NOT_IMPLEMENTED; };
};
#endif // ( VACORE_WITH_RENDERER_MONAURAL_FREE_FIELD == 1 )
......
......@@ -55,6 +55,9 @@ public:
private:
ITADatasourceRealization* m_pDataSource;
const CVAAudioRendererInitParams oParams; //!< Create a const copy of the init params
//! Not for use, avoid C4512
CVAPTDummyAudioRenderer operator=( const CVAPTDummyAudioRenderer & ) { VA_EXCEPT_NOT_IMPLEMENTED; };
};
#endif // ( VACORE_WITH_RENDERER_PROTOTYPE_DUMMY == 1 )
......
......@@ -797,7 +797,7 @@ void CVAPTGenericPathAudioRenderer::HandleProcessStream( ITADatasourceRealizatio
CVASoundSourceDesc* pSourceData = pPath->pSource->pData;
ITASampleBuffer* psbInput = pSourceData->pSignalSourceInputBuf;
float fSoundSourceGain = float( pSourceState->GetVolume() );
float fSoundSourceGain = float( pSourceState->GetVolume( m_oParams.pCore->GetCoreConfig()->dDefaultAmplitudeCalibration ) );
for( int n=0; n < m_iNumChannels; n++ )
{
......
......@@ -183,6 +183,9 @@ private:
friend class CVAPTGenericSoundPath;
friend class CVAPTGPListenerPoolFactory;
friend class CVAPTGPSourcePoolFactory;
//! Not for use, avoid C4512
CVAPTGenericPathAudioRenderer operator=( const CVAPTGenericPathAudioRenderer & ) { VA_EXCEPT_NOT_IMPLEMENTED; };
};
#endif // ( VACORE_WITH_RENDERER_PROTOTYPE_GENERIC_PATH == 1 )
......
......@@ -718,7 +718,7 @@ void CVAPTHearingAidRenderer::ProcessStream( const ITAStreamInfo* pStreamInfo )
bool bDSGlobalStatusEnabled = ( m_iCurGlobalAuralizationMode & IVAInterface::VA_AURAMODE_DIRECT_SOUND );
bool bDSEnabled = bDSSourceStatusEnabled && bDSListenerStatusEnabled && bDSGlobalStatusEnabled;
float fSoundSourceGain = float( dDistanceDecrease * pSourceState->GetVolume() );
float fSoundSourceGain = float( dDistanceDecrease * pSourceState->GetVolume( m_oParams.pCore->GetCoreConfig()->dDefaultAmplitudeCalibration ) );
if( pPath->pSource->pData->bMuted || ( bDSEnabled == false ) )
fSoundSourceGain = 0.0f;
pPath->pFIRConvolverChL1->SetGain( ( float ) m_dRenderingGain*fSoundSourceGain );
......
......@@ -371,7 +371,7 @@ void CVAVBAPFreeFieldAudioRenderer::HandleProcessStream( ITADatasourceRealizatio
if( !bRet )
VA_WARN( "VBAP", "Could not calculate gains" );
double dOverallGain = pState->GetVolume(); // Lautsrke der Quelle einstellen
double dOverallGain = pState->GetVolume( m_oParams.pCore->GetCoreConfig()->dDefaultAmplitudeCalibration ); // Lautsrke der Quelle einstellen
dOverallGain /= vSoundSource.Length(); // 1/r Gesetz
for( int k = 0; k < vdLoudspeakerGains.size(); k++ ) // anwenden
......
......@@ -14,10 +14,11 @@
#include "VASoundSourceState.h"
#include <VA.h>
#include "../Directivities/VADirectivity.h"
#include "../VALog.h"
#include "VASceneManager.h"
#include "VAMotionState.h"
#include "../directivities/VADirectivity.h"
#include <ITANumericUtils.h>
......@@ -26,7 +27,7 @@
void CVASoundSourceState::Initialize( double dModificationTime )
{
data.pMotionState = nullptr; // undefined position
data.dVolume = 1.0f;
data.dSoundPower = g_dSoundPower_94dB_SPL_1m;
data.iAuraMode = IVAInterface::VA_AURAMODE_ALL;
data.iDirID = -1;
data.pDirData = nullptr;
......@@ -102,21 +103,31 @@ CVAMotionState* CVASoundSourceState::AlterMotionState()
}
}
VA_TRACE( "SoundSourceState", "Requested new motion state" );
return data.pMotionState;
}
double CVASoundSourceState::GetVolume() const
double CVASoundSourceState::GetVolume( const double dAmplitudeCalibration ) const
{
return data.dVolume;
if( dAmplitudeCalibration <= 0.0f )
VA_EXCEPT2( INVALID_PARAMETER, "Aplitude calibration factor for converting sound source power can not be zero or negative." );
return data.dSoundPower / dAmplitudeCalibration;
}
void CVASoundSourceState::SetSoundPower( double dSoundPower )
void CVASoundSourceState::SetSoundPower( const double dSoundPower )
{
assert( !IsFixed() );
data.dVolume = dSoundPower / g_dSoundPower_94dB_SPL_1m;
data.dSoundPower = dSoundPower;
VA_VERBOSE( "SoundSourceState", "Sound power changed" );
}
double CVASoundSourceState::GetSoundPower() const
{
return data.dSoundPower;
}
int CVASoundSourceState::GetDirectivityID() const {
int CVASoundSourceState::GetDirectivityID() const
{
return data.iDirID;
}
......@@ -128,19 +139,20 @@ const IVADirectivity* CVASoundSourceState::GetDirectivityData() const
void CVASoundSourceState::SetDirectivityID( int iDirectivityID )
{
assert( !IsFixed() );
// TODO: Validation
data.iDirID = iDirectivityID;
VA_VERBOSE( "SoundSourceState", "Directivity identifier changed" );
}
void CVASoundSourceState::SetDirectivityData( const IVADirectivity* pDirData )
{
assert( !IsFixed() );
// TODO: Validation
data.pDirData = pDirData;
VA_VERBOSE( "SoundSourceState", "Directivity dataset changed" );
}
int CVASoundSourceState::GetAuralizationMode() const {
int CVASoundSourceState::GetAuralizationMode() const
{
return data.iAuraMode;
}
......@@ -154,11 +166,11 @@ void CVASoundSourceState::SetAuralizationMode( int iAuralizationMode )
void CVASoundSourceState::SetParameters( const CVAStruct& oParams )
{
VA_VERBOSE( "SoundSourceState", "Parameters changed" );
data.oParams = oParams;
}
CVAStruct CVASoundSourceState::GetParameters( const CVAStruct& oArgs ) const
CVAStruct CVASoundSourceState::GetParameters( const CVAStruct& ) const
{
VA_VERBOSE( "SoundSourceState", "Parameters requested" );
CVAStruct oRet;
return oRet;
return data.oParams;
}
......@@ -35,15 +35,31 @@ public:
// Fixieren (Fixiert alle enthaltenen Objekte)
void Fix();
// Getter
//! Getter
const CVAMotionState* GetMotionState() const;
double GetVolume() const;
//!Get sound source volume
/**
* Volume / gain is calculated by dividing sound power with the amplitude calibration factor
* The resulting gain factor is relative to a certain sound pressure (level) at 1m, usually 94 dB SPL re 20uPa (but can also be set to 124 dB)
*
* @param[in] dAmplitudeCalibration Calibration factor amplifying source volume to achieve a certain sound pressure at amplitudes of 1.0
*
* @sa VACoreImpl::GetAmplitudeCalibration()
*/
double GetVolume( const double dAmplitudeCalibration ) const;
int GetDirectivityID() const;
const IVADirectivity* GetDirectivityData() const;
int GetAuralizationMode() const;
// Setter
//! Sets the sound source sound power in Watts (not dB!)
void SetSoundPower( const double dPowerInWatts );
//! Returns the sound source sound power in Watts (not dB!)
double GetSoundPower() const;
//! Setter
void SetDirectivityID( int iDirectivityID );
void SetDirectivityData( const IVADirectivity* pDirData );
void SetAuralizationMode( int iAuralizationMode );
......@@ -61,22 +77,19 @@ public:
//std::string ToString() const;
protected:
// Destruktion vor Pool-Release
//! Destruktion vor Pool-Release
void PreRelease();
private:
struct
{
CVAMotionState* pMotionState; //!@ Motion state pointer
double dVolume; //!@ Linear gain factor, factor of 1 is relative to 94 dB SPL @ 1m
int iAuraMode; //!@ Current auralization mode
// Richtcharakteristik [ID]
// (Hinweis: Liegt hier direkt als Zeiger fr einen schnellen Zugriff ohne Lookup)
int iDirID;
CVAMotionState* pMotionState; //!< Motion state pointer
double dSoundPower; //!< Sound power [W]
int iAuraMode; //!< Current auralization mode
int iDirID; //!< Directivity identifier
const IVADirectivity* pDirData; //!< Pointer to directivity data set
CVAStruct oParams; //!< Sound source parameters for special implementations
// Richtcharakteristik-Datensatz (DAFF)
const IVADirectivity* pDirData;
} data;
};
......
......@@ -103,6 +103,12 @@ void CVACoreConfig::Init( const CVAStruct& oData )
conf.OptNumber( "HomogeneousMedium/DefaultSoundSpeed", oInitialHomogeneousMedium.dSoundSpeed, g_dDefaultSpeedOfSound );
conf.OptNumber( "HomogeneousMedium/DefaultStaticPressure", oInitialHomogeneousMedium.dStaticPressurePascal, g_dDefaultStaticPressure );
conf.OptNumber( "HomogeneousMedium/DefaultTemperature", oInitialHomogeneousMedium.dTemperatureDegreeCentigrade, g_dDefaultTemperature );
std::string sDefaultAmplitudeCalibrationMode;
conf.OptString( "Calibration/DefaultAmplitudeCalibrationMode", sDefaultAmplitudeCalibrationMode, "94dB" );
dDefaultAmplitudeCalibration = g_dSoundPower_94dB_SPL_1m;
if( sDefaultAmplitudeCalibrationMode == "124dB" )
dDefaultAmplitudeCalibration = g_dSoundPower_128dB_SPL_1m;
}
const CVAStruct& CVACoreConfig::GetStruct() const
......
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