SAF
Loading...
Searching...
No Matches
rotator_internal.h
Go to the documentation of this file.
1/*
2 * Copyright 2017-2018 Leo McCormack
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 * PERFORMANCE OF THIS SOFTWARE.
15 */
16
33
34#ifndef __ROTATOR_INTERNAL_H_INCLUDED__
35#define __ROTATOR_INTERNAL_H_INCLUDED__
36
37#include "rotator.h" /* Include header for this example */
38#include "saf.h" /* Main include header for SAF */
39#include "saf_externals.h" /* To also include SAF dependencies (cblas etc.) */
40
41#ifdef __cplusplus
42extern "C" {
43#endif /* __cplusplus */
44
45/* ========================================================================== */
46/* Internal Parameters */
47/* ========================================================================== */
48
49#if !defined(ROTATOR_FRAME_SIZE)
50# if defined(FRAME_SIZE) /* Use the global framesize if it is specified: */
51# define ROTATOR_FRAME_SIZE ( FRAME_SIZE )
52# else /* Otherwise, the default framesize for this example is: */
53# define ROTATOR_FRAME_SIZE ( 64 )
54# endif
55#endif
56
57/* ========================================================================== */
58/* Structures */
59/* ========================================================================== */
60
67
68#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__)
69 typedef _Atomic M_ROT_STATUS _Atomic_M_ROT_STATUS;
70#else
71 typedef M_ROT_STATUS _Atomic_M_ROT_STATUS;
72#endif
73
75typedef struct _rotator
76{
77 /* Internal buffers */
83
84 /* Internal variables */
89 _Atomic_M_ROT_STATUS M_rot_status;
90 int fs;
91
92 /* user parameters */
94 _Atomic_INT32 bFlipQuaternion;
95 _Atomic_FLOAT32 yaw;
96 _Atomic_FLOAT32 roll;
97 _Atomic_FLOAT32 pitch;
98 _Atomic_INT32 bFlipYaw;
99 _Atomic_INT32 bFlipPitch;
100 _Atomic_INT32 bFlipRoll;
101 _Atomic_INT32 useRollPitchYawFlag;
102 _Atomic_CH_ORDER chOrdering;
103 _Atomic_NORM_TYPES norm;
104 _Atomic_SH_ORDERS inputOrder;
105
107
108
109#ifdef __cplusplus
110} /* extern "C" { */
111#endif /* __cplusplus */
112
113#endif /* __ROTATOR_INTERNAL_H_INCLUDED__ */
#define MAX_NUM_SH_SIGNALS
Maximum number of spherical harmonic components/signals supported.
Definition _common.h:243
A basic spherical harmonic/ Ambisonic signals rotator, based on the recursive approach detailed in [1...
M_ROT_STATUS
Available Ambisonic channel ordering conventions.
@ 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.
Main include header for the Spatial_Audio_Framework (SAF)
Include header for SAF externals.
Quaternion data structure.
Main struct for the rotator.
float tempFrame_fadeOut[MAX_NUM_SH_SIGNALS][ROTATOR_FRAME_SIZE]
Temporary frame with linear interpolation (fade-out) applied.
_Atomic_INT32 bFlipYaw
flag to flip the sign of the yaw rotation angle
_Atomic_INT32 useRollPitchYawFlag
rotation order flag, 1: r-p-y, 0: y-p-r
float M_rot[MAX_NUM_SH_SIGNALS][MAX_NUM_SH_SIGNALS]
Current SH rotation matrix [1].
float outputFrameTD_fadeIn[MAX_NUM_SH_SIGNALS][ROTATOR_FRAME_SIZE]
Output frame of SH signals with linear interpolation (fade-in) applied.
_Atomic_FLOAT32 roll
roll (Euler) rotation angle, in degrees
float interpolator_fadeOut[ROTATOR_FRAME_SIZE]
Linear Interpolator (fade-out)
_Atomic_FLOAT32 yaw
yaw (Euler) rotation angle, in degrees
float inputFrameTD[MAX_NUM_SH_SIGNALS][ROTATOR_FRAME_SIZE]
Input frame of signals.
_Atomic_CH_ORDER chOrdering
Ambisonic channel order convention (see CH_ORDER)
int fs
Host sampling rate, in Hz.
_Atomic_SH_ORDERS inputOrder
current input/output SH order
quaternion_data Q
Quaternion used for rotation.
_Atomic_M_ROT_STATUS M_rot_status
see M_ROT_STATUS
_Atomic_INT32 bFlipQuaternion
1: invert quaternion, 0: no inversion
float prev_M_rot[MAX_NUM_SH_SIGNALS][MAX_NUM_SH_SIGNALS]
Previous SH rotation matrix [1].
_Atomic_INT32 bFlipPitch
flag to flip the sign of the pitch rotation angle
float interpolator_fadeIn[ROTATOR_FRAME_SIZE]
Linear Interpolator (fade-in)
_Atomic_INT32 bFlipRoll
flag to flip the sign of the roll rotation angle
float outputFrameTD[MAX_NUM_SH_SIGNALS][ROTATOR_FRAME_SIZE]
Output frame of SH signals.
_Atomic_FLOAT32 pitch
pitch (Euler) rotation angle, in degrees
_Atomic_NORM_TYPES norm
Ambisonic normalisation convention (see NORM_TYPES)
float tempFrame[MAX_NUM_SH_SIGNALS][ROTATOR_FRAME_SIZE]
Temporary frame.