Loading lib_com/ivas_prot.h +4 −18 Original line number Diff line number Diff line Loading @@ -4556,27 +4556,13 @@ void QuatToRotMat( float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ ); #ifndef FIX_I109_ORIENTATION_TRACKING void Quat2Euler( const Quaternion quat, /* i : quaternion describing the rotation */ float *yaw, /* o : yaw */ float *pitch, /* o : pitch */ float *roll /* o : roll */ ); #ifdef FIX_I109_ORIENTATION_TRACKING void Euler2Quat( const float yaw, /* i : yaw */ const float pitch, /* i : pitch */ const float roll, /* i : roll */ Quaternion *quat /* o : quaternion describing the rotation */ ); void Euler2RotMat( const float yaw, /* i : yaw */ const float pitch, /* i : pitch */ const float roll, /* i : roll */ float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ ); #endif void rotateAziEle( Loading Loading @@ -5503,12 +5489,12 @@ void ivas_reverb_get_hrtf_set_properties( /* Orientation tracking */ void ivas_orient_trk_Init( ivas_orient_trk_state_t *pOTR ivas_orient_trk_state_t *pOTR /* i/o : orientation tracker handle */ ); ivas_error ivas_orient_trk_SetTrackingType( ivas_orient_trk_state_t *pOTR, OTR_TRACKING_T trackingType ivas_orient_trk_state_t *pOTR, /* i/o : orientation tracker handle */ OTR_TRACKING_T trackingType /* i : orientation tracking type */ ); #ifdef FIX_I109_ORIENTATION_TRACKING Loading lib_dec/ivas_orient_trk.c +38 −13 Original line number Diff line number Diff line Loading @@ -53,11 +53,16 @@ /* TODO relate to frame rate - assumed here 50Hz, i.e. 20ms frame length */ #define OTR_UPDATE_RATE ( 50.0f ) /* rate of the Process() calls [Hz]; 1x per IVAS frame */ /*------------------------------------------------------------------------------------------* * Local functions *------------------------------------------------------------------------------------------*/ #ifdef FIX_I109_ORIENTATION_TRACKING /*------------------------------------------------------------------------------------------* * Declarations *------------------------------------------------------------------------------------------*/ void QuaternionProduct( const Quaternion q1, const Quaternion q2, Quaternion *const result ); float QuaternionDotProduct( const Quaternion q1, const Quaternion ); void QuaternionDivision( const Quaternion q, const float d, Quaternion *const result ); Loading @@ -81,6 +86,9 @@ void QuaternionProduct( *r = tmp; } /*------------------------------------------------------------------------------------------* * Quaternion dot product *------------------------------------------------------------------------------------------*/ float QuaternionDotProduct( const Quaternion q1, const Quaternion q2 ) Loading @@ -88,6 +96,9 @@ float QuaternionDotProduct( return q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w; } /*------------------------------------------------------------------------------------------* * Divides a quaternion by a scalar *------------------------------------------------------------------------------------------*/ void QuaternionDivision( const Quaternion q, const float d, Loading @@ -99,6 +110,9 @@ void QuaternionDivision( r->z = q.z / d; } /*------------------------------------------------------------------------------------------* * Normalizes a quaternion *------------------------------------------------------------------------------------------*/ void QuaternionNormalize( const Quaternion q, Quaternion *const r ) Loading @@ -106,6 +120,9 @@ void QuaternionNormalize( QuaternionDivision( q, sqrtf( QuaternionDotProduct( q, q ) ), r ); } /*------------------------------------------------------------------------------------------* * Computes a spherical linear interpolation between two quaternions *------------------------------------------------------------------------------------------*/ void QuaternionSlerp( const Quaternion q1, const Quaternion q2, Loading @@ -122,7 +139,7 @@ void QuaternionSlerp( angle = acosf( s ); denom = sinf( angle ); s = sinf( 1 - t ) * angle; s = sinf( ( 1 - t ) * angle ); s2 = sinf( t * angle ); r->x = ( q1.x * s + q2.x * s2 ) / denom; r->y = ( q1.y * s + q2.y * s2 ) / denom; Loading @@ -132,6 +149,9 @@ void QuaternionSlerp( QuaternionNormalize( *r, r ); } /*------------------------------------------------------------------------------------------* * Computes a quaternion conjugate *------------------------------------------------------------------------------------------*/ void QuaternionConjugate( const Quaternion q, Quaternion *const r ) Loading @@ -142,6 +162,9 @@ void QuaternionConjugate( r->z = -q.z; } /*------------------------------------------------------------------------------------------* * Computes an angle between two quaternions *------------------------------------------------------------------------------------------*/ float QuaternionAngle( const Quaternion q1, const Quaternion q2 ) Loading @@ -154,6 +177,9 @@ float QuaternionAngle( return angle; } /*------------------------------------------------------------------------------------------* * Computes an inverse quaternion *------------------------------------------------------------------------------------------*/ void QuaternionInverse( const Quaternion q, Quaternion *const r ) Loading Loading @@ -212,7 +238,7 @@ static float ClipAngle( *-------------------------------------------------------------------*/ void ivas_orient_trk_Init( ivas_orient_trk_state_t *pOTR ) ivas_orient_trk_state_t *pOTR ) /* i/o : orientation tracker handle */ { /* Track relative to a reference orientation */ pOTR->trackingType = OTR_TRACKING_REF_ORIENT; Loading Loading @@ -251,6 +277,7 @@ void ivas_orient_trk_Init( #endif } /*-------------------------------------------------------------------* * ivas_orient_trk_SetTrackingType() * Loading @@ -258,15 +285,14 @@ void ivas_orient_trk_Init( *-------------------------------------------------------------------*/ ivas_error ivas_orient_trk_SetTrackingType( ivas_orient_trk_state_t *pOTR, OTR_TRACKING_T trackingType ) ivas_orient_trk_state_t *pOTR, /* i/o : orientation tracker handle */ OTR_TRACKING_T trackingType ) /* i/o : orientation tracking type */ { pOTR->trackingType = trackingType; return IVAS_ERR_OK; } #ifdef FIX_I109_ORIENTATION_TRACKING #else #ifndef FIX_I109_ORIENTATION_TRACKING /*-------------------------------------------------------------------* * ivas_orient_trk_SetAbsoluteOrientation() * Loading Loading @@ -296,10 +322,10 @@ ivas_error ivas_orient_trk_SetAbsoluteOrientation( #ifdef FIX_I109_ORIENTATION_TRACKING ivas_error ivas_orient_trk_Process( ivas_orient_trk_state_t *pOTR, Quaternion absRot, float updateRate, Quaternion *pTrkRot ) ivas_orient_trk_state_t *pOTR, /* i/o : orientation tracker handle */ Quaternion absRot, /* i : absolute head rotation */ float updateRate, /* i : rotation update rate [Hz] */ Quaternion *pTrkRot ) /* o : tracked rotation */ { float normalizedOrientation; float relativeOrientationRate; Loading @@ -307,7 +333,6 @@ ivas_error ivas_orient_trk_Process( float cutoffFrequency; float alpha = pOTR->alpha; float ang; Quaternion tq; if ( pOTR->trackingType == OTR_TRACKING_AVG_ORIENT ) { Loading Loading @@ -482,8 +507,7 @@ ivas_error ivas_orient_trk_Process( return IVAS_ERR_OK; } #ifdef FIX_I109_ORIENTATION_TRACKING #else #ifndef FIX_I109_ORIENTATION_TRACKING /*-------------------------------------------------------------------* * ivas_orient_trk_GetTrackedOrientation() * Loading @@ -499,6 +523,7 @@ ivas_error ivas_orient_trk_GetTrackedOrientation( *yaw = pOTR->trkYaw; *pitch = pOTR->trkPitch; *roll = pOTR->trkRoll; return IVAS_ERR_OK; } #endif lib_dec/ivas_rotation.c +2 −73 Original line number Diff line number Diff line Loading @@ -105,7 +105,7 @@ ivas_error ivas_headTrack_open( #ifdef FIX_I109_ORIENTATION_TRACKING /*-----------------------------------------------------------------------* * ivas_headTrack_closes() * ivas_headTrack_close() * * Deallocate Head-Tracking handle *-----------------------------------------------------------------------*/ Loading Loading @@ -195,6 +195,7 @@ void QuatToRotMat( return; } #ifndef FIX_I109_ORIENTATION_TRACKING /*------------------------------------------------------------------------- * Quat2Euler() * Loading @@ -210,15 +211,9 @@ void Quat2Euler( { if ( quat.w != -3.0 ) { #ifdef FIX_I109_ORIENTATION_TRACKING *yaw = atan2f( 2.0f * ( quat.w * quat.z + quat.x * quat.y ), 1.0f - 2.0f * ( quat.y * quat.y + quat.z * quat.z ) ); *pitch = asinf( 2.0f * ( quat.w * quat.y - quat.z * quat.x ) ); *roll = atan2f( 2.0f * ( quat.w * quat.x + quat.y * quat.z ), 1.0f - 2.0f * ( quat.x * quat.x + quat.y * quat.y ) ); #else *yaw = atan2f( 2 * ( quat.w * quat.x + quat.y * quat.z ), 1 - 2 * ( quat.x * quat.x + quat.y * quat.y ) ); *pitch = asinf( 2 * ( quat.w * quat.y - quat.z * quat.x ) ); *roll = atan2f( 2 * ( quat.w * quat.z + quat.x * quat.y ), 1 - 2 * ( quat.y * quat.y + quat.z * quat.z ) ); #endif } else { Loading @@ -235,72 +230,6 @@ void Quat2Euler( return; } #ifdef FIX_I109_ORIENTATION_TRACKING /*------------------------------------------------------------------------- * Quat2Euler() * * Euler handling: calculate corresponding Quaternions *------------------------------------------------------------------------*/ void Euler2Quat( const float yaw, /* i : yaw */ const float pitch, /* i : pitch */ const float roll, /* i : roll */ Quaternion *quat /* o : quaternion describing the rotation */ ) { float cos_y_2, sin_y_2, cos_p_2, sin_p_2, cos_r_2, sin_r_2; cos_y_2 = cosf( yaw * 0.5f ); sin_y_2 = sinf( yaw * 0.5f ); cos_p_2 = cosf( pitch * 0.5f ); sin_p_2 = sinf( pitch * 0.5f ); cos_r_2 = cosf( roll * 0.5f ); sin_r_2 = sinf( roll * 0.5f ); quat->w = cos_y_2 * cos_p_2 * cos_r_2 + sin_y_2 * sin_p_2 * sin_r_2; quat->x = cos_y_2 * cos_p_2 * sin_r_2 - sin_y_2 * sin_p_2 * cos_r_2; quat->y = cos_y_2 * sin_p_2 * cos_r_2 + sin_y_2 * cos_p_2 * sin_r_2; quat->z = sin_y_2 * cos_p_2 * cos_r_2 - cos_y_2 * sin_p_2 * sin_r_2; return; } /*------------------------------------------------------------------------- * Quat2Euler() * * Euler handling: calculate rotation matrices in real-space and SHD *------------------------------------------------------------------------*/ void Euler2RotMat( const float yaw, /* i : yaw */ const float pitch, /* i : pitch */ const float roll, /* i : roll */ float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ ) { float c_1, c_2, c_3; float s_1, s_2, s_3; c_1 = cosf( yaw ); c_2 = cosf( pitch ); c_3 = cosf( roll ); s_1 = sinf( yaw ); s_2 = sinf( pitch ); s_3 = sinf( roll ); Rmat[0][0] = c_1 * c_2; Rmat[0][1] = c_1 * s_2 * s_3 - s_1 * c_3; Rmat[0][2] = c_1 * s_2 * c_3 + s_1 * s_3; Rmat[1][0] = s_1 * c_2; Rmat[1][1] = s_1 * s_2 * s_3 + c_1 * c_3; Rmat[1][2] = s_1 * s_2 * c_3 - c_1 * s_3; Rmat[2][0] = -s_2; Rmat[2][1] = c_2 * s_3; Rmat[2][2] = c_2 * c_3; } #endif /*------------------------------------------------------------------------- Loading Loading
lib_com/ivas_prot.h +4 −18 Original line number Diff line number Diff line Loading @@ -4556,27 +4556,13 @@ void QuatToRotMat( float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ ); #ifndef FIX_I109_ORIENTATION_TRACKING void Quat2Euler( const Quaternion quat, /* i : quaternion describing the rotation */ float *yaw, /* o : yaw */ float *pitch, /* o : pitch */ float *roll /* o : roll */ ); #ifdef FIX_I109_ORIENTATION_TRACKING void Euler2Quat( const float yaw, /* i : yaw */ const float pitch, /* i : pitch */ const float roll, /* i : roll */ Quaternion *quat /* o : quaternion describing the rotation */ ); void Euler2RotMat( const float yaw, /* i : yaw */ const float pitch, /* i : pitch */ const float roll, /* i : roll */ float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ ); #endif void rotateAziEle( Loading Loading @@ -5503,12 +5489,12 @@ void ivas_reverb_get_hrtf_set_properties( /* Orientation tracking */ void ivas_orient_trk_Init( ivas_orient_trk_state_t *pOTR ivas_orient_trk_state_t *pOTR /* i/o : orientation tracker handle */ ); ivas_error ivas_orient_trk_SetTrackingType( ivas_orient_trk_state_t *pOTR, OTR_TRACKING_T trackingType ivas_orient_trk_state_t *pOTR, /* i/o : orientation tracker handle */ OTR_TRACKING_T trackingType /* i : orientation tracking type */ ); #ifdef FIX_I109_ORIENTATION_TRACKING Loading
lib_dec/ivas_orient_trk.c +38 −13 Original line number Diff line number Diff line Loading @@ -53,11 +53,16 @@ /* TODO relate to frame rate - assumed here 50Hz, i.e. 20ms frame length */ #define OTR_UPDATE_RATE ( 50.0f ) /* rate of the Process() calls [Hz]; 1x per IVAS frame */ /*------------------------------------------------------------------------------------------* * Local functions *------------------------------------------------------------------------------------------*/ #ifdef FIX_I109_ORIENTATION_TRACKING /*------------------------------------------------------------------------------------------* * Declarations *------------------------------------------------------------------------------------------*/ void QuaternionProduct( const Quaternion q1, const Quaternion q2, Quaternion *const result ); float QuaternionDotProduct( const Quaternion q1, const Quaternion ); void QuaternionDivision( const Quaternion q, const float d, Quaternion *const result ); Loading @@ -81,6 +86,9 @@ void QuaternionProduct( *r = tmp; } /*------------------------------------------------------------------------------------------* * Quaternion dot product *------------------------------------------------------------------------------------------*/ float QuaternionDotProduct( const Quaternion q1, const Quaternion q2 ) Loading @@ -88,6 +96,9 @@ float QuaternionDotProduct( return q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w; } /*------------------------------------------------------------------------------------------* * Divides a quaternion by a scalar *------------------------------------------------------------------------------------------*/ void QuaternionDivision( const Quaternion q, const float d, Loading @@ -99,6 +110,9 @@ void QuaternionDivision( r->z = q.z / d; } /*------------------------------------------------------------------------------------------* * Normalizes a quaternion *------------------------------------------------------------------------------------------*/ void QuaternionNormalize( const Quaternion q, Quaternion *const r ) Loading @@ -106,6 +120,9 @@ void QuaternionNormalize( QuaternionDivision( q, sqrtf( QuaternionDotProduct( q, q ) ), r ); } /*------------------------------------------------------------------------------------------* * Computes a spherical linear interpolation between two quaternions *------------------------------------------------------------------------------------------*/ void QuaternionSlerp( const Quaternion q1, const Quaternion q2, Loading @@ -122,7 +139,7 @@ void QuaternionSlerp( angle = acosf( s ); denom = sinf( angle ); s = sinf( 1 - t ) * angle; s = sinf( ( 1 - t ) * angle ); s2 = sinf( t * angle ); r->x = ( q1.x * s + q2.x * s2 ) / denom; r->y = ( q1.y * s + q2.y * s2 ) / denom; Loading @@ -132,6 +149,9 @@ void QuaternionSlerp( QuaternionNormalize( *r, r ); } /*------------------------------------------------------------------------------------------* * Computes a quaternion conjugate *------------------------------------------------------------------------------------------*/ void QuaternionConjugate( const Quaternion q, Quaternion *const r ) Loading @@ -142,6 +162,9 @@ void QuaternionConjugate( r->z = -q.z; } /*------------------------------------------------------------------------------------------* * Computes an angle between two quaternions *------------------------------------------------------------------------------------------*/ float QuaternionAngle( const Quaternion q1, const Quaternion q2 ) Loading @@ -154,6 +177,9 @@ float QuaternionAngle( return angle; } /*------------------------------------------------------------------------------------------* * Computes an inverse quaternion *------------------------------------------------------------------------------------------*/ void QuaternionInverse( const Quaternion q, Quaternion *const r ) Loading Loading @@ -212,7 +238,7 @@ static float ClipAngle( *-------------------------------------------------------------------*/ void ivas_orient_trk_Init( ivas_orient_trk_state_t *pOTR ) ivas_orient_trk_state_t *pOTR ) /* i/o : orientation tracker handle */ { /* Track relative to a reference orientation */ pOTR->trackingType = OTR_TRACKING_REF_ORIENT; Loading Loading @@ -251,6 +277,7 @@ void ivas_orient_trk_Init( #endif } /*-------------------------------------------------------------------* * ivas_orient_trk_SetTrackingType() * Loading @@ -258,15 +285,14 @@ void ivas_orient_trk_Init( *-------------------------------------------------------------------*/ ivas_error ivas_orient_trk_SetTrackingType( ivas_orient_trk_state_t *pOTR, OTR_TRACKING_T trackingType ) ivas_orient_trk_state_t *pOTR, /* i/o : orientation tracker handle */ OTR_TRACKING_T trackingType ) /* i/o : orientation tracking type */ { pOTR->trackingType = trackingType; return IVAS_ERR_OK; } #ifdef FIX_I109_ORIENTATION_TRACKING #else #ifndef FIX_I109_ORIENTATION_TRACKING /*-------------------------------------------------------------------* * ivas_orient_trk_SetAbsoluteOrientation() * Loading Loading @@ -296,10 +322,10 @@ ivas_error ivas_orient_trk_SetAbsoluteOrientation( #ifdef FIX_I109_ORIENTATION_TRACKING ivas_error ivas_orient_trk_Process( ivas_orient_trk_state_t *pOTR, Quaternion absRot, float updateRate, Quaternion *pTrkRot ) ivas_orient_trk_state_t *pOTR, /* i/o : orientation tracker handle */ Quaternion absRot, /* i : absolute head rotation */ float updateRate, /* i : rotation update rate [Hz] */ Quaternion *pTrkRot ) /* o : tracked rotation */ { float normalizedOrientation; float relativeOrientationRate; Loading @@ -307,7 +333,6 @@ ivas_error ivas_orient_trk_Process( float cutoffFrequency; float alpha = pOTR->alpha; float ang; Quaternion tq; if ( pOTR->trackingType == OTR_TRACKING_AVG_ORIENT ) { Loading Loading @@ -482,8 +507,7 @@ ivas_error ivas_orient_trk_Process( return IVAS_ERR_OK; } #ifdef FIX_I109_ORIENTATION_TRACKING #else #ifndef FIX_I109_ORIENTATION_TRACKING /*-------------------------------------------------------------------* * ivas_orient_trk_GetTrackedOrientation() * Loading @@ -499,6 +523,7 @@ ivas_error ivas_orient_trk_GetTrackedOrientation( *yaw = pOTR->trkYaw; *pitch = pOTR->trkPitch; *roll = pOTR->trkRoll; return IVAS_ERR_OK; } #endif
lib_dec/ivas_rotation.c +2 −73 Original line number Diff line number Diff line Loading @@ -105,7 +105,7 @@ ivas_error ivas_headTrack_open( #ifdef FIX_I109_ORIENTATION_TRACKING /*-----------------------------------------------------------------------* * ivas_headTrack_closes() * ivas_headTrack_close() * * Deallocate Head-Tracking handle *-----------------------------------------------------------------------*/ Loading Loading @@ -195,6 +195,7 @@ void QuatToRotMat( return; } #ifndef FIX_I109_ORIENTATION_TRACKING /*------------------------------------------------------------------------- * Quat2Euler() * Loading @@ -210,15 +211,9 @@ void Quat2Euler( { if ( quat.w != -3.0 ) { #ifdef FIX_I109_ORIENTATION_TRACKING *yaw = atan2f( 2.0f * ( quat.w * quat.z + quat.x * quat.y ), 1.0f - 2.0f * ( quat.y * quat.y + quat.z * quat.z ) ); *pitch = asinf( 2.0f * ( quat.w * quat.y - quat.z * quat.x ) ); *roll = atan2f( 2.0f * ( quat.w * quat.x + quat.y * quat.z ), 1.0f - 2.0f * ( quat.x * quat.x + quat.y * quat.y ) ); #else *yaw = atan2f( 2 * ( quat.w * quat.x + quat.y * quat.z ), 1 - 2 * ( quat.x * quat.x + quat.y * quat.y ) ); *pitch = asinf( 2 * ( quat.w * quat.y - quat.z * quat.x ) ); *roll = atan2f( 2 * ( quat.w * quat.z + quat.x * quat.y ), 1 - 2 * ( quat.y * quat.y + quat.z * quat.z ) ); #endif } else { Loading @@ -235,72 +230,6 @@ void Quat2Euler( return; } #ifdef FIX_I109_ORIENTATION_TRACKING /*------------------------------------------------------------------------- * Quat2Euler() * * Euler handling: calculate corresponding Quaternions *------------------------------------------------------------------------*/ void Euler2Quat( const float yaw, /* i : yaw */ const float pitch, /* i : pitch */ const float roll, /* i : roll */ Quaternion *quat /* o : quaternion describing the rotation */ ) { float cos_y_2, sin_y_2, cos_p_2, sin_p_2, cos_r_2, sin_r_2; cos_y_2 = cosf( yaw * 0.5f ); sin_y_2 = sinf( yaw * 0.5f ); cos_p_2 = cosf( pitch * 0.5f ); sin_p_2 = sinf( pitch * 0.5f ); cos_r_2 = cosf( roll * 0.5f ); sin_r_2 = sinf( roll * 0.5f ); quat->w = cos_y_2 * cos_p_2 * cos_r_2 + sin_y_2 * sin_p_2 * sin_r_2; quat->x = cos_y_2 * cos_p_2 * sin_r_2 - sin_y_2 * sin_p_2 * cos_r_2; quat->y = cos_y_2 * sin_p_2 * cos_r_2 + sin_y_2 * cos_p_2 * sin_r_2; quat->z = sin_y_2 * cos_p_2 * cos_r_2 - cos_y_2 * sin_p_2 * sin_r_2; return; } /*------------------------------------------------------------------------- * Quat2Euler() * * Euler handling: calculate rotation matrices in real-space and SHD *------------------------------------------------------------------------*/ void Euler2RotMat( const float yaw, /* i : yaw */ const float pitch, /* i : pitch */ const float roll, /* i : roll */ float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ ) { float c_1, c_2, c_3; float s_1, s_2, s_3; c_1 = cosf( yaw ); c_2 = cosf( pitch ); c_3 = cosf( roll ); s_1 = sinf( yaw ); s_2 = sinf( pitch ); s_3 = sinf( roll ); Rmat[0][0] = c_1 * c_2; Rmat[0][1] = c_1 * s_2 * s_3 - s_1 * c_3; Rmat[0][2] = c_1 * s_2 * c_3 + s_1 * s_3; Rmat[1][0] = s_1 * c_2; Rmat[1][1] = s_1 * s_2 * s_3 + c_1 * c_3; Rmat[1][2] = s_1 * s_2 * c_3 - c_1 * s_3; Rmat[2][0] = -s_2; Rmat[2][1] = c_2 * s_3; Rmat[2][2] = c_2 * c_3; } #endif /*------------------------------------------------------------------------- Loading