43 *phRot = (
void*)pData;
88 pData->
fs = sampleRate;
104 const float *
const * inputs,
105 float*
const*
const outputs,
112 int i, j, order, nSH, mixWithPreviousFLAG;
125 for(i=0; i <
SAF_MIN(nSH, nInputs); i++)
138 mixWithPreviousFLAG = 0;
154 pData->
M_rot[i][j] = M_rot_tmp[i*nSH+j];
155 mixWithPreviousFLAG = 1;
160 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, nSH,
ROTATOR_FRAME_SIZE, nSH, 1.0f,
166 if(mixWithPreviousFLAG){
167 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, nSH,
ROTATOR_FRAME_SIZE, nSH, 1.0f,
173 for (i=0; i < nSH; i++){
197 for (i = 0; i <
SAF_MIN(nSH, nOutputs); i++)
199 for (; i < nOutputs; i++)
203 for (i = 0; i < nOutputs; i++)
235 pData->
Q.
w = newValue;
419 return (
int)pData->
norm;
NORM_TYPES
Available Ambisonic normalisation conventions.
@ NORM_SN3D
Schmidt semi-normalisation (SN3D)
@ NORM_FUMA
(Legacy) Furse-Malham scaling
CH_ORDER
Available Ambisonic channel ordering conventions.
@ CH_ACN
Ambisonic Channel Numbering (ACN)
@ CH_FUMA
(Legacy) Furse-Malham/B-format (WXYZ)
#define MAX_NUM_SH_SIGNALS
Maximum number of spherical harmonic components/signals supported.
SH_ORDERS
Available spherical harmonic (SH) input/output order options.
@ SH_ORDER_FIRST
First-order (4 channels)
void convertHOAChannelConvention(float *insig, int order, int signalLength, HOA_CH_ORDER inConvention, HOA_CH_ORDER outConvention)
Converts an Ambisonic signal from one channel ordering convention to another.
@ HOA_CH_ORDER_FUMA
Furse-Malham (FuMa) convention, often used by older recordings.
@ HOA_CH_ORDER_ACN
Ambisonic Channel numbering (ACN) convention, which is employed by all spherical harmonic related fun...
#define ORDER2NSH(order)
Converts spherical harmonic order to number of spherical harmonic components i.e: (order+1)^2.
void getSHrotMtxReal(float Rxyz[3][3], float *RotMtx, int L)
Generates a real-valued spherical harmonic rotation matrix [1] based on a 3x3 rotation matrix (see qu...
void utility_svvmul(const float *a, const float *b, const int len, float *c)
Single-precision, element-wise vector-vector multiplication i.e.
#define DEG2RAD(x)
Converts degrees to radians.
void quaternion2rotationMatrix(quaternion_data *Q, float R[3][3])
Constructs a 3x3 rotation matrix based on a quaternion.
void euler2Quaternion(float alpha, float beta, float gamma, int degreesFlag, EULER_ROTATION_CONVENTIONS convention, quaternion_data *Q)
Converts Euler angles to a quaternion.
void quaternion2euler(quaternion_data *Q, int degreesFlag, EULER_ROTATION_CONVENTIONS convention, float *alpha, float *beta, float *gamma)
Converts a quaternion to Euler angles.
void utility_svvcopy(const float *a, const int len, float *c)
Single-precision, vector-vector copy, i.e.
#define SAF_MIN(a, b)
Returns the minimum of the two values.
void yawPitchRoll2Rzyx(float yaw, float pitch, float roll, int rollPitchYawFLAG, float R[3][3])
Constructs a 3x3 rotation matrix from the Euler angles, using the yaw-pitch-roll (zyx) convention.
#define RAD2DEG(x)
Converts radians to degrees
@ EULER_ROTATION_YAW_PITCH_ROLL
yaw-pitch-roll, 'zyx'
@ EULER_ROTATION_ROLL_PITCH_YAW
roll-pitch-yaw, 'xyz'
void * malloc1d(size_t dim1_data_size)
1-D malloc (same as malloc, but with error checking)
void rotator_setQuaternionW(void *const hRot, float newValue)
Sets the quaternion 'W' value [-1..1].
int rotator_getRPYflag(void *const hRot)
Returns a flag as to whether to use "yaw-pitch-roll" (0) or "roll-pitch-yaw" (1) rotation order.
int rotator_getNSHrequired(void *const hRot)
Returns the number of spherical harmonic signals required by the current input/output order: (current...
int rotator_getFrameSize(void)
Returns the processing framesize (i.e., number of samples processed with every _process() call )
int rotator_getNormType(void *const hRot)
Returns the Ambisonic normalisation convention currently being usedto decode with,...
void rotator_setPitch(void *const hRot, float newPitch)
Sets the 'pitch' rotation angle, in DEGREES.
float rotator_getQuaternionY(void *const hRot)
Returns the quaternion 'Y' value [-1..1].
void rotator_setFlipPitch(void *const hRot, int newState)
Sets a flag as to whether to "flip" the sign of the current 'pitch' angle (0: do not flip sign,...
void rotator_create(void **const phRot)
Creates an instance of rotator.
int rotator_getProcessingDelay()
Returns the processing delay in samples (may be used for delay compensation features)
void rotator_setFlipRoll(void *const hRot, int newState)
Sets a flag as to whether to "flip" the sign of the current 'roll' angle (0: do not flip sign,...
float rotator_getQuaternionW(void *const hRot)
Returns the quaternion 'W' value [-1..1].
int rotator_getFlipRoll(void *const hRot)
Returns a flag as to whether to "flip" the sign of the current 'roll' angle (0: do not flip sign,...
void rotator_setRPYflag(void *const hRot, int newState)
Sets a flag as to whether to use "yaw-pitch-roll" (0) or "roll-pitch-yaw" (1) rotation order.
float rotator_getQuaternionZ(void *const hRot)
Returns the quaternion 'Z' value [-1..1].
float rotator_getPitch(void *const hRot)
Returns the 'pitch' rotation angle, in DEGREES.
int rotator_getChOrder(void *const hRot)
Returns the Ambisonic channel ordering convention currently being used to decode with,...
void rotator_destroy(void **const phRot)
Destroys an instance of rotator.
void rotator_setQuaternionZ(void *const hRot, float newValue)
Sets the quaternion 'Z' value [-1..1].
float rotator_getYaw(void *const hRot)
Returns the 'yaw' rotation angle, in DEGREES.
void rotator_process(void *const hRot, const float *const *inputs, float *const *const outputs, int nInputs, int nOutputs, int nSamples)
Rotates the input spherical harmonic signals.
int rotator_getOrder(void *const hRot)
Returns the input/output order (see SH_ORDERS enum)
int rotator_getFlipYaw(void *const hRot)
Returns a flag as to whether to "flip" the sign of the current 'yaw' angle (0: do not flip sign,...
void rotator_setRoll(void *const hRot, float newRoll)
Sets the 'roll' rotation angle , in DEGREES.
float rotator_getRoll(void *const hRot)
Returns the 'roll' rotation angle, in DEGREES.
int rotator_getFlipQuaternion(void *const hRot)
Returns a flag as to whether to invert the quaternion used for rotation (0: do not flip sign,...
void rotator_setQuaternionX(void *const hRot, float newValue)
Sets the quaternion 'X' value [-1..1].
void rotator_init(void *const hRot, int sampleRate)
Initialises an instance of rotator with default settings.
void rotator_setNormType(void *const hRot, int newType)
Sets the Ambisonic normalisation convention to decode with, in order to match with the convention emp...
void rotator_setChOrder(void *const hRot, int newOrder)
Sets the Ambisonic channel ordering convention to decode with, in order to match the convention emplo...
float rotator_getQuaternionX(void *const hRot)
Returns the quaternion 'X' value [-1..1].
void rotator_setFlipYaw(void *const hRot, int newState)
Sets a flag as to whether to "flip" the sign of the current 'yaw' angle (0: do not flip sign,...
void rotator_setQuaternionY(void *const hRot, float newValue)
Sets the quaternion 'Y' value [-1..1].
int rotator_getFlipPitch(void *const hRot)
Returns a flag as to whether to "flip" the sign of the current 'pitch' angle (0: do not flip sign,...
void rotator_setYaw(void *const hRot, float newYaw)
Sets the 'yaw' rotation angle, in DEGREES.
void rotator_setFlipQuaternion(void *const hRot, int newState)
Sets a flag as to whether to invert the quaternion used for rotation (0: do not flip sign,...
void rotator_setOrder(void *const hRot, int newOrder)
Sets the input/output order (see SH_ORDERS enum)
A basic spherical harmonic/ Ambisonic signals rotator, based on the recursive approach detailed in [1...
A basic spherical harmonic/ Ambisonic signals rotator, based on the recursive approach detailed in [1...
@ M_ROT_READY
M_rot is ready.
@ M_ROT_RECOMPUTE_QUATERNION
Use Quaternions to recompute M_rot.
@ M_ROT_RECOMPUTE_EULER
Use Euler angles to recompute M_rot.
#define ROTATOR_FRAME_SIZE
Framesize, in time-domain samples.
float x
X value of the quaternion [-1..1].
float z
Z value of the quaternion [-1..1].
float y
Y value of the quaternion [-1..1].
float w
W value of the quaternion [-1..1].
Main struct for the rotator.
float tempFrame_fadeOut[MAX_NUM_SH_SIGNALS][ROTATOR_FRAME_SIZE]
Temporary frame with linear interpolation (fade-out) applied.
float pitch
pitch (Euler) rotation angle, in degrees
int bFlipRoll
flag to flip the sign of the roll rotation angle
float M_rot[MAX_NUM_SH_SIGNALS][MAX_NUM_SH_SIGNALS]
Current SH rotation matrix [1].
int useRollPitchYawFlag
rotation order flag, 1: r-p-y, 0: y-p-r
M_ROT_STATUS M_rot_status
see M_ROT_STATUS
NORM_TYPES norm
Ambisonic normalisation convention (see NORM_TYPES)
float outputFrameTD_fadeIn[MAX_NUM_SH_SIGNALS][ROTATOR_FRAME_SIZE]
Output frame of SH signals with linear interpolation (fade-in) applied.
float prev_inputFrameTD[MAX_NUM_SH_SIGNALS][ROTATOR_FRAME_SIZE]
Previous frame of signals.
float interpolator_fadeOut[ROTATOR_FRAME_SIZE]
Linear Interpolator (fade-out)
float inputFrameTD[MAX_NUM_SH_SIGNALS][ROTATOR_FRAME_SIZE]
Input frame of signals.
float roll
roll (Euler) rotation angle, in degrees
SH_ORDERS inputOrder
current input/output SH order
int bFlipQuaternion
1: invert quaternion, 0: no inversion
float yaw
yaw (Euler) rotation angle, in degrees
int bFlipYaw
flag to flip the sign of the yaw rotation angle
int fs
Host sampling rate, in Hz.
quaternion_data Q
Quaternion used for rotation.
CH_ORDER chOrdering
Ambisonic channel order convention (see CH_ORDER)
float prev_M_rot[MAX_NUM_SH_SIGNALS][MAX_NUM_SH_SIGNALS]
Previous SH rotation matrix [1].
float interpolator_fadeIn[ROTATOR_FRAME_SIZE]
Linear Interpolator (fade-in)
float outputFrameTD[MAX_NUM_SH_SIGNALS][ROTATOR_FRAME_SIZE]
Output frame of SH signals.
float tempFrame[MAX_NUM_SH_SIGNALS][ROTATOR_FRAME_SIZE]
Temporary frame.
int bFlipPitch
flag to flip the sign of the pitch rotation angle