Starting API changes in base and core interfacce

parent 901a410c
......@@ -16,10 +16,16 @@
#include <VABaseDefinitions.h>
#include <VAStruct.h>
#include <string>
#include <vector>
#include <cmath>
static const double g_dSoundPower_94dB_SPL_1m = 1.0f; // [W] Sound power that results in 94 dB SPL re 20uPa @ 1m for spherical spreading
static const double g_dDefaultSoundPower_128dB_SPL_1m = 1.0f; // [W] Sound power that results in 124 dB SPL re 20uPa @ 1m for spherical spreading
static const double g_dDefaultSpeedOfSound = 344.0f; // [m/s]
static const double g_dDefaultStaticPressure = 101125; // [Pa]
//! 3-element Vector (double precision), in a geometrical context in meters (if not stated otherwise)
class VABASE_API VAVec3
......@@ -151,19 +157,32 @@ VABASE_API std::ostream& operator<<( std::ostream& os, const VAQuat& oOrient );
//! Data class describing callable and registrable objects
/**
* 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
*/
struct VABASE_API CVAObjectInfo
{
int iID; //!< Object ID
std::string sName; //!< Object name
std::string sDesc; //!< Object description
inline CVAObjectInfo()
: iID( -1 )
{};
};
//! Pure data class describing modules of the core
/**
*
*/
struct VABASE_API CVAModuleInfo
{
std::string sName; //!< Module name
std::string sDesc; //!< Module description
CVAStruct oParams; //!< Parameters
};
//! Struct describing an audio renderer
......@@ -173,6 +192,17 @@ struct VABASE_API CVAAudioRendererInfo
std::string sClass; //!< Renderer class
std::string sDescription; //!< Renderer description
bool bEnabled; //!< Availability during runtime
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 )
{};
};
//! Struct describing an audio reproduction module
......@@ -182,6 +212,22 @@ struct VABASE_API CVAAudioReproductionInfo
std::string sClass; //!< Reproduction module class
std::string sDescription; //!< Reproduction module description
bool bEnabled; //!< Availability during runtime
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 )
{};
};
//! Describes the current state of a progress
......@@ -231,56 +277,66 @@ public:
, iValue( iTheValue )
{
};
private:
//! No default construction
inline CVAIntLiteral() {};
};
//! Data class containing information of loaded directivities for sources and receivers
//! 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.
*/
class VABASE_API CVADirectivityInfo
{
public:
enum DirectivityType
{
RECEIVER = 0,
SOURCE,
};
enum DirectivityClass
{
IMPULSE_RESPONSE = 0,
UNSPECIFIED = -1,
PROTOTYPE = 0,
IMPULSE_RESPONSE,
TRANSFER_FUNCTION,
ENERGETIC_BAND_SPECTRUM,
};
int iID; //!< ID
int iType;
int iClass;
std::string sName; //!< Name (optional)
std::string sFilename; //!< Filename
std::string sDesc; //!< Description (e.g. resolution)
int iID; //!< Identifier
int iClass; //!< Class identifier
std::string sName; //!< Name
std::string sDesc; //!< Verbose description
int iReferences; //!< Number of references
// TODO: Auflsung usw.
CVAStruct oParams; //!< Special parameters (including file path etc.)
//! Default constructor
inline CVADirectivityInfo()
: iID( -1 )
, iClass( UNSPECIFIED )
, iReferences( 0 )
{
};
//! Initializing constructor
/**
* \param iID Identifier
* \param sName Name of directivity
* \param sFilename Path to the data file
* \param sDesc Brief description of the directivity
* \param iReferences Usage reference count of directivity data
* @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
*/
inline CVADirectivityInfo( const int iID, const std::string& sName, const std::string& sFilename, const std::string& sDesc, const int iReferences )
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 )
{
this->iID = iID;
this->sName = sName;
this->sFilename = sFilename;
this->sDesc = sDesc;
this->iReferences = iReferences;
};
};
......@@ -289,34 +345,50 @@ public:
class VABASE_API CVASignalSourceInfo
{
public:
//! Signal source type
enum Type
{
UNSPECIFIED = -1,
FILE = 0,
SAMPLER,
DEVICE_INPUT,
NETSTREAM,
MACHINE,
ENGINE
};
std::string sID; //!< ID (i.e. "af1")
std::string sType; //!< Type (File|Sampler|Device input|Network stream)
std::string sName; //!< Name (i.e. "Trompet 1")
int iType; //!< Type
std::string sName; //!< Name (i.e. "Blue horn 2")
std::string sDesc; //!< Description
std::string sState; //!< State description
int iReferences; //!< Reference counter
//! Default constructor
inline CVASignalSourceInfo() : iReferences( 0 ) {};
inline ~CVASignalSourceInfo() {};
inline CVASignalSourceInfo()
: iReferences( 0 )
, iType( UNSPECIFIED )
{};
virtual inline ~CVASignalSourceInfo() {};
//! Initializing constructor
/**
* \param sID Identifier string
* \param sType Type of signal source info (i.e. File|Sampler|Device input|Network stream)
* \param iType
* \param sName Name of signal source info
* \param sDesc Brief description of signal source info
* \param sState State description of signal source info
* \param iReference Usage reference counter
*/
inline CVASignalSourceInfo( const std::string& sID, const std::string& sType, const std::string& sName, const std::string& sDesc, const std::string& sState, const int iReferences )
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 )
{
this->sID = sID;
this->sType = sType;
this->sName = sName;
this->sDesc = sDesc;
this->sState = sState;
this->iReferences = iReferences;
};
};
......@@ -363,16 +435,26 @@ public:
class VABASE_API CVASoundSourceInfo
{
public:
int iID; //!< ID
std::string sName; //!< Displayed name
VAVec3 vPos; //!< Position vector [m]
VAVec3 vView, vUp; //!< View-/Up vector
VAQuat oOrient; //!< Orientation (quaternion)
double dVolume; //!< Volume
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)
int iID; //!< ID
std::string sName; //!< Displayed name
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)
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)
CVAStruct oParams; //!< Special parameters
inline CVASoundSourceInfo()
: iID( -1 )
, bMuted( false )
, dSpoundPower( g_dSoundPower_94dB_SPL_1m )
, iSignalSourceID( -1 )
, iDirectivityID( -1 )
, iAuraMode( -1 )
{};
virtual inline ~CVASoundSourceInfo() {};
};
......@@ -382,14 +464,22 @@ public:
class VABASE_API CVASoundReceiverInfo
{
public:
int iID; //!< ID
std::string sName; //!< Displayed name
VAVec3 vPos; //!< Position vector [m]
VAVec3 vVel; //!< Velocity vector [m/s]
VAVec3 vView, vUp; //!< View-/Up-vector
VAQuat oOrient; //!< Orientation (quaternion)
int iDirectivityID; //!< ID of assigned directivity (-1 => none)
int iAuraMode; //!< Auralization mode (flags)
int iID; //!< ID
std::string sName; //!< Displayed name
VAVec3 v3Pos; //!< Position vector of location between ears [m]
VAVec3 v3View, vUp; //!< Orientation of ears/eyes (view and up vectors in OpenGL convention)
VAQuat qOrient; //!< Orientation of ears/eyes (quaternion)
VAVec3 v3HeadAboveTorsoOrientation; //!< Orientation of head above torso
int iDirectivityID; //!< ID of assigned directivity (-1 => none)
int iAuraMode; //!< Auralization mode (flags)
double dSensivitity; //!< Sensitivity of receiving entity
inline CVASoundReceiverInfo()
: iID( -1 )
, iDirectivityID( -1 )
, iAuraMode( -1 )
, dSensivitity( 1.0f )
{};
virtual inline ~CVASoundReceiverInfo() {};
};
......@@ -403,8 +493,12 @@ public:
std::string sName; //!< Displayed name (optional)
VAVec3 vPos; //!< Position vector [m]
VAVec3 vView, vUp; //!< View-/Up-vector
VAQuat oOrient; //!< Orientation (quaternion)
double dState; //!< Portal state [0..1] (0 => fully closed, 1 => fully opened)
VAQuat qOrient; //!< Orientation (quaternion)
CVAStruct oParams; //!< Special parameters
inline CVAPortalInfo()
: iID( -1 )
{};
virtual inline ~CVAPortalInfo() {};
};
......
This diff is collapsed.
......@@ -24,7 +24,7 @@
const double DECIBEL_MINUS_INFINITY = -1.5E-308;
#define VACORE_REGISTER_LITERAL(L) push_back( CVAIntLiteral( "VACore", #L, IVACore::L) )
#define VACORE_REGISTER_LITERAL(L) push_back( CVAIntLiteral( "VACore", #L, IVACore::L ) )
class CVALiteralsTable : public std::vector<CVAIntLiteral>
{
......@@ -41,7 +41,7 @@ public:
VACORE_REGISTER_LITERAL( VA_PLAYBACK_STATE_PAUSED );
VACORE_REGISTER_LITERAL( VA_PLAYBACK_STATE_PLAYING );
VACORE_REGISTER_LITERAL( VA_PLAYBACK_STATE_STOPPED );
VACORE_REGISTER_LITERAL( VA_PLAYBACK_ACTION_NONE );
VACORE_REGISTER_LITERAL( VA_PLAYBACK_ACTION_STOP );
VACORE_REGISTER_LITERAL( VA_PLAYBACK_ACTION_PLAY );
......@@ -61,7 +61,6 @@ public:
VACORE_REGISTER_LITERAL( VA_AURAMODE_DEFAULT );
VACORE_REGISTER_LITERAL( VA_AURAMODE_ALL );
};
};
#undef VACORE_REGISTER_LITERAL
......@@ -75,23 +74,24 @@ IVACore::~IVACore() {}
bool IVACore::AddSearchPath( const std::string& sPath )
{
CVAStruct oArg, oRet;
oArg["addsearchpath"] = sPath;
CallModule( "VACore", oArg, oRet );
bool bPathFound = oRet["pathvalid"];
CVAStruct oArg;
oArg[ "addsearchpath" ] = sPath;
CVAStruct oRet = CallModule( "VACore", oArg );
const bool bPathFound = oRet[ "pathvalid" ];
return bPathFound;
}
bool IVACore::IsValidAuralizationMode(int iAuralizationMode)
bool IVACore::IsValidAuralizationMode( const int iAuralizationMode )
{
return ( iAuralizationMode >= 0 ) && ( iAuralizationMode <= 2047 );
}
bool IVACore::IsValidVolume(double dVolume) {
return (dVolume >= 0);
bool IVACore::IsValidVolume( const double dVolume )
{
return ( dVolume >= 0 );
}
bool IVACore::IsValidAudiofileSignalSourcePlaybackAction( int iAction )
bool IVACore::IsValidAudiofileSignalSourcePlaybackAction( const int iAction )
{
if( iAction == IVACore::VA_PLAYBACK_ACTION_PAUSE )
return true;
......@@ -99,11 +99,11 @@ bool IVACore::IsValidAudiofileSignalSourcePlaybackAction( int iAction )
return true;
if( iAction == IVACore::VA_PLAYBACK_ACTION_STOP )
return true;
return false;
}
std::string IVACore::GetLogLevelStr( int iLogLevel )
std::string IVACore::GetLogLevelStr( const int iLogLevel )
{
if( iLogLevel == IVACore::VA_LOG_LEVEL_QUIET ) return "QUIET";
if( iLogLevel == IVACore::VA_LOG_LEVEL_ERROR ) return "ERRORS";
......@@ -117,21 +117,21 @@ std::string IVACore::GetLogLevelStr( int iLogLevel )
// Parses a token of an auralization mode part (must be uppercase, used below)
int ParseAuralizationModeToken( const std::string& t )
{
if (t == "DS") return IVACore::VA_AURAMODE_DIRECT_SOUND;
if (t == "ER") return IVACore::VA_AURAMODE_EARLY_REFLECTIONS;
if (t == "DD") return IVACore::VA_AURAMODE_DIFFUSE_DECAY;
if (t == "DIR") return IVACore::VA_AURAMODE_DIRECTIVITY;
if (t == "AA") return IVACore::VA_AURAMODE_AIR_ABSORPTION;
if (t == "TV") return IVACore::VA_AURAMODE_ATMOS_TEMP_VAR;
if (t == "SC") return IVACore::VA_AURAMODE_SCATTERING;
if (t == "DIF") return IVACore::VA_AURAMODE_DIFFRACTION;
if (t == "NF") return IVACore::VA_AURAMODE_NEARFIELD;
if (t == "DP") return IVACore::VA_AURAMODE_DOPPLER;
if( t == "DS" ) return IVACore::VA_AURAMODE_DIRECT_SOUND;
if( t == "ER" ) return IVACore::VA_AURAMODE_EARLY_REFLECTIONS;
if( t == "DD" ) return IVACore::VA_AURAMODE_DIFFUSE_DECAY;
if( t == "DIR" ) return IVACore::VA_AURAMODE_DIRECTIVITY;
if( t == "AA" ) return IVACore::VA_AURAMODE_AIR_ABSORPTION;
if( t == "TV" ) return IVACore::VA_AURAMODE_ATMOS_TEMP_VAR;
if( t == "SC" ) return IVACore::VA_AURAMODE_SCATTERING;
if( t == "DIF" ) return IVACore::VA_AURAMODE_DIFFRACTION;
if( t == "NF" ) return IVACore::VA_AURAMODE_NEARFIELD;
if( t == "DP" ) return IVACore::VA_AURAMODE_DOPPLER;
if( t == "SL" ) return IVACore::VA_AURAMODE_SPREADING_LOSS;
return -1;
}
int IVACore::ParseAuralizationModeStr( const std::string& sModeStr, int iBaseMode )
int IVACore::ParseAuralizationModeStr( const std::string& sModeStr, const int iBaseMode )
{
// Remove all whitespaces, valid chars: Alphabetic + *+-,
std::string s;
......@@ -140,114 +140,133 @@ int IVACore::ParseAuralizationModeStr( const std::string& sModeStr, int iBaseMod
if( isspace( sModeStr[ k ] ) )
continue;
if (isalpha(sModeStr[k])) {
if( isalpha( sModeStr[ k ] ) )
{
s += char( toupper( sModeStr[ k ] ) );
continue;
}
if ((sModeStr[k] == '*') ||
(sModeStr[k] == '+') ||
(sModeStr[k] == '-') ||
(sModeStr[k] == ',')) {
if( ( sModeStr[ k ] == '*' ) ||
( sModeStr[ k ] == '+' ) ||
( sModeStr[ k ] == '-' ) ||
( sModeStr[ k ] == ',' ) )
{
s += char( toupper( sModeStr[ k ] ) );
continue;
}
VA_EXCEPT2(INVALID_PARAMETER, "Auralization mode specification contains invalid characters");
VA_EXCEPT2( INVALID_PARAMETER, "Auralization mode specification contains invalid characters" );
}
// Trivial cases: Empty string, "null", "none", "default", "all"
if (s.empty()) return VA_AURAMODE_NOTHING;
if ((s == "NULL") || (s == "NONE")) return VA_AURAMODE_NOTHING;
if (s == "DEFAULT") return VA_AURAMODE_DEFAULT;
if ((s == "ALL") || (s == "*")) return VA_AURAMODE_ALL;
if( s.empty() ) return VA_AURAMODE_NOTHING;
if( ( s == "NULL" ) || ( s == "NONE" ) ) return VA_AURAMODE_NOTHING;
if( s == "DEFAULT" ) return VA_AURAMODE_DEFAULT;
if( ( s == "ALL" ) || ( s == "*" ) ) return VA_AURAMODE_ALL;
// Format: List of tokens seperated by commas (possibly whitespaces)
// [fwe] For not adding PCRE this is implemented by hand here
size_t i=0,j=0,op=0;
bool err=false;
int m=0; // Scanning modes: 0 => none, 1 => token
int def=0, plus=0, minus=0;
size_t i = 0, j = 0, op = 0;
bool err = false;
int m = 0; // Scanning modes: 0 => none, 1 => token
int def = 0, plus = 0, minus = 0;
std::string sErrorMsg;
for (i; i<s.length(); i++) {
if (isalpha(s[i])) {
if (m==0) { // None => Begin token
j=i;
m=1;
} else { // Token => extend
for( i; i < s.length(); i++ )
{
if( isalpha( s[ i ] ) )
{
if( m == 0 )
{
// None => Begin token
j = i;
m = 1;
}
else
{
// Token => extend
continue;
}
}
if (s[i] == '+') {
if ((m==1) || (op!=0)) { // Scanning toking || multiple operands => Error
if( s[ i ] == '+' )
{
if( ( m == 1 ) || ( op != 0 ) )
{ // Scanning toking || multiple operands => Error
err = true;
sErrorMsg = "Multiple plus operand found in auralisation mode";
break;
}
op=1;
op = 1;
}
if (s[i] == '-') {
if ((m==1) || (op!=0)) { // Scanning toking || multiple operands => Error
if( s[ i ] == '-' )
{
if( ( m == 1 ) || ( op != 0 ) )
{ // Scanning toking || multiple operands => Error
err = true;
sErrorMsg = "Multiple minus operand found in auralisation mode";
break;
}
op=2;
op = 2;
}
if (s[i] == ',') {
if (m==0) { // No token => Error
if( s[ i ] == ',' )
{
if( m == 0 )
{ // No token => Error
err = true;
sErrorMsg = "No token in auralisation mode found";
break;
} else { // Finished token
std::string t = s.substr(j,i-j);
int p=ParseAuralizationModeToken(t);
if (p==-1) {
}
else
{ // Finished token
std::string t = s.substr( j, i - j );
int p = ParseAuralizationModeToken( t );
if( p == -1 ) {
// Invalid token
sErrorMsg = "Invalid token '"+t+"' found in auralisation mode";
sErrorMsg = "Invalid token '" + t + "' found in auralisation mode";
err = true;
break;
}
if (op==0) def |= p; // No operator
if (op==1) plus |= p; // Plus operator
if (op==2) minus |= p; // Minus operator
if( op == 0 ) def |= p; // No operator
if( op == 1 ) plus |= p; // Plus operator
if( op == 2 ) minus |= p; // Minus operator
op=0;
j=0;
m=0;
op = 0;
j = 0;
m = 0;
}
}
}
// Unfinished token?
if (m!=0) {
std::string t = s.substr(j,i-j);
int p=ParseAuralizationModeToken(t);
if (p==-1) {
if( m != 0 )
{
std::string t = s.substr( j, i - j );
int p = ParseAuralizationModeToken( t );
if( p == -1 )
{
// Invalid token
sErrorMsg = "Invalid token '"+t+"' found in auralisation mode";
sErrorMsg = "Invalid token '" + t + "' found in auralisation mode";
err = true;
}
if (op==0) def |= p; // No operator
if (op==1) plus |= p; // Plus operator
if (op==2) minus |= p; // Minus operator
if( op == 0 ) def |= p; // No operator
if( op == 1 ) plus |= p; // Plus operator
if( op == 2 ) minus |= p; // Minus operator
}
if (err)
VA_EXCEPT2(INVALID_PARAMETER, "Invalid auralization mode specification, " + sErrorMsg);
if( err )
VA_EXCEPT2( INVALID_PARAMETER, "Invalid auralization mode specification, " + sErrorMsg );
// Combine modes:
int result=(iBaseMode & VA_AURAMODE_ALL);
if (def != 0) // Assignment => Forget about the base
int result = ( iBaseMode & VA_AURAMODE_ALL );
if( def != 0 ) // Assignment => Forget about the base
result = def;
// Plus flags
......@@ -259,61 +278,69 @@ int IVACore::ParseAuralizationModeStr( const std::string& sModeStr, int iBaseMod
return result;
}