Commit 08c13c49 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Progress on events

parent 9544d878
......@@ -109,10 +109,10 @@ void CVAAudiofileSignalSource::SetPlaybackAction( int iPlayStateAction )
m_iRequestedPlaybackAction = iPlayStateAction;
break;
case IVAInterface::VA_PLAYBACK_ACTION_NONE:
VA_WARN( "AudiofileSignalSource", "Ignoring playback action '" << iPlayStateAction << "' (NONE)" );
VA_WARN( "BufferSignal", "Ignoring playback action '" << iPlayStateAction << "' (NONE)" );
break;
default:
VA_ERROR( "AudiofileSignalSource", "Could not apply unkown playback action '" << iPlayStateAction << "'" );
VA_ERROR( "BufferSignal", "Could not apply unkown playback action '" << iPlayStateAction << "'" );
break;
}
......@@ -263,7 +263,7 @@ const float* CVAAudiofileSignalSource::GetStreamBlock( const CVAAudiostreamState
if( m_pBufferDataSource->GetLoopMode() == false )
{
m_iCurrentPlayState = IVAInterface::VA_PLAYBACK_STATE_STOPPED; // Attention, directly modifying member, only OK here.
VA_INFO( "AudiofileSignalSource", "Playback stop transition forced during locked scene." );
VA_INFO( "BufferSignal", "Playback stop transition forced during locked scene." );
}
}
break;
......@@ -328,7 +328,7 @@ const float* CVAAudiofileSignalSource::GetStreamBlock( const CVAAudiostreamState
if( m_iCurrentPlayState != iNewPlaybackState && !bSyncMod )
{
VA_INFO( "AudiofileSignalSource", "Playback transition from '" << GetStateString( m_iCurrentPlayState ) << "'" <<
VA_INFO( "BufferSignal", "Playback transition from '" << GetStateString( m_iCurrentPlayState ) << "'" <<
" to '" << GetStateString( iNewPlaybackState ) << "'" );
assert( iNewPlaybackState != IVAInterface::VA_PLAYBACK_STATE_INVALID );
......
......@@ -26,43 +26,43 @@
#include <xutility>
CVAAmbisonicsReproduction::CVAAmbisonicsReproduction( const CVAAudioReproductionInitParams& oParams )
: m_oParams( oParams )
: m_oParams( oParams )
{
CVAConfigInterpreter conf( *(m_oParams.pConfig) );
CVAConfigInterpreter conf( *( m_oParams.pConfig ) );
conf.ReqInteger( "TruncationOrder", m_iAmbisonicsTruncationOrder );
double dSampleRate = m_oParams.pCore->GetCoreConfig()->oAudioDriverConfig.dSampleRate;
int iBlockLength = oParams.pCore->GetCoreConfig()->oAudioDriverConfig.iBuffersize;
// Decoder input (B-Format with implicit channels)
m_pDecoderMatrixPatchBay = new ITAStreamPatchbay( dSampleRate, iBlockLength );
for( size_t i=0; i<m_oParams.vpOutputs.size(); i++ )
for( size_t i = 0; i < m_oParams.vpOutputs.size(); i++ )
{
const CVAHardwareOutput* pTargetOutput = m_oParams.vpOutputs[i];
const CVAHardwareOutput* pTargetOutput = m_oParams.vpOutputs[ i ];
if( pTargetOutput == nullptr )
VA_EXCEPT2( INVALID_PARAMETER, "Unrecognized output '"+pTargetOutput->sIdentifier+"' for Ambisonics reproduction" );
VA_EXCEPT2( INVALID_PARAMETER, "Unrecognized output '" + pTargetOutput->sIdentifier + "' for Ambisonics reproduction" );
m_vpTargetOutputs.push_back( pTargetOutput );
}
std::string sReproCenterPos;
conf.OptString( "ReproductionCenterPos", sReproCenterPos, "AUTO" );
if(sReproCenterPos=="AUTO")
if( sReproCenterPos == "AUTO" )
{
//Mittelpunkt aus der ersten LS Configuration berechnen
m_vpTargetOutputs[0];
m_v3ReproductionCenterPos.Set(0, 0, 0);
m_vpTargetOutputs[ 0 ];
m_v3ReproductionCenterPos.Set( 0, 0, 0 );
// VA_EXCEPT2(NOT_IMPLEMENTED, "Automatic reproduction center calculation not implemented, please provide 3-dim vector with key 'ReproductionCenterPos' in reproduction configuration");
VA_WARN(this, "Reproduction center set to 0,0,0");
VA_WARN( this, "Reproduction center set to 0,0,0" );
}
else
{
std::vector< std::string > vsPosComponents = splitString( sReproCenterPos, ',' );
assert( vsPosComponents.size() == 3 );
m_v3ReproductionCenterPos.Set( StringToFloat( vsPosComponents[0] ), StringToFloat( vsPosComponents[1] ), StringToFloat( vsPosComponents[2] ) );
m_v3ReproductionCenterPos.Set( StringToFloat( vsPosComponents[ 0 ] ), StringToFloat( vsPosComponents[ 1 ] ), StringToFloat( vsPosComponents[ 2 ] ) );
}
return;
}
......@@ -74,7 +74,7 @@ CVAAmbisonicsReproduction::~CVAAmbisonicsReproduction()
void CVAAmbisonicsReproduction::SetInputDatasource( ITADatasource* p )
{
CVAConfigInterpreter conf(*(m_oParams.pConfig));
CVAConfigInterpreter conf( *( m_oParams.pConfig ) );
m_pDecoderMatrixPatchBay->AddInput( p );
......@@ -85,61 +85,61 @@ void CVAAmbisonicsReproduction::SetInputDatasource( ITADatasource* p )
int iMaxPossibleAmbisonicsChannelNumber = min( int( p->GetNumberOfChannels() ), iNumConfiguredAmbisonicsChannels );
std::string sOutput;
conf.ReqString("Outputs", sOutput);
m_pOutput = m_oParams.pCore->GetCoreConfig()->oHardwareSetup.GetOutput(sOutput);
conf.ReqString( "Outputs", sOutput );
m_pOutput = m_oParams.pCore->GetCoreConfig()->oHardwareSetup.GetOutput( sOutput );
Eigen::MatrixXd matY(m_pOutput->vpDevices.size(), (m_iAmbisonicsTruncationOrder + 1)*(m_iAmbisonicsTruncationOrder + 1));
Eigen::MatrixXd matY( m_pOutput->vpDevices.size(), ( m_iAmbisonicsTruncationOrder + 1 )*( m_iAmbisonicsTruncationOrder + 1 ) );
double dAzimuth, dElevation;
// TODO Center Position aus Config?
VAVec3 va3Origin(0, 0, 0);
VAVec3 va3View(0, 0, -1);
VAVec3 va3Up(0, 1, 0);
VAVec3 va3Origin( 0, 0, 0 );
VAVec3 va3View( 0, 0, -1 );
VAVec3 va3Up( 0, 1, 0 );
std::vector<double> vdYParts;
// Gather matrix with loudspeaker position as (N_LS x 3);
for (int k = 0; k < m_pOutput->vpDevices.size(); k++)
for( int k = 0; k < m_pOutput->vpDevices.size(); k++ )
{
const CVAHardwareDevice* pDevice = m_pOutput->vpDevices[k];
const CVAHardwareDevice* pDevice = m_pOutput->vpDevices[ k ];
dAzimuth = GetAzimuthOnTarget_DEG(va3Origin, va3View, va3Up, pDevice->vPos) / 180 * ITAConstants::PI_D;
dElevation = GetElevationOnTarget_DEG(va3Origin, va3View, va3Up, pDevice->vPos) / 180 * ITAConstants::PI_D;
dAzimuth = GetAzimuthOnTarget_DEG( va3Origin, va3View, va3Up, pDevice->vPos ) / 180 * ITAConstants::PI_D;
dElevation = GetElevationOnTarget_DEG( va3Origin, va3View, va3Up, pDevice->vPos ) / 180 * ITAConstants::PI_D;
vdYParts = SHRealvaluedBasefunctions(ITAConstants::PI_D / 2 - dElevation, dAzimuth, m_iAmbisonicsTruncationOrder);
for (int l = 0; l < vdYParts.size(); l++)
vdYParts = SHRealvaluedBasefunctions( ITAConstants::PI_D / 2 - dElevation, dAzimuth, m_iAmbisonicsTruncationOrder );
for( int l = 0; l < vdYParts.size(); l++ )
{
matY(k, l) = vdYParts[l];
matY( k, l ) = vdYParts[ l ];
}
}
Eigen::MatrixXd matYinv = CalculatePseudoInverse(matY);
Eigen::MatrixXd matYinv = CalculatePseudoInverse( matY );
std::vector<double> vdRemaxWeights = HOARemaxWeights(m_iAmbisonicsTruncationOrder);
std::vector<double> vdRemaxWeights = HOARemaxWeights( m_iAmbisonicsTruncationOrder );
// Ambisonics outputs
for( size_t i=0; i<m_vpTargetOutputs.size(); i++ )
for( size_t i = 0; i < m_vpTargetOutputs.size(); i++ )
{
const CVAHardwareOutput* pTargetOutput( m_vpTargetOutputs[i] );
const CVAHardwareOutput* pTargetOutput( m_vpTargetOutputs[ i ] );
m_pDecoderMatrixPatchBay->AddOutput( int( pTargetOutput->GetPhysicalOutputChannels().size() ) );
// Apply matrix as weighting gains of in/out patch bay (truncate higher orders if necessary)
for( int j=0; j < iMaxPossibleAmbisonicsChannelNumber; j++ )
for( int j = 0; j < iMaxPossibleAmbisonicsChannelNumber; j++ )
{
int iCurrentOrder = floor(sqrt(j));
for( size_t k=0; k < pTargetOutput->GetPhysicalOutputChannels().size(); k++ )
int iCurrentOrder = ( int ) floor( sqrt( j ) );
for( size_t k = 0; k < pTargetOutput->GetPhysicalOutputChannels().size(); k++ )
{
const VAVec3& v3LSPos( pTargetOutput->vpDevices[k]->vPos );
const VAVec3& v3LSPos( pTargetOutput->vpDevices[ k ]->vPos );
VAVec3 v3ViewDummy, v3UpDummy;
double dAzimuth = GetAzimuthOnTarget_DEG( m_v3ReproductionCenterPos, v3ViewDummy, v3UpDummy, v3LSPos );
double dElevation = GetAzimuthOnTarget_DEG( m_v3ReproductionCenterPos, v3ViewDummy, v3UpDummy, v3LSPos );
// todo calculate gain @mko
if ( j==0 && k==0 )
VA_WARN("AmbisonicsReproduction", "No dynamic HOA matrix calculation based on LS configuration available, using pre-calculated matrix for ITA VR lab");
double dGain = matYinv(i, j)*vdRemaxWeights[iCurrentOrder];
if( j == 0 && k == 0 )
VA_WARN( "AmbisonicsReproduction", "No dynamic HOA matrix calculation based on LS configuration available, using pre-calculated matrix for ITA VR lab" );
double dGain = matYinv( i, j )*vdRemaxWeights[ iCurrentOrder ];
m_pDecoderMatrixPatchBay->ConnectChannels( 0, int( j ), 0, int( k ), dGain );
}
}
......@@ -164,19 +164,19 @@ void CVAAmbisonicsReproduction::UpdateScene( CVASceneState* )
return;
}
Eigen::MatrixXd CVAAmbisonicsReproduction::CalculatePseudoInverse(Eigen::MatrixXd ematIn)
Eigen::MatrixXd CVAAmbisonicsReproduction::CalculatePseudoInverse( Eigen::MatrixXd ematIn )
{
Eigen::JacobiSVD<Eigen::MatrixXd> svd(ematIn, Eigen::ComputeFullU | Eigen::ComputeFullV);
Eigen::JacobiSVD<Eigen::MatrixXd> svd( ematIn, Eigen::ComputeFullU | Eigen::ComputeFullV );
double pinvtoler = 1.e-6; // choose your tolerance wisely!
Eigen::MatrixXd singularValues = svd.singularValues();
Eigen::MatrixXd singularValues_inv;
singularValues_inv = singularValues_inv.Zero(ematIn.cols(), ematIn.rows());
singularValues_inv = singularValues_inv.Zero( ematIn.cols(), ematIn.rows() );
for (int i = 0; i<singularValues.size(); ++i) {
if (singularValues(i) > pinvtoler)
singularValues_inv(i, i) = 1.0 / singularValues(i);
else singularValues_inv(i, i) = 0;
for( int i = 0; i < singularValues.size(); ++i ) {
if( singularValues( i ) > pinvtoler )
singularValues_inv( i, i ) = 1.0 / singularValues( i );
else singularValues_inv( i, i ) = 0;
}
......
......@@ -3449,7 +3449,7 @@ void CVACoreImpl::SetSoundReceiverHeadAboveTorsoOrientation( const int iID, cons
pNewMotionState->SetHeadAboveTorsoOrientation( qOrient );
CVAEvent ev;
ev.iEventType = CVAEvent::SOUND_RECEIVER_REAL_WORLD_POSE_CHANGED;
ev.iEventType = CVAEvent::SOUND_RECEIVER_CHANGED_POSE;
ev.pSender = this;
ev.iObjectID = iID;
SetCoreEventParams( ev, pNewMotionState );
......@@ -3513,15 +3513,12 @@ void CVACoreImpl::SetSoundReceiverRealWorldPositionOrientationVU( const int iID,
ConvertViewUpToQuaternion( v3View, v3Up, oNewPose.qOrient );
pNewMotionState->SetRealWorldPose( oNewPose );
/* Ereignis generieren
CVAEvent ev;
ev.iEventType = CVAEvent::REAL_WORLD_SOUND_RECEIVER_CHANGED_POSE;
ev.iEventType = CVAEvent::SOUND_RECEIVER_REAL_WORLD_POSE_CHANGED;
ev.pSender = this;
ev.iObjectID = iID;
SetCoreEventParams( ev, pNewMotionState );
m_pCoreEventMan->EnqueueEvent( ev );
*/
m_pEventManager->EnqueueEvent( ev );
if( !bSync )
UnlockUpdate();
......@@ -3580,15 +3577,12 @@ void CVACoreImpl::SetSoundReceiverRealWorldPose( const int iID, const VAVec3& v3
oNewPose.qOrient = qOrient;
pNewMotionState->SetRealWorldPose( oNewPose );
/* Ereignis generieren
CVAEvent ev;
ev.iEventType = CVAEvent::REAL_WORLD_SOUND_RECEIVER_CHANGED_POSE;
ev.iEventType = CVAEvent::SOUND_RECEIVER_CHANGED_POSE;
ev.pSender = this;
ev.iObjectID = iID;
SetCoreEventParams( ev, pNewMotionState );
m_pCoreEventMan->EnqueueEvent( ev );
*/
m_pEventManager->EnqueueEvent( ev );
if( !bSync )
UnlockUpdate();
......@@ -3642,15 +3636,12 @@ void CVACoreImpl::SetSoundReceiverRealWorldHeadAboveTorsoOrientation( const int
CVAMotionState* pNewMotionState = pListenerState->AlterMotionState();
pNewMotionState->SetRealWorldHeadAboveTorsoOrientation( qOrient );
/* Ereignis generieren
CVAEvent ev;
ev.iEventType = CVAEvent::REAL_WORLD_SOUND_RECEIVER_CHANGED_POSE;
ev.iEventType = CVAEvent::SOUND_RECEIVER_CHANGED_POSE;
ev.pSender = this;
ev.iObjectID = iID;
SetCoreEventParams( ev, pNewMotionState );
m_pCoreEventMan->EnqueueEvent( ev );
*/
m_pEventManager->EnqueueEvent( ev );
if( !bSync )
UnlockUpdate();
......@@ -3873,7 +3864,6 @@ void CVACoreImpl::SetSoundPortalName( const int iPortalID, const std::string& sN
{
m_pSceneManager->SetPortalName( iPortalID, sName );
// Ereignis generieren
CVAEvent ev;
ev.iEventType = CVAEvent::SOUND_PORTAL_CHANGED_NAME;
ev.pSender = this;
......@@ -4008,7 +3998,8 @@ void CVACoreImpl::SetInputMuted( const bool bMuted )
m_pInputAmp->SetGain( ( float ) m_dInputGain );
}
// Ereignis generieren
VA_INFO( "Core", "Input mute toggled" );
CVAEvent ev;
ev.iEventType = CVAEvent::INPUT_MUTING_CHANGED;
ev.pSender = this;
......@@ -4121,6 +4112,7 @@ void CVACoreImpl::SetOutputMuted( const bool bMuted )
if( m_bOutputMuted == bMuted )
return;
m_bOutputMuted = bMuted;
VA_INFO( "Core", "Output mute toggled" );
if( m_pOutputPatchbay )
m_pOutputPatchbay->SetOutputMuted( 0, bMuted );
......@@ -4131,7 +4123,6 @@ void CVACoreImpl::SetOutputMuted( const bool bMuted )
ev.pSender = this;
ev.bMuted = m_bOutputMuted;
m_pEventManager->BroadcastEvent( ev );
}
VA_RETHROW;
}
......@@ -4218,7 +4209,7 @@ void CVACoreImpl::SetActiveSoundReceiver( const int iListenerID )
ev.iObjectID = iListenerID;
m_pEventManager->EnqueueEvent( ev );
VA_VERBOSE( "Core", "Set sound receiver " << iListenerID << " the active listener" );
VA_VERBOSE( "Core", "Set sound receiver " << iListenerID << " the active receiver" );
}
bSync = false;
......@@ -4983,6 +4974,8 @@ void CVACoreImpl::SendRenderingModuleOutputDetectorsUpdateEvents()
if( oRenderer.pOutputDetector )
{
ev.vfOutputRMSs.resize( oRenderer.pOutputDetector->GetNumberOfChannels() );
oRenderer.pOutputDetector->GetRMSs( ev.vfOutputRMSs, true );
ev.vfOutputPeaks.resize( oRenderer.pOutputDetector->GetNumberOfChannels() );
oRenderer.pOutputDetector->GetPeaks( ev.vfOutputPeaks, true );
}
......@@ -5005,12 +4998,16 @@ void CVACoreImpl::SendReproductionModuleOIDetectorsUpdateEvents()
if( oReproduction.pInputDetector )
{
ev.vfInputRMSs.resize( oReproduction.pInputDetector->GetNumberOfChannels() );
oReproduction.pInputDetector->GetRMSs( ev.vfInputRMSs, true );
ev.vfInputPeaks.resize( oReproduction.pInputDetector->GetNumberOfChannels() );
oReproduction.pInputDetector->GetPeaks( ev.vfInputPeaks, true );
}
if( oReproduction.pOutputDetector )
{
ev.vfOutputRMSs.resize( oReproduction.pOutputDetector->GetNumberOfChannels() );
oReproduction.pOutputDetector->GetRMSs( ev.vfOutputRMSs, true );
ev.vfOutputPeaks.resize( oReproduction.pOutputDetector->GetNumberOfChannels() );
oReproduction.pOutputDetector->GetPeaks( ev.vfOutputPeaks, true );
}
......
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