Commit 423a7ff5 authored by Jonas Stienen's avatar Jonas Stienen
Browse files

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

parents d5fdd926 5fbae10e
......@@ -2,47 +2,55 @@
#include <ITASampleBuffer.h>
CVADeviceInputSignalSource::CVADeviceInputSignalSource(ITASampleBuffer* psbInputData, const std::string& sDesc)
: m_pAssociatedCore(nullptr),
m_psbInputData(psbInputData),
m_sDesc(sDesc)
{ }
CVADeviceInputSignalSource::CVADeviceInputSignalSource( ITASampleBuffer* psbInputData, const std::string& sDesc )
: m_pAssociatedCore( nullptr ),
m_psbInputData( psbInputData ),
m_sDesc( sDesc )
{
}
CVADeviceInputSignalSource::~CVADeviceInputSignalSource()
{
CVADeviceInputSignalSource::~CVADeviceInputSignalSource() {
}
int CVADeviceInputSignalSource::GetType() const {
int CVADeviceInputSignalSource::GetType() const
{
return IVAAudioSignalSource::VA_SS_DEVICE_INPUT;
}
std::string CVADeviceInputSignalSource::GetTypeString() const {
std::string CVADeviceInputSignalSource::GetTypeString() const
{
return "audioinput";
}
std::string CVADeviceInputSignalSource::GetDesc() const {
std::string CVADeviceInputSignalSource::GetDesc() const
{
return m_sDesc;
}
std::string CVADeviceInputSignalSource::GetStateString() const {
// TODO:
std::string CVADeviceInputSignalSource::GetStateString() const
{
return "";
}
IVACore* CVADeviceInputSignalSource::GetAssociatedCore() const {
IVACore* CVADeviceInputSignalSource::GetAssociatedCore() const
{
return m_pAssociatedCore;
}
void CVADeviceInputSignalSource::HandleRegistration(IVACore* pParentCore) {
void CVADeviceInputSignalSource::HandleRegistration( IVACore* pParentCore )
{
m_pAssociatedCore = pParentCore;
}
void CVADeviceInputSignalSource::HandleUnregistration(IVACore* pParentCore) {
void CVADeviceInputSignalSource::HandleUnregistration( IVACore* )
{
m_pAssociatedCore = nullptr;
}
const float* CVADeviceInputSignalSource::GetStreamBlock(const CVAAudiostreamState* pStreamInfo) {
// Inhalt des externen Puffers zurckgeben
// (Momentan noch keine eigene Bearbeitung)
const float* CVADeviceInputSignalSource::GetStreamBlock( const CVAAudiostreamState* )
{
// Return samples from external buffer, no unternal processing required
return m_psbInputData->data();
}
\ No newline at end of file
}
......@@ -11,6 +11,8 @@ CVANetstreamSignalSource::CVANetstreamSignalSource( double dDestinationSamplerat
: m_pAssociatedCore( NULL )
{
m_pSourceStream = new CITANetAudioStream( 1, dDestinationSamplerate, iBlocklength, 12 * iBlocklength );
m_pSourceStream->SetAllowedLatencySamples( m_pSourceStream->GetMaximumLatencySamples() );
if( !m_pSourceStream->Connect( sBindAddress, iRecvPort ) )
VA_EXCEPT2( INVALID_PARAMETER, "Could not connect to network audio streaming server" );
}
......@@ -23,7 +25,7 @@ CVANetstreamSignalSource::~CVANetstreamSignalSource()
std::string CVANetstreamSignalSource::GetTypeString() const
{
return "Network stream";
return "netstream";
}
std::string CVANetstreamSignalSource::GetTypeMnemonic() const
......@@ -34,7 +36,7 @@ std::string CVANetstreamSignalSource::GetTypeMnemonic() const
std::string CVANetstreamSignalSource::GetDesc() const
{
std::stringstream ss;
ss << "Plays the network audio stream";
ss << "Plays a network audio stream";
return ss.str();
}
......
......@@ -387,7 +387,8 @@ CVACoreImpl::~CVACoreImpl()
VA_VERBOSE( "Core", m_pmCoreThreadLoopTotalDuration.ToString() );
}
void CVACoreImpl::SetDebugStream(std::ostream* posDebug) {
void CVACoreImpl::SetDebugStream( std::ostream* posDebug )
{
VALog_setOutputStream(posDebug);
VALog_setErrorStream(posDebug);
}
......@@ -1169,7 +1170,7 @@ std::string CVACoreImpl::CreateNetworkStreamSignalSource( const std::string& sIn
ev.iEventType = CVACoreEvent::VA_COREEVENT_SIGNALSOURCE_CREATED;
ev.pSender = this;
ev.sObjectID = sID;
m_pCoreEventMan->BroadcastEvent(ev);
m_pCoreEventMan->BroadcastEvent( ev );
VA_INFO( "Core", "Created network stream signal source (ID=" << sID << ", Name='" << sName << "', Interface=" << sInterface << ":" << iPort << ")" );
......
......@@ -12,7 +12,7 @@ using namespace std;
IVACore* core = NULL;
class EventBasedGenericRenderingController: public IVACoreEventHandler
class EventBasedGenericRenderingController : public IVACoreEventHandler
{
public:
void HandleVACoreEvent( const CVACoreEvent* pEvent )
......@@ -29,11 +29,11 @@ public:
sNewFilePath = "$(VADataDir)/rooms/shoebox_room_brir_azi020_ele000.wav";
CVAStruct oArgs, oReturn;
oArgs["COMMAND"] = "UPDATE";
oArgs["TYPE"] = "FILE"; // or DATA that sends ITASampleFrame from this controller context
oArgs["FilePath"] = sNewFilePath;
oArgs["ListenerID"] = pEvent->iObjectID;
oArgs["SourceID"] = 1;
oArgs[ "COMMAND" ] = "UPDATE";
oArgs[ "TYPE" ] = "FILE"; // or DATA that sends ITASampleFrame from this controller context
oArgs[ "FilePath" ] = sNewFilePath;
oArgs[ "ListenerID" ] = pEvent->iObjectID;
oArgs[ "SourceID" ] = 1;
try
{
core->CallModule( "GenericPath:MyGenericRenderer", oArgs, oReturn );
......@@ -69,7 +69,7 @@ void AudioRenderers()
for( size_t i = 0; i < voRenderers.size(); i++ )
{
cout << " + Renderer #" << i+1 << ": "
cout << " + Renderer #" << i + 1 << ": "
<< voRenderers[ i ].sID << " [" << voRenderers[ i ].sClass << "] "
<< ( voRenderers[ i ].bEnabled ? "[enabled]" : "disabled" )
<< " ( " << voRenderers[ i ].sDescription << " )" << endl;
......@@ -85,7 +85,7 @@ void AudioReproductions()
for( size_t i = 0; i < voReproductions.size(); i++ )
{
cout << " + Renderer #" << i+1 << ": "
cout << " + Renderer #" << i + 1 << ": "
<< voReproductions[ i ].sID << " [" << voReproductions[ i ].sClass << "] "
<< ( voReproductions[ i ].bEnabled ? "[enabled]" : "disabled" )
<< " ( " << voReproductions[ i ].sDescription << " )" << endl;
......@@ -102,34 +102,114 @@ void TestModuleInterface()
for( size_t i = 0; i < viModuleInfos.size(); i++ )
{
cout << " + Module #" << i+1 << ": " << viModuleInfos[ i ].sName << " ( " << viModuleInfos[ i ].sDesc << " )" << endl;
cout << " + Module #" << i + 1 << ": " << viModuleInfos[ i ].sName << " ( " << viModuleInfos[ i ].sDesc << " )" << endl;
}
}
CVAStruct GetCoreConfig()
{
CVAStruct oConfig;
CVAStruct oSectionDebug;
oSectionDebug[ "loglevel" ] = 5;
oConfig[ "debug" ] = oSectionDebug;
CVAStruct oSectionDriver;
oSectionDriver[ "driver" ] = "Portaudio";
oConfig[ "audio driver" ] = oSectionDriver;
CVAStruct oDevice1;
oDevice1[ "type" ] = "HP";
oDevice1[ "channels" ] = "1,2";
oConfig[ "OutputDevice:MyHP" ] = oDevice1;
CVAStruct oOutput1;
oOutput1[ "devices" ] = "MyHP";
oConfig[ "Output:MyDesktopHP" ] = oOutput1;
CVAStruct oReproduction1;
oReproduction1[ "class" ] = "Talkthrough";
oReproduction1[ "outputs" ] = "MyDesktopHP";
oConfig[ "Reproduction:Talkthrough" ] = oReproduction1;
CVAStruct oRenderer1;
oRenderer1[ "class" ] = "BinauralFreeField";
oRenderer1[ "outputs" ] = "MyTalkthroughHeadphones";
oConfig[ "Renderer:BFF_CoreTest" ] = oRenderer1;
CVAStruct oRenderer2;
oRenderer2[ "class" ] = "PrototypeGenericPath";
oRenderer2[ "numchannels" ] = 2;
oRenderer2[ "outputs" ] = "MyTalkthroughHeadphones";
oConfig[ "Renderer:PTGP_CoreTest" ] = oRenderer2;
return oConfig;
}
void CreateAudioSignals()
{
string sNetStreamID = core->CreateNetworkStreamSignalSource( "localhost", 12480, "CoreTestNetStream" );
string sFileID = core->CreateAudiofileSignalSource( "Audiofiles/Bauer.wav" );
core->SetAudiofileSignalSourcePlaybackAction( sFileID, IVACore::VA_PLAYBACK_ACTION_PLAY );
core->SetAudiofileSignalSourceIsLooping( sFileID, true );
}
void CreateHRIRs()
{
int iHRIR = core->LoadHRIRDataset( "HRIR/ITA-Kunstkopf_HRIR_AP11_Pressure_Equalized_3x3_256.v17.ir.daff" );
}
void CreateScene()
{
int iListenerID = core->CreateListener( "MyListener", IVACore::VA_AURAMODE_ALL );
core->SetListenerOrientationYPR( iListenerID, 20, 0, 0 ); // 20 degree rotation of head in horizontal plane, triggers a core event
core->SetListenerHRIRDataset( iListenerID, 1 );
core->SetActiveListener( iListenerID );
int iSoundSource = core->CreateSoundSource( "MySoundSource", IVACore::VA_AURAMODE_ALL );
core->SetSoundSourcePosition( iSoundSource, -20, 0, 0 );
}
void ConnectSignals()
{
//core->SetSoundSourceSignalSource( 1, "audiofile1" );
core->SetSoundSourceSignalSource( 1, "netstream1" );
}
int main()
{
try
{
core = VACore::CreateCoreInstance( "../conf/VACore.ini" );
//core = VACore::CreateCoreInstance( GetCoreConfig() );
// Attach (register) event handler
core->AttachCoreEventHandler( &dumper );
core->AttachCoreEventHandler( &rendering_controller );
CVACoreVersionInfo ver;
core->GetVersionInfo(&ver);
core->GetVersionInfo( &ver );
cout << ver.ToString() << endl;
core->Initialize();
core->AddSearchPath( "../data" );
TestModuleInterface();
AudioRenderers();
AudioReproductions();
CreateHRIRs();
CreateAudioSignals();
CreateScene();
ConnectSignals();
int iListenerID = core->CreateListener( "MyListener" );
core->SetListenerOrientationYPR( iListenerID, 20, 0, 0 ); // 20 degree rotation of head in horizontal plane, triggers a core event
core->SetGlobalAuralizationMode( IVACore::VA_AURAMODE_ALL );
Sleep(10000);
Sleep( 10000 );
core->Finalize();
......@@ -143,7 +223,7 @@ int main()
return iErrorCode;
}
delete core;
delete core;
return 0;
}
......@@ -152,7 +232,7 @@ void testLoadDirectivity()
{
cout << "Loading a directivity" << endl;
cout << "Load 1: ID = " << core->LoadDirectivity("D:/Temp/Directivity/trompete1.ddb", "Trompete1") << endl;
cout << "Load 1: ID = " << core->LoadDirectivity( "D:/Temp/Directivity/trompete1.ddb", "Trompete1" ) << endl;
//
//// Test: Gleiches Sound nochmal laden...
//cout << "Load 2: ID = " << (id = core->LoadSound("ding.wav", "Max")) << endl;
......@@ -173,16 +253,16 @@ void testLoadSound()
int id;
cout << "Load 1: ID = " << core->LoadSound("ding.wav", "Max") << endl;
cout << "Load 1: ID = " << core->LoadSound( "ding.wav", "Max" ) << endl;
// Test: Gleiches Sound nochmal laden...
cout << "Load 2: ID = " << (id = core->LoadSound("ding.wav", "Max")) << endl;
cout << "Load 2: ID = " << ( id = core->LoadSound( "ding.wav", "Max" ) ) << endl;
cout << "Load 3: ID = " << core->LoadSound("D:/ding.wav", "Max") << endl;
cout << "Load 3: ID = " << core->LoadSound( "D:/ding.wav", "Max" ) << endl;
//core->PrintSoundInfos();
cout << "Freeing Sound " << id << endl;
core->FreeSound(id);
core->FreeSound( id );
//core->PrintSoundInfos();
}
......@@ -193,47 +273,47 @@ void testScene()
int iSource1, iSource2, iSource3;
iSource1 = core->CreateSoundSource("Source1");
iSource1 = core->CreateSoundSource( "Source1" );
//core->SetSoundSourceName(iSource1, "Max der Erste");
cout << "Create sound source 1: ID = " << iSource1 << endl;
core->LockScene();
iSource2 = core->CreateSoundSource("Source2");
iSource2 = core->CreateSoundSource( "Source2" );
//core->SetSoundSourceName(iSource2, "Klaus die Katze");
cout << "Create sound source 1: ID = " << iSource2 << endl;
iSource3 = core->CreateSoundSource("Source3");
iSource3 = core->CreateSoundSource( "Source3" );
cout << "Create sound source 1: ID = " << iSource3 << endl;
// Positions & orientations
core->SetSoundSourceOrientationVU(iSource1, 1, 2, 3, 4, 5, 6);
core->SetSoundSourcePosition(iSource2, 47, 11, 0);
core->SetSoundSourceOrientationVU( iSource1, 1, 2, 3, 4, 5, 6 );
core->SetSoundSourcePosition( iSource2, 47, 11, 0 );
//core->SetSoundSourceOrientationYPR(iSource3, 47, 11, 0);
//cout << "Create listener 1: ID = " << core->CreateListener("Listener1") << endl;
core->UnlockScene();
double px, py, pz, vx, vy, vz, ux, uy, uz;
core->GetSoundSourcePositionOrientationVU(iSource1, px, py, pz, vx, vy, vz, ux, uy, uz);
cout << "Sound source 1 pos & ori: p=" << px << ", " << py << ", " << pz << ", v=" << vx<< ", " << vy<< ", " << vz<< ", u=" << ux<< ", " << uy<< ", " << uz << endl;
core->GetSoundSourcePositionOrientationVU( iSource1, px, py, pz, vx, vy, vz, ux, uy, uz );
cout << "Sound source 1 pos & ori: p=" << px << ", " << py << ", " << pz << ", v=" << vx << ", " << vy << ", " << vz << ", u=" << ux << ", " << uy << ", " << uz << endl;
core->SetSoundSourceName(iSource1, "Klaus die Katze");
core->SetSoundSourceName( iSource1, "Klaus die Katze" );
cout << "Get sound source name source 1: name = "
<< core->GetSoundSourceName(iSource1) << endl;
<< core->GetSoundSourceName( iSource1 ) << endl;
cout << "Set sound source volume source 1: volume = 1.23" << endl;
core->SetSoundSourceVolume(iSource1, 1.23);
core->SetSoundSourceVolume( iSource1, 1.23 );
core->LockScene();
int iListener1 = core->CreateListener("Lauschermann");
int iListener1 = core->CreateListener( "Lauschermann" );
cout << "Create listener 1: ID = " << iListener1 << endl;
core->SetListenerPositionOrientationVU(iListener1, 0, -1, 1, 0, 0, 1, 1, 0, 0);
core->SetListenerPositionOrientationVU( iListener1, 0, -1, 1, 0, 0, 1, 1, 0, 0 );
core->UnlockScene();
cout << "Delete sound source ID=1: result = " << core->DeleteSoundSource(1) << endl;
cout << "Delete sound source ID=1: result = " << core->DeleteSoundSource( 1 ) << endl;
//core->PrintSceneState();
}
......
Supports Markdown
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