Commit 14f4d76e authored by Daniel Filbert's avatar Daniel Filbert
Browse files

Merge branch 'develop' of https://git.rwth-aachen.de/ita/VACore into develop

parents 181b5339 53fccd17
......@@ -173,7 +173,7 @@ if( NOT DEFINED ITA_VACORE_WITH_RENDERER_PROTOTYPE_GENERIC_PATH )
endif( )
if( NOT DEFINED ITA_VACORE_WITH_RENDERER_VBAP_FREE_FIELD )
set( ITA_VACORE_WITH_RENDERER_VBAP_FREE_FIELD OFF CACHE BOOL "Build VACore with rendering module: vector-base amplitude panning free-field" )
set( ITA_VACORE_WITH_RENDERER_VBAP_FREE_FIELD ON CACHE BOOL "Build VACore with rendering module: vector-base amplitude panning free-field" )
endif( )
......
......@@ -55,6 +55,7 @@
// Vista includes
#include <VistaInterProcComm/Concurrency/VistaThreadEvent.h>
#include <VistaBase/VistaQuaternion.h>
// STL includes
#include <algorithm>
......@@ -736,9 +737,8 @@ void CVABinauralFreeFieldAudioRenderer::ProcessStream( const ITAStreamInfo* pStr
pPath->UpdateDir( bDIREnabled );
// HATO
const VAQuat qHATO = pListenerState->GetMotionState()->GetHeadAboveTorsoOrientation();
const double dHATODenominator = sqrt( 1 - qHATO.w * qHATO.w );
const double dHATODeg = rad2grad( dHATODenominator == 0.0f ? 0.0f : qHATO.y / dHATODenominator );
const VistaQuaternion qHATO( pListenerState->GetMotionState()->GetHeadAboveTorsoOrientation().comp );
const double dHATODeg = rad2grad( qHATO.GetAngles().b );
pPath->UpdateHRIR( pListenerState->GetAnthropometricData(), dHATODeg );
// Sound source gain / direct sound audibility via AuraMode flags
......
......@@ -139,7 +139,7 @@ void CVAAmbisonicsReproduction::SetInputDatasource( ITADatasource* p )
// 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 ];
double dGain = matYinv( j, k )*vdRemaxWeights[ iCurrentOrder ];
m_pDecoderMatrixPatchBay->ConnectChannels( 0, int( j ), 0, int( k ), dGain );
}
}
......
......@@ -346,7 +346,10 @@ void CVAContainerState::SetObject( const int iID, CVASceneStateBase* pObject )
// Referenz auf altem Objekt entfernen und bei neuem Objekt hinzufgen
pObject->AddReference();
if( i->second )
{
assert( i->second->GetNumReferences() > 0 );
i->second->RemoveReference();
}
i->second = pObject;
return;
......
......@@ -20,14 +20,10 @@
#include "VAMotionState.h"
#include <cassert>
#include <cmath>
void CVAReceiverState::Initialize( double dModificationTime )
{
// Nullposition
data.pMotionState = GetManager()->RequestMotionState();
data.pMotionState->Initialize( dModificationTime );
data.pMotionState = nullptr; // undefined position
data.iAuraMode = IVAInterface::VA_AURAMODE_ALL;
data.iDirectivityID = -1;
data.pDirectivity = nullptr;
......@@ -42,7 +38,11 @@ void CVAReceiverState::Copy( const CVAReceiverState* pSrc, double dModificationT
assert( pSrc->IsFixed() );
// Abhngige Objekte des Vorlagenobjektes autonom referenzieren
pSrc->data.pMotionState->AddReference();
if( pSrc->data.pMotionState )
{
assert( pSrc->data.pMotionState->GetNumReferences() > 0 );
pSrc->data.pMotionState->AddReference();
}
// Daten kopieren
data = pSrc->data;
......@@ -50,23 +50,32 @@ void CVAReceiverState::Copy( const CVAReceiverState* pSrc, double dModificationT
SetModificationTime( dModificationTime );
}
void CVAReceiverState::Fix() {
void CVAReceiverState::Fix()
{
// Alle enthaltenen Objekte fixieren
if( data.pMotionState ) data.pMotionState->Fix();
if( data.pMotionState )
data.pMotionState->Fix();
// Selbst fixieren
CVASceneStateBase::Fix();
}
void CVAReceiverState::PreRelease() {
void CVAReceiverState::PreRelease()
{
// Alle Referenzen auf abhngige Objekte entfernen
if( data.pMotionState ) data.pMotionState->RemoveReference();
if( data.pMotionState )
{
assert( data.pMotionState->GetNumReferences() > 0 );
data.pMotionState->RemoveReference();
data.pMotionState = NULL;
}
// Funktion der Oberklasse aufrufen
CVASceneStateBase::PreRelease();
}
const CVAMotionState* CVAReceiverState::GetMotionState() const {
const CVAMotionState* CVAReceiverState::GetMotionState() const
{
return data.pMotionState;
}
......@@ -88,19 +97,28 @@ CVAMotionState* CVAReceiverState::AlterMotionState()
// Falls der Zustand finalisiert => Zustand aus der Basiskonfig => Autonomen Zustand erzeugen
// Falls der Zustand nicht finalisiert => Bereits erzeugter autonomen Zustand => Diesen zurckgeben
if( data.pMotionState->IsFixed() )
if( !data.pMotionState )
{
// Autonomen Zustand ableiten
CVAMotionState* pNewState = GetManager()->RequestMotionState();
// nderungszeit des bergeordneten Szenezustands bernehmen
double dCreationTime = GetModificationTime();
pNewState->Copy( data.pMotionState, dCreationTime );
data.pMotionState->RemoveReference();
data.pMotionState = pNewState;
data.pMotionState = GetManager()->RequestMotionState();
data.pMotionState->Initialize( GetModificationTime() );
}
else
{
if( data.pMotionState->IsFixed() )
{
// Autonomen Zustand ableiten
CVAMotionState* pNewState = GetManager()->RequestMotionState();
// nderungszeit des bergeordneten Szenezustands bernehmen
double dCreationTime = GetModificationTime();
pNewState->Copy( data.pMotionState, dCreationTime );
data.pMotionState->RemoveReference();
data.pMotionState = pNewState;
}
}
VA_TRACE( "SoundReceiverState", "Requested new motion state" );
return data.pMotionState;
}
......@@ -201,5 +219,4 @@ double CVAReceiverState::CVAAnthropometricParameter::GetHeadDepthParameterFromLU
b = 0;
return ( m_vvdHeadDepthParameterLUT[ a ][ b ] );
}
......@@ -218,6 +218,7 @@ CVASoundSourceState* CVASceneManager::RequestSoundSourceState()
{
CVASoundSourceState* pState = dynamic_cast< CVASoundSourceState* >( m_pPoolSourceStates->RequestObject() );
pState->SetManager( this );
assert( pState->GetNumReferences() == 1 );
return pState;
}
......
......@@ -142,7 +142,8 @@ CVASoundSourceState* CVASceneState::AlterSoundSourceState( const int iSourceID )
assert( pList );
// Zustand der Quelle fr Modifkation ableiten
if( pCurState->IsFixed() ) {
if( pCurState->IsFixed() )
{
// Autonomen Zustand ableiten
CVASoundSourceState* pNewState = GetManager()->RequestSoundSourceState();
......
......@@ -15,13 +15,10 @@
#include <VA.h>
#include "../Directivities/VADirectivity.h"
#include "../VALog.h"
#include "VASceneManager.h"
#include "VAMotionState.h"
#include <ITANumericUtils.h>
#include <cassert>
void CVASoundSourceState::Initialize( double dModificationTime )
......@@ -29,8 +26,8 @@ void CVASoundSourceState::Initialize( double dModificationTime )
data.pMotionState = nullptr; // undefined position
data.dSoundPower = g_dSoundPower_94dB_SPL_1m;
data.iAuraMode = IVAInterface::VA_AURAMODE_ALL;
data.iDirID = -1;
data.pDirData = nullptr;
data.iDirectivityID = -1;
data.pDirectivity = nullptr;
SetModificationTime( dModificationTime );
}
......@@ -43,7 +40,10 @@ void CVASoundSourceState::Copy( const CVASoundSourceState* pSrc, double dModific
// Abhngige Objekte des Vorlagenobjektes autonom referenzieren
if( pSrc->data.pMotionState )
{
assert( pSrc->data.pMotionState->GetNumReferences() > 0 );
pSrc->data.pMotionState->AddReference();
}
// Daten kopieren
data = pSrc->data;
......@@ -65,7 +65,11 @@ void CVASoundSourceState::PreRelease()
{
// Alle Referenzen auf abhngige Objekte entfernen
if( data.pMotionState )
{
assert( data.pMotionState->GetNumReferences() > 0 );
data.pMotionState->RemoveReference();
data.pMotionState = NULL;
}
// Funktion der Oberklasse aufrufen
CVASceneStateBase::PreRelease();
......@@ -128,25 +132,25 @@ double CVASoundSourceState::GetSoundPower() const
int CVASoundSourceState::GetDirectivityID() const
{
return data.iDirID;
return data.iDirectivityID;
}
const IVADirectivity* CVASoundSourceState::GetDirectivityData() const
{
return data.pDirData;
return data.pDirectivity;
}
void CVASoundSourceState::SetDirectivityID( int iDirectivityID )
{
assert( !IsFixed() );
data.iDirID = iDirectivityID;
data.iDirectivityID = iDirectivityID;
VA_VERBOSE( "SoundSourceState", "Directivity identifier changed" );
}
void CVASoundSourceState::SetDirectivityData( const IVADirectivity* pDirData )
{
assert( !IsFixed() );
data.pDirData = pDirData;
data.pDirectivity = pDirData;
VA_VERBOSE( "SoundSourceState", "Directivity dataset changed" );
}
......
......@@ -86,8 +86,8 @@ private:
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
int iDirectivityID; //!< Directivity identifier
const IVADirectivity* pDirectivity; //!< Pointer to directivity data set
CVAStruct oParams; //!< Sound source parameters for special implementations
} data;
......
......@@ -2034,27 +2034,22 @@ int CVACoreImpl::DeleteSoundSource( const int iSoundSourceID )
VA_TRY
{
m_pNewSceneState->RemoveSoundSource( iSoundSourceID );
int iResult = 0;
if( iResult == 0 )
{
// Ereignis generieren, wenn erfolgreich
CVAEvent ev;
ev.iEventType = CVAEvent::SOUND_SOURCE_DELETED;
ev.pSender = this;
ev.iObjectID = iSoundSourceID;
m_pEventManager->EnqueueEvent( ev );
}
// Ereignis generieren, wenn erfolgreich
CVAEvent ev;
ev.iEventType = CVAEvent::SOUND_SOURCE_DELETED;
ev.pSender = this;
ev.iObjectID = iSoundSourceID;
m_pEventManager->EnqueueEvent( ev );
if( !bSync )
UnlockUpdate();
VA_INFO( "Core", "Deleted sound source " << iSoundSourceID );
return iResult;
return 0;
}
VA_FINALLY
VA_FINALLY
{
if( !bSync )
UnlockUpdate();
......@@ -3174,7 +3169,7 @@ void CVACoreImpl::SetSoundReceiverDirectivity( const int iID, const int iDirecti
if( !bSync )
UnlockUpdate();
VA_INFO( "Core", "Linked sound receiver " + std::to_string( long( iID ) ) + " with HRIR dataset " + std::to_string( long( iDirectivityID ) ) );
VA_INFO( "Core", "Linked sound receiver " + std::to_string( long( iID ) ) + " with receiver directivity dataset " + std::to_string( long( iDirectivityID ) ) );
}
VA_RETHROW;
......
......@@ -202,12 +202,12 @@ int CVADirectivityDAFFHATOHRIR::GetHATOChannelIndexLeft( const double dHATODeg )
else
iResult = ( int ) ( ( m_dHATOEndDeg + dNearestHATODeg ) / dHATORes ) + 1;
return 2 * iResult; // odd! index
return 2 * iResult; // even! channel index (starting at 0)
}
int CVADirectivityDAFFHATOHRIR::GetHATOChannelIndexRight( const double dHATODeg ) const
{
return GetHATOChannelIndexLeft( dHATODeg ) + 1;
return GetHATOChannelIndexLeft(dHATODeg) + 1; // odd! channel index (indexing starts at 0, first right channels is 1)
}
void CVADirectivityDAFFHATOHRIR::GetHRIRByIndexAndHATO( ITASampleFrame* psfDest, const int iIndex, const double dHATODeg ) const
......
......@@ -7,7 +7,7 @@
using namespace std;
IVAInterface* core = NULL;
IVAInterface* va = NULL;
class EventBasedGenericRenderingController : public IVAEventHandler
{
......@@ -33,7 +33,7 @@ public:
oArgs[ "SourceID" ] = 1;
try
{
oReturn = core->CallModule( "GenericPath:MyGenericRenderer", oArgs );
oReturn = va->CallModule( "GenericPath:MyGenericRenderer", oArgs );
}
catch( CVAException& e )
{
......@@ -57,10 +57,76 @@ public:
};
CoreEventDumper dumper;
void bugfix_scene_pool_clearance_issue();
void TestModuleInterface();
void AudioRenderers();
void AudioReproductions();
void CreateHRIRs();
void CreateAudioSignals();
void CreateScene();
void ConnectSignals();
void TestSignalAndSourceConnections();
int main( int, char** )
{
try
{
va = VACore::CreateCoreInstance( "../conf/VACore.ini" );
//va = VACore::CreateCoreInstance( GetCoreConfig() );
// Attach (register) event handler
//va->AttachEventHandler( &dumper );
va->AttachEventHandler( &rendering_controller );
CVAVersionInfo ver;
va->GetVersionInfo( &ver );
cout << ver.ToString() << endl;
va->Initialize();
va->AddSearchPath( "../data" );
/*
TestModuleInterface();
AudioRenderers();
AudioReproductions();
CreateHRIRs();
CreateAudioSignals();
CreateScene();
//ConnectSignals();
TestSignalAndSourceConnections();
*/
bugfix_scene_pool_clearance_issue();
va->SetGlobalAuralizationMode( IVAInterface::VA_AURAMODE_ALL );
VistaTimeUtils::Sleep( 10000 );
va->Finalize();
}
catch( CVAException& e )
{
cerr << "Error: " << e << endl;
int iErrorCode = e.GetErrorCode();
delete va;
return iErrorCode;
}
delete va;
return 0;
}
void AudioRenderers()
{
std::vector< CVAAudioRendererInfo > voRenderers;
core->GetRenderingModules( voRenderers );
va->GetRenderingModules( voRenderers );
if( voRenderers.size() )
cout << "Found " << voRenderers.size() << " audio renderer" << endl;
......@@ -76,7 +142,7 @@ void AudioRenderers()
void AudioReproductions()
{
std::vector< CVAAudioReproductionInfo > voReproductions;
core->GetReproductionModules( voReproductions );
va->GetReproductionModules( voReproductions );
if( voReproductions.size() )
cout << "Found " << voReproductions.size() << " audio renderer" << endl;
......@@ -92,7 +158,7 @@ void AudioReproductions()
void TestModuleInterface()
{
std::vector< CVAModuleInfo > viModuleInfos;
core->GetModules( viModuleInfos );
va->GetModules( viModuleInfos );
if( viModuleInfos.size() )
cout << "Found " << viModuleInfos.size() << " modules" << endl;
......@@ -105,7 +171,6 @@ void TestModuleInterface()
CVAStruct GetCoreConfig()
{
CVAStruct oConfig;
CVAStruct oSectionDebug;
......@@ -150,109 +215,92 @@ void CreateAudioSignals()
string sNetStreamID;
try
{
sNetStreamID = core->CreateSignalSourceNetworkStream( "localhost", 12480, "CoreTestNetStream" );
sNetStreamID = va->CreateSignalSourceNetworkStream( "localhost", 12480, "CoreTestNetStream" );
}
catch( CVAException& e )
{
cerr << "Caught exception during stream signal source connection:" << e << endl;
}
string sFileID = core->CreateSignalSourceBufferFromFile( "Audiofiles/Bauer.wav" );
core->SetSignalSourceBufferPlaybackAction( sFileID, IVAInterface::VA_PLAYBACK_ACTION_PLAY );
core->SetSignalSourceBufferLooping( sFileID, true );
string sFileID = va->CreateSignalSourceBufferFromFile( "$(DemoSound)" );
va->SetSignalSourceBufferPlaybackAction( sFileID, IVAInterface::VA_PLAYBACK_ACTION_PLAY );
va->SetSignalSourceBufferLooping( sFileID, true );
}
void CreateHRIRs()
{
core->CreateDirectivityFromFile( "HRIR/ITA-Kunstkopf_HRIR_AP11_Pressure_Equalized_3x3_256.v17.ir.daff" );
va->CreateDirectivityFromFile( "$(DefaultHRIR)" );
}
void CreateScene()
{
int iListenerID = core->CreateSoundReceiver( "MyListener" );
core->SetSoundReceiverAuralizationMode( iListenerID, IVAInterface::VA_AURAMODE_ALL );
core->SetSoundReceiverOrientationVU( iListenerID, VAVec3( 0.7172f, 0.0f, -0.7172f ), VAVec3( 0, 1, 0 ) );
core->SetSoundReceiverDirectivity( iListenerID, 1 );
int iListenerID = va->CreateSoundReceiver( "MyListener" );
va->SetSoundReceiverAuralizationMode( iListenerID, IVAInterface::VA_AURAMODE_ALL );
va->SetSoundReceiverOrientationVU( iListenerID, VAVec3( 0.7172f, 0.0f, -0.7172f ), VAVec3( 0, 1, 0 ) );
va->SetSoundReceiverDirectivity( iListenerID, 1 );
core->SetActiveSoundReceiver( iListenerID );
va->SetActiveSoundReceiver( iListenerID );
int iSoundSource = core->CreateSoundSource( "MySoundSource" );
core->SetSoundSourcePosition( iSoundSource, VAVec3( -2.0f, 0, 0 ) );
int iSoundSource = va->CreateSoundSource( "MySoundSource" );
va->SetSoundSourcePosition( iSoundSource, VAVec3( -2.0f, 0, 0 ) );
}
void ConnectSignals()
{
//core->SetSoundSourceSignalSource( 1, "audiofile1" );
core->SetSoundSourceSignalSource( 1, "netstream1" );
}
int main()
void TestSignalAndSourceConnections()
{
int iSourceID = va->CreateSoundSource();
string sSignalID = va->CreateSignalSourceBufferFromFile( "$(DemoSound)" );
va->SetSoundSourceSignalSource( iSourceID, sSignalID );
va->SetSoundSourceSignalSource( iSourceID, "" );
va->SetSoundSourceSignalSource( iSourceID, sSignalID );
va->SetSoundSourceSignalSource( iSourceID, sSignalID );
va->SetSoundSourceSignalSource( iSourceID, sSignalID );
va->SetSoundSourceSignalSource( iSourceID, sSignalID );
va->SetSoundSourceSignalSource( iSourceID, "" );
va->DeleteSignalSource( sSignalID );
sSignalID = va->CreateSignalSourceBufferFromFile( "$(DemoSound)" );
va->DeleteSignalSource( sSignalID );
sSignalID = va->CreateSignalSourceBufferFromFile( "$(DemoSound)" );
string sSignalID2 = va->CreateSignalSourceBufferFromFile( "$(DemoSound)" );
va->SetSoundSourceSignalSource( iSourceID, sSignalID );
va->SetSoundSourceSignalSource( iSourceID, sSignalID2 );
try
{
core = VACore::CreateCoreInstance( "../conf/VACore.ini" );
//core = VACore::CreateCoreInstance( GetCoreConfig() );
// Attach (register) event handler
core->AttachEventHandler( &dumper );
core->AttachEventHandler( &rendering_controller );
CVAVersionInfo ver;
core->GetVersionInfo( &ver );
cout << ver.ToString() << endl;
core->Initialize();
core->AddSearchPath( "../data" );
TestModuleInterface();
AudioRenderers();
AudioReproductions();
CreateHRIRs();
CreateAudioSignals();
CreateScene();
ConnectSignals();
core->SetGlobalAuralizationMode( IVAInterface::VA_AURAMODE_ALL );
VistaTimeUtils::Sleep( 10000 );
core->Finalize();
va->DeleteSignalSource( sSignalID2 );
}
catch( CVAException& e )
catch( CVAException e )
{
cerr << "Error: " << e << endl;
int iErrorCode = e.GetErrorCode();
delete core;
return iErrorCode;
; // good
}
va->DeleteSoundSource( iSourceID );
va->DeleteSignalSource( sSignalID2 );
}
delete core;
return 0;
void ConnectSignals()
{
//va->SetSoundSourceSignalSource( 1, "audiofile1" );
va->SetSoundSourceSignalSource( 1, "netstream1" );
}
void testLoadDirectivity()
{
cout << "Loading a directivity" << endl;
cout << "Load 1: ID = " << core->CreateDirectivityFromFile( "D:/Temp/Directivity/trompete1.ddb", "Trompete1" ) << endl;
cout << "Load 1: ID = " << va->CreateDirectivityFromFile( "D:/Temp/Directivity/trompete1.ddb", "Trompete1" ) << endl;
//
//// Test: Gleiches Sound nochmal laden...
//cout << "Load 2: ID = " << (id = core->LoadSound("ding.wav", "Max")) << endl;
//cout << "Load 2: ID = " << (id = va->LoadSound("ding.wav", "Max")) << endl;
//cout << "Load 3: ID = " << core->LoadSound("D:/ding.wav", "Max") << endl;
//cout << "Load 3: ID = " << va->LoadSound("D:/ding.wav", "Max") << endl;
//core->PrintDirectivityInfos();
//va->PrintDirectivityInfos();
//cout << "Freeing Sound " << id << endl;
//core->FreeSound(id);
//va->FreeSound(id);
//core->PrintDirectivityInfos();
//va->PrintDirectivityInfos();
}
void testLoadSound()
......@@ -261,25 +309,25 @@ void testLoadSound()
int id1, id2, id3;
const std::string sSequencerID = core->CreateSignalSourceSequencer( "MySequencer" );
const std::string sSequencerID = va->CreateSignalSourceSequencer( "MySequencer" );
CVAStruct oSequencerSample;
oSequencerSample[ "name" ] = "Max";
oSequencerSample[ "filepath" ] = "ding.wav";
cout << "Load 1: ID = " << ( id1 = core->AddSignalSourceSequencerSample( sSequencerID, oSequencerSample ) ) << endl;
cout << "Load 1: ID = " << ( id1 = va->AddSignalSourceSequencerSample( sSequencerID, oSequencerSample ) ) << endl;
// Test: Gleiches Sound nochmal laden...
cout << "Load 2: ID = " << ( id2 = core->AddSignalSourceSequencerSample( sSequencerID,