VABase.h 22.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 *  --------------------------------------------------------------------------------------------
 *
 *    VVV        VVV A           Virtual Acoustics (VA) | http://www.virtualacoustics.org
 *     VVV      VVV AAA          Licensed under the Apache License, Version 2.0
 *      VVV    VVV   AAA
 *       VVV  VVV     AAA        Copyright 2015-2017
 *        VVVVVV       AAA       Institute of Technical Acoustics (ITA)
 *         VVVV         AAA      RWTH Aachen University
 *
 *  --------------------------------------------------------------------------------------------
 */

#ifndef IW_VABASE
#define IW_VABASE

#include <VABaseDefinitions.h>

19 20
#include <VAStruct.h>

21 22 23 24
#include <string>
#include <vector>
#include <cmath>

25 26
// L_w = L_p + 10 * log10( 1m / 1m ) dB re 1pW + 10 * log10 ( 4 * pi ) dB re 1pW; P = 10^( L_w / 10 ) * 1pW
static const double g_dSoundPower_94dB_SPL_1m = 0.0316227766f; //!< [W] Sound power that results in 94 dB SPL re 20uPa @ 1m for spherical spreading
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
27
static const double g_dSoundPower_128dB_SPL_1m = 31.6227766017f; //!< [W] Sound power that results in 124 dB SPL re 20uPa @ 1m for spherical spreading
28 29 30 31 32 33

// c ~= ( 331.5 + 0.6 * 20 degree / degree ) m/s
static const double g_dDefaultSpeedOfSound = 343.0f; //!< [m/s] Sound speed at 20 degree centigrade with adiabatic approximation
static const double g_dDefaultStaticPressure = 101325.0f; //!< [Pa] Norm pressure over NN; 1 bar; 1 atmosphere; *100 hPa
static const double g_dDefaultTemperature = 20.0f; //!< [Degree centigrade] Arbitrarily defined, satisfactory for indoor and outdoor
static const double g_dDefaultRelativeHumidity = 20.0f; //!< [Percent]
34 35

//! 3-element Vector (double precision), in a geometrical context in meters (if not stated otherwise)
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
36
/**
37
  * Uses Cartesian style, mostly operated within OpenGL-rotation convention context (especially for view-up direction vectors)
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
38
  */
39 40 41 42 43
class VABASE_API VAVec3
{
public:
	union
	{
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
44
		//!< Vector compontents in order x,y,z
45 46 47 48 49 50 51
		double comp[ 3 ];
		struct
		{
			double x, y, z;
		};
	};

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
52
	//! Default constructur, sets values to zero
53
	inline VAVec3() : x( 0 ), y( 0 ), z( 0 ) {};
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
54 55 56 57 58

	//! Copy constructor
	/**
	  * @param[in] v Copy values from this vector
	  */
59
	inline VAVec3( const VAVec3& v ) : x( v.x ), y( v.y ), z( v.z ) {};
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
60 61 62 63 64 65 66

	//! Init constructor
	/**
	  * @param[in] x X component
	  * @param[in] y Y component
	  * @param[in] z Z component
	  */
67
	inline VAVec3( const double x, const double y, const double z ) : x( x ), y( y ), z( z ) {};
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
68 69

	//! Destructor
70 71
	inline virtual ~VAVec3() {};

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
72 73 74 75
	//! Returns RMS lengs / L2 norm
	/*
	 * @return L2 norm length of cartesian cevrot
	 */
76 77 78 79 80
	inline virtual double Length() const
	{
		return sqrt( x*x + y*y + z*z );
	};

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
81 82 83 84 85 86
	//! Component setter
	/**
	  * @param[in] x_ X component
	  * @param[in] y_ Y component
	  * @param[in] z_ Z component
	  */
87
	inline virtual void Set( const double x_, const double y_, const double z_ )
88 89 90 91 92 93
	{
		x = x_;
		y = y_;
		z = z_;
	};

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
94 95 96 97 98 99
	//! Get cross product
	/**
	  * Performs cross product of internal components with parameter vector
	  * @param[in] vCrossProduct Cross product right-hand value
	  * @return Cross product vector
	  */
100 101 102 103 104 105 106 107 108
	inline VAVec3 Cross( const VAVec3& vCrossProduct ) const
	{
		VAVec3 vCrossResult;
		vCrossResult.x = y * vCrossProduct.z - z * vCrossProduct.y;
		vCrossResult.y = z * vCrossProduct.x - x * vCrossProduct.z;
		vCrossResult.z = x * vCrossProduct.y - y * vCrossProduct.x;
		return vCrossResult;
	};

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
109 110 111 112 113 114
	//! Get dot product
	/**
	  * Performs dot product of internal components with parameter vector
	  * @param[in] vDotProduct Dot product right-hand value
	  * @return Dot product scalar
	  */
115 116 117 118 119
	inline double Dot( const VAVec3& vDotProduct ) const
	{
		return ( x * vDotProduct.x + y * vDotProduct.y + z * vDotProduct.z );
	};

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
120 121 122 123
	//!< Normalizes internal components
	/**
	  * Will return in a L2 norm of 1.0
	  */
124 125 126 127 128 129 130
	inline void Norm()
	{
		const double l = Length();
		x /= l;
		y /= l;
		z /= l;
	};
131

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
132 133 134 135 136 137
	//!< Get vector as struct
	/**
	  * For struct payload serializaton / deserialization. Make sure that keys are not already assigned.
	  *
	  * @return Struct with vector as x,y,z components with keys "x", "y", "z".
	  */
138 139 140 141 142 143 144 145
	inline CVAStruct GetAsStruct() const
	{
		CVAStruct oVec;
		oVec[ "x" ] = x;
		oVec[ "y" ] = y;
		oVec[ "z" ] = z;
		return oVec;
	};
146 147
};

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
148 149 150 151 152 153 154
//!< Compare operator for vectors
/**
  * @param[in] a Left-hand vector
  * @param[in] b Right-hand vector
  *
  * @return True, if equal
  */
155 156 157 158 159
inline VABASE_API bool operator==( const VAVec3& a, const VAVec3& b )
{
	return ( ( a.x == b.x ) && ( a.y == b.y ) && ( a.z == b.z ) );
};

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
160 161 162 163 164 165 166
//!< Unequal operator for vectors
/**
  * @param[in] a Left-hand vector
  * @param[in] b Right-hand vector
  *
  * @return True, if unequal
  */
167 168 169 170 171
inline VABASE_API bool operator!=( const VAVec3& a, const VAVec3& b )
{
	return !( a == b );
};

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
172 173 174 175 176 177 178
//!< Add operator for vectors
/**
  * @param[in] oSummand1 Left-hand vector
  * @param[in] oSummand2 Right-hand vector
  *
  * @return Addition result
  */
179 180 181 182 183 184 185 186 187
inline VABASE_API VAVec3 operator+( const VAVec3& oSummand1, const VAVec3& oSummand2 )
{
	VAVec3 vSum;
	vSum.x = oSummand1.x + oSummand2.x;
	vSum.y = oSummand1.y + oSummand2.y;
	vSum.z = oSummand1.z + oSummand2.z;
	return vSum;
};

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
188 189 190 191 192 193 194
//!< Subtract operator for vectors
/**
  * @param[in] oSummand1 Left-hand vector
  * @param[in] oSummand2 Right-hand vector
  *
  * @return Subtraction result
  */
195 196 197 198 199 200 201 202 203
inline VABASE_API VAVec3 operator-( const VAVec3& oSummand1, const VAVec3& oSummand2 )
{
	VAVec3 vDiff;
	vDiff.x = oSummand1.x - oSummand2.x;
	vDiff.y = oSummand1.y - oSummand2.y;
	vDiff.z = oSummand1.z - oSummand2.z;
	return vDiff;
};

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
204 205
//!< Scalar multiply operator for vectors
/**
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
206
  * @param[in] oVec Vector
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
207 208
  * @param[in] dScalar Scalar
  *
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
209
  * @return Scaled vector
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
210
  */
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
211
inline VABASE_API VAVec3 operator*( const VAVec3& oVec, const double dScalar )
212 213 214 215 216 217 218 219
{
	VAVec3 vScaledVector = oVec;
	vScaledVector.x *= dScalar;
	vScaledVector.y *= dScalar;
	vScaledVector.z *= dScalar;
	return vScaledVector;
};

220
//! Stream output operator for VAVec3
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
221 222 223 224 225 226 227 228
/**
  * Output format: "< x, y, z >"
  *
  * @param[in] os Outstream
  * @param[in] oVec Vector
  *
  * @return Outstream with vector output attached
  */
229 230
VABASE_API std::ostream& operator<<( std::ostream& os, const VAVec3& oVec );

231 232

//! 4-element Quaternion (double precision)
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
233 234 235
/**
  * Quaternion representation for solid rotation and orientation representation.
  */
236
class VABASE_API VAQuat
237 238
{
public:
239 240
	union
	{
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
241
		//!< Components in order x,y,z,w
242 243 244 245 246 247
		double comp[ 4 ];
		struct
		{
			double x, y, z, w;
		};
	};
248

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
249
	//! Default constructur, sets values to zero and w to 1.0
250
	inline VAQuat() : x( 0 ), y( 0 ), z( 0 ), w( 1.0f ) {};
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
251 252 253 254 255

	//! Copy constructor
	/**
	  * @param[in] v Will copy values from this quaternion
	  */
256
	inline VAQuat( const VAQuat& v ) : x( v.x ), y( v.y ), z( v.z ), w( v.w ) {};
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
257 258 259 260 261 262 263 264
	
	//! Init constructor
	/**
	  * @param[in] x X component
	  * @param[in] y Y component
	  * @param[in] z Z component
	  * @param[in] w W component
	  */
265
	inline VAQuat( const double x, const double y, const double z, const double w = 1.0f ) : x( x ), y( y ), z( z ), w( w ) {};
266

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
267 268 269 270 271 272 273 274 275 276
	//! Destructor
	inline virtual ~VAQuat() {};
	
	//! Setter
	/**
	  * @param[in] x_ X component
	  * @param[in] y_ Y component
	  * @param[in] z_ Z component
	  * @param[in] w_ W component
	  */
277
	inline virtual void Set( const double x_, const double y_, const double z_, const double w_ )
278
	{
279 280 281 282
		x = x_;
		y = y_;
		z = z_;
		w = w_;
283
	};
284
	
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
285 286 287 288 289 290
	//!< Get vector as struct
	/**
	  * For struct payload serializaton / deserialization. Make sure that keys are not already assigned.
	  *
	  * @return Struct with vector as x,y,z,w components with keys "x", "y", "z", "w".
	  */
291 292 293 294 295 296 297 298 299
	inline CVAStruct GetAsStruct() const
	{
		CVAStruct oOrient;
		oOrient[ "x" ] = x;
		oOrient[ "y" ] = y;
		oOrient[ "z" ] = z;
		oOrient[ "w" ] = w;
		return oOrient;
	};
300 301
};

302
//! Stream output operator for Quaternion
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
303 304 305 306 307 308 309 310 311
/**
  * Output format: "< x, y, z, w >"
  *
  * @param[in] os Outstream
  * @param[in] qOrient Quaternion orientation
  *
  * @return Outstream with quaternion output attached
  */
VABASE_API std::ostream& operator<<( std::ostream& os, const VAQuat& qOrient );
312 313 314


//! Data class describing callable and registrable objects
315 316 317 318 319
/**
  * In VA, anything can be an object. If an object is registered,
  * it can also be listed and called over the VA interface. Then, it
  * is called a module, @sa CVAModuleInfo, GetModules
  */
320 321 322 323 324
struct VABASE_API CVAObjectInfo
{
	int iID;			//!< Object ID
	std::string sName;	//!< Object name
	std::string sDesc;	//!< Object description
325

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
326
	//! Default constructor will set identifier to -1
327 328 329
	inline CVAObjectInfo()
		: iID( -1 )
	{};
330 331 332 333
};


//! Pure data class describing modules of the core
334
/**
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
335
  * For module info getter.
336
  */
337 338 339 340
struct VABASE_API CVAModuleInfo
{
	std::string sName;	//!< Module name
	std::string sDesc;	//!< Module description
341
	CVAStruct oParams; //!< Parameters
342 343 344
};

//! Struct describing an audio renderer
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
345 346 347
/**
  * Rendering module info for getters.
  */
348 349 350 351 352 353
struct VABASE_API CVAAudioRendererInfo
{
	std::string sID;	//!< Renderer identifier
	std::string sClass; //!< Renderer class
	std::string sDescription; //!< Renderer description
	bool bEnabled; //!< Availability during runtime
354 355 356 357 358 359 360 361 362 363 364
	bool bOutputDetectorEnabled; //!< Indicates if output detector is enabled
	bool bOutputRecordingEnabled; //!< Indicates if output detector is enabled
	std::string sOutputRecordingFilePath; //!< Output recording file path
	CVAStruct oParams; //!< Additional parameters, may be changed during runtime

	//! Constructor with default init values
	inline CVAAudioRendererInfo()
		: bEnabled( false )
		, bOutputDetectorEnabled( false )
		, bOutputRecordingEnabled( false )
	{};
365 366 367
};

//! Struct describing an audio reproduction module
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
368 369 370
/**
  * Reproduction module info for getters.
  */
371 372 373 374 375 376
struct VABASE_API CVAAudioReproductionInfo
{
	std::string sID;	//!< Reproduction module identifier
	std::string sClass; //!< Reproduction module class
	std::string sDescription; //!< Reproduction module description
	bool bEnabled; //!< Availability during runtime
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392
	bool bInputDetectorEnabled; //!< Indicates if output detector is enabled
	bool bInputRecordingEnabled; //!< Indicates if output detector is enabled
	std::string sInputRecordingFilePath; //!< Output recording file path
	bool bOutputDetectorEnabled; //!< Indicates if output detector is enabled
	bool bOutputRecordingEnabled; //!< Indicates if output detector is enabled
	std::string sOutputRecordingFilePath; //!< Output recording file path
	CVAStruct oParams; //!< Additional parameters, may be changed during runtime

	//! Constructor with default init values
	inline CVAAudioReproductionInfo()
		: bEnabled( false )
		, bInputDetectorEnabled( false )
		, bInputRecordingEnabled( false )
		, bOutputDetectorEnabled( false )
		, bOutputRecordingEnabled( false )
	{};
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410
};

//! Describes the current state of a progress
/**
  * This data class is used to describe the current state of a
  * running process (progress). It is intended for the purpose
  * of displaying the progress of an action that takes some time
  * to be shown in a user interface (i.e. the initialisation of
  * a core)
  */
class VABASE_API CVAProgress
{
public:
	int iCurrentStep;		//!< Current step number (0 = nothing happened yet)
	int iMaxStep;			//!< Maximum step number (end)
	std::string sAction;	//!< Currently performed action (top level)
	std::string sSubaction;	//!< Currently performed sub action

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
411
	//! Constructor inits values
412
	inline CVAProgress()
413 414 415 416 417 418 419 420
		: iCurrentStep( 0 )
		, iMaxStep( 0 )
	{
	};
};


//! Data class describing integer literals within the core interface (reflexions)
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
421 422 423
/**
  * For literals getter.
  */
424 425 426 427 428 429 430 431 432 433 434
class VABASE_API CVAIntLiteral
{
public:
	std::string sScope;		//!< Interface name (e.g. IVACore)
	std::string sName;		//!< Literal name (e.g. 'VA_AURAMODE_DIRECT_SOUND')
	int iValue;				//!< Literal integer value

	//! Constructor
	/**
	  * Create an integer literal.
	  *
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
435 436 437
	  * @param[in] sTheScope Scope of the literal, i.e. IVACore
	  * @param[in] sTheName Name string of the integer literal, i.e. 'VA_AURAMOD_DEFAULT'
	  * @param[in] iTheValue Value of the integer
438
	  */
439
	inline CVAIntLiteral( const std::string& sTheScope, const std::string& sTheName, const int iTheValue )
440 441 442 443 444
		: sScope( sTheScope )
		, sName( sTheName )
		, iValue( iTheValue )
	{
	};
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
445

446 447 448
private:
	//! No default construction
	inline CVAIntLiteral() {};
449 450
};

451 452 453 454 455 456 457 458 459 460 461
//! Data class containing information on directivities of sound sources and sound receivers
/**
  * This class describes a directivity: the sound changes depending on the directional component
  * of a sending or receiving entity. It may also include distance-dependent data.
  *
  * There are certain classes available, that will be recognized by most renderers. However,
  * you might want to use the PROTOTYPE class if you are testing new types that are not part
  * of the VA base interface.
  *
  * Special parameters are stores in the parameter struct.
  */
462 463 464
class VABASE_API CVADirectivityInfo
{
public:
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
465
	//! Directivity class definitions
466
	enum DirectivityClass
467
	{
468 469 470
		UNSPECIFIED = -1,
		PROTOTYPE = 0,
		IMPULSE_RESPONSE,
471 472
		TRANSFER_FUNCTION,
		ENERGETIC_BAND_SPECTRUM,
473 474
	};

475 476 477 478
	int iID;					//!< Identifier
	int iClass;					//!< Class identifier
	std::string sName;			//!< Name
	std::string sDesc;			//!< Verbose description
479
	int iReferences;			//!< Number of references
480
	CVAStruct oParams; 			//!< Special parameters (including file path etc.)
481

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
482
	//! Default constructor inits some values
483
	inline CVADirectivityInfo()
484
		: iID( -1 )
485
		, iClass( UNSPECIFIED )
486 487 488 489 490 491
		, iReferences( 0 )
	{
	};

	//! Initializing constructor
	/**
492 493 494 495 496 497
	  * @param[in] iID Identifier
	  * @param[in] iClass Directivity class
	  * @param[in] sName Name of directivity
	  * @param[in] sDesc Brief description of the directivity
	  * @param[in] iReferences Usage reference count of directivity data
	  * @param[in] oParams Special parameters
498
	  */
499 500 501 502 503 504 505
	inline CVADirectivityInfo( const int iID, const int iClass, const std::string& sName, const std::string& sDesc, const int iReferences, const CVAStruct& oParams )
		: iID( iID )
		, iClass( iClass )
		, sName( sName )
		, sDesc( sDesc )
		, iReferences( iReferences )
		, oParams( oParams )
506 507 508 509 510 511
	{
	};
};


//! Data class for signal source information
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
512 513 514
/**
  * For info getter.
  */
515 516 517
class VABASE_API CVASignalSourceInfo
{
public:
518 519 520 521 522 523 524 525 526 527 528 529
	//! Signal source type
	enum Type
	{
		UNSPECIFIED = -1,
		FILE = 0,
		SAMPLER,
		DEVICE_INPUT,
		NETSTREAM,
		MACHINE,
		ENGINE
	};

530
	std::string	sID;			//!< ID (i.e. "af1")
531 532
	int	iType;					//!< Type
	std::string sName;			//!< Name (i.e. "Blue horn 2")
533 534 535 536 537
	std::string sDesc;			//!< Description
	std::string sState;			//!< State description
	int iReferences;			//!< Reference counter

	//! Default constructor
538 539 540 541 542
	inline CVASignalSourceInfo()
		: iReferences( 0 )
		, iType( UNSPECIFIED )
	{};

543
	// Signal source destructor
544
	virtual inline ~CVASignalSourceInfo() {};
545 546 547

	//! Initializing constructor
	/**
Dipl.-Ing. Jonas Stienen's avatar
Stuff  
Dipl.-Ing. Jonas Stienen committed
548 549 550 551 552 553
	  * @param[in] sID Identifier string
	  * @param[in] iType Signal source type
	  * @param[in] sName Name of signal source info
	  * @param[in] sDesc Brief description of signal source info
	  * @param[in] sState State description of signal source info
	  * @param[in] iReference Usage reference counter
554
	  */
555 556 557 558 559 560 561
	inline CVASignalSourceInfo( const std::string& sID, const int iType, const std::string& sName, const std::string& sDesc, const std::string& sState, const int iReferences )
		: sID( sID )
		, iType( iType )
		, sName( sName )
		, sDesc( sDesc )
		, sState( sState )
		, iReferences( iReferences )
562
	{
563
	};
564 565 566
};


567
//! Data class containing information of a virtual acoustic scene
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
568 569 570
/**
  * For scene getter.
  */
571 572 573
class VABASE_API CVASceneInfo
{
public:
574 575
	std::string sID;	//!< Scene identifier
	std::string sName;	//!< Scene name
Dipl.-Ing. Jonas Stienen's avatar
Stuff  
Dipl.-Ing. Jonas Stienen committed
576
	bool bEnabled; //!< Enabled/disabled flag
577 578
	CVAStruct oParams; //!< Scene parameters

Dipl.-Ing. Jonas Stienen's avatar
Stuff  
Dipl.-Ing. Jonas Stienen committed
579
	//! Constructor settng scene info as enabled
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
580 581 582 583 584
	inline CVASceneInfo()
		: bEnabled( true )
	{
	};

585
	//! Scene info destructor
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
586 587 588
	inline virtual ~CVASceneInfo()
	{
	};
589 590 591 592
};


//! Data class describing states of audio streams
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
593 594 595
/**
  * For audio stream state getter.
  */
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621
class VABASE_API CVAAudiostreamState
{
public:
	int64_t	i64Sample;	//!< Index of the first sample since last clock reset
	double dSysTime;	//!< Associated system time in time [s] (internal core clock) of the first sample of the requested output block.
	double dCoreTime;	//!< Associated playback time in core clock time [s] (world time) of the first sample of the requested output block.
	bool bTimeReset;	//!<  Flag that indicates a discontinous change of the playback time (world time)

	//!< Synchronise commands on the stream
	/**  Flag that indicates, that a synchronized
	  * sequence of atomic commands is executed on
	  * elements of the stream. If this flag is true
	  * the source shall handle parameter
	  * changes and buffer them internally, but
	  * first apply them for the stream, if the
	  * flag is set to false again.
	  * Example: Synchronized start/stop of file sources
	  */
	bool bSyncMod;

	//! Destructor
	inline virtual ~CVAAudiostreamState() {};
};


//! Data class containing information of a sound source (acoustic actuator)
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
622 623 624
/**
  * For sound source info getter.
  */
625 626 627
class VABASE_API CVASoundSourceInfo
{
public:
628 629 630 631 632 633 634
	int iID;				//!< ID
	std::string sName;		//!< Displayed name
	double dSpoundPower;	//!< Sound power [W]
	bool bMuted;			//!< Muted?
	int iSignalSourceID;	//!< ID of assigned signal source (-1 => none)
	int iDirectivityID;		//!< ID of assigned directivity (-1 => none)
	int iAuraMode;			//!< Auralization mode (flags)
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
635 636 637 638 639

	VAVec3 v3Pos;			//!< Position vector of location between ears [m]
	VAVec3 v3View, v3Up;	//!< Orientation of ears/eyes (view and up vectors in OpenGL convention)
	VAQuat qOrient;			//!< Orientation of ears/eyes (quaternion)

640 641
	CVAStruct oParams;		//!< Special parameters

642
	//! Constructor for sound source info
643 644 645 646 647 648 649 650
	inline CVASoundSourceInfo()
		: iID( -1 )
		, bMuted( false )
		, dSpoundPower( g_dSoundPower_94dB_SPL_1m )
		, iSignalSourceID( -1 )
		, iDirectivityID( -1 )
		, iAuraMode( -1 )
	{};
651

652
	//! Destructor
653
	virtual inline ~CVASoundSourceInfo() {};
654 655 656
};


Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
657
//! Data class containing information of a sound receiver (acoustic receiver)
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
658 659 660
/**
  * For sound source info receiver.
  */
661
class VABASE_API CVASoundReceiverInfo
662 663
{
public:
664 665
	int iID;				//!< ID
	std::string sName;		//!< Displayed name
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
666 667 668 669 670
	int iDirectivityID;		//!< ID of assigned directivity (-1 => none)
	int iAuraMode;			//!< Auralization mode (flags)
	double dSensivitity;	//!< Sensitivity of receiving entity
	bool bEnabled; 			//!< Enabled/disable from processing

671
	VAVec3 v3Pos;			//!< Position vector of location between ears [m]
Dipl.-Ing. Jonas Stienen's avatar
Style  
Dipl.-Ing. Jonas Stienen committed
672
	VAVec3 v3View;//!< Orientation of ears/eyes (view and up vectors in OpenGL convention)
673
	VAVec3 v3Up;		//!< Orientation of ears/eyes (view and up vectors in OpenGL convention)
674
	VAQuat qOrient;			//!< Orientation of ears/eyes (quaternion)
675
	VAQuat qHeadAboveTorsoOrientation;	//!< Orientation of head above torso relative to ears
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
676 677

	VAVec3 v3RealWorldPos;					//!< Position vector of location between ears [m] in real world (from tracking)
678 679
	VAVec3 v3RealWorldView; //!< Orientation of ears/eyes (view and up vectors in OpenGL convention) in real world (from tracking)
	VAVec3 v3RealWorldUp;	//!< Orientation of ears/eyes (view and up vectors in OpenGL convention) in real world (from tracking)
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
680
	VAQuat qRealWorldOrient;				//!< Orientation of ears/eyes (quaternion) in real world (from tracking)
681
	VAQuat qRealWorldHeadAboveTorsoOrientation;	//!< Orientation of head above torso in real world (from tracking) relative to ears
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
682 683

	CVAStruct oParams; 	//!< Special parameters
684

685
	//! Constructor for sound receiver info
686 687 688 689 690
	inline CVASoundReceiverInfo()
		: iID( -1 )
		, iDirectivityID( -1 )
		, iAuraMode( -1 )
		, dSensivitity( 1.0f )
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
691
		, bEnabled( true )
692
	{};
693

694
	//! Destructor
695
	virtual inline ~CVASoundReceiverInfo() {};
696 697 698
};


699 700
//! Data class containing information of a sound portal (acoustic portal)
class VABASE_API CVASoundPortalInfo
701 702
{
public:
703 704
	int iID;			//!< ID
	std::string sName;	//!< Displayed name (optional)
705
	bool bEnabled; //!< Enabled flag
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
706

707
	int iMaterialID; //!< Material ID with transmission data
708 709 710
	int iNextPortalID; //!< Next sound portal identifier, if existing
	int iSoundReceiverID; //!< Source receiver identifier, if existing
	int iSoundSourceID; //!< Source sound identifier, if existing
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
711

712 713
	VAVec3 v3Pos;		//!< Position vector [m]
	VAVec3 v3View, v3Up;	//!< View-/Up-vector
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
714 715
	VAQuat qOrient;		//!< Orientation (quaternion)

716 717
	CVAStruct oParams; 	//!< Special parameters

718
	//! Default constructor for sound portal
719
	inline CVASoundPortalInfo()
720
		: iID( -1 )
721 722 723 724
		, iNextPortalID( -1 )
		, iSoundSourceID( -1 )
		, iSoundReceiverID( -1 )
		, iMaterialID( -1 )
725
	{};
726

727
	//! Destructor
728
	virtual inline ~CVASoundPortalInfo() {};
729 730 731
};


732 733 734 735 736 737
//! Data class containing information of an acoustic material
/**
  * This data class holds information on acoustic materials such as
  * absorption, scattering and transmission coefficients. Data has
  * a type, a data vector for floating point values and a set of parametres.
  */
738 739 740
class VABASE_API CVAAcousticMaterial
{
public:
741
	//! Material base frequency resolution
742 743 744 745 746 747 748 749
	enum Type
	{
		UNSPECIFIED = -1,
		PROTOTYPE = 0,
		ENERGETIC_BAND_FILTER_WHOLE_OCTAVE,
		ENERGETIC_BAND_FILTER_THIRD_OCTAVE,
	};

750 751 752 753 754 755 756
	int iID;			//!< Material identifier
	int iType; //!< Type, see #Type
	std::string sName; //!< Verbatim name
	CVAStruct oParams; //!< Parameters for prototyping
	std::vector< float > vfAbsorptionValues; //!< Absorption values
	std::vector< float > vfScatteringValues; //!< Scattering values
	std::vector< float > vfTransmissionValues; //!< Transmission values
757

758
	//! Instantiate empty material
759 760 761
	inline CVAAcousticMaterial()
		: iID( -1 )
	{};
762 763 764

	//! Destructor
	virtual inline ~CVAAcousticMaterial() {};
765 766 767 768 769 770 771 772 773 774 775 776 777 778
};



//! Geometry mesh class
/**
  * This is only intended to be used as an exchange
  * format of the simplest mesh structure. Renderers
  * use more elaborate representations.
  *
  * It can be used for rudimentary rooms and dynamic geometry objects.
  */
class VABASE_API CVAGeometryMesh
{
779
public:
780
	//! Vertex representation
781 782 783
	class CVAVertex
	{
	public:
784 785 786 787
		int iID; //!< Vertex identifier
		VAVec3 v3Point; //!< Vertext point / position

		//! Constructor initializing defaults
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
788
		inline CVAVertex() : iID( -1 ) {};
789 790
	};

791
	//! Face representation
792 793
	class CVAFace
	{
794
	public:
795
		int iID; //!< Face identifier
796
		int iMaterialID; //!< Assigned material
797 798 799
		std::vector< int > viVertexList; //!< Face vertices
		
		//! Constructor initializing defaults
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
800
		inline CVAFace() : iID( -1 ), iMaterialID( -1 ) {};
801 802
	};

803 804
	int iID; //!< Geometry mesh identifier
	bool bEnabled; //!< Enabled flag
805 806 807
	std::vector< CVAVertex > voVertices; //!< List of available vertices
	std::vector< CVAFace > voFaces; //!< List of faces defined by vertices
	CVAStruct oParams; //!< Additional parameters
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
808

809
	//! Constructor initializing members
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
810 811 812 813
	inline CVAGeometryMesh()
		: iID( -1 )
		, bEnabled( true )
	{};
814 815
};

816
#endif // IW_VABASE