aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormusil <tmusil@users.sourceforge.net>2006-11-10 14:31:45 +0000
committermusil <tmusil@users.sourceforge.net>2006-11-10 14:31:45 +0000
commit4902bb3bd0bba7839921baa099abe311f2e9391d (patch)
tree21f625ad1cd7198019c4e5d1fa74c9a7a63088dc
parentb7b733fcdb95dea0537f5db87b7917c293c5e30a (diff)
makefile fno-strict-aliasing bug
float to t_float svn path=/trunk/externals/iem/iem_ambi/; revision=6256
-rw-r--r--src/ambi_decode.c16
-rw-r--r--src/ambi_decode2.c17
-rw-r--r--src/ambi_decode3.c32
-rw-r--r--src/ambi_decode_cube.c26
-rw-r--r--src/ambi_encode.c746
-rw-r--r--src/ambi_rot.c2966
-rw-r--r--src/iem_ambi.c6
-rw-r--r--src/iemlib.h8
-rw-r--r--src/makefile2
-rw-r--r--src/makefile_linux51
10 files changed, 1927 insertions, 1943 deletions
diff --git a/src/ambi_decode.c b/src/ambi_decode.c
index 466244f..1481be3 100644
--- a/src/ambi_decode.c
+++ b/src/ambi_decode.c
@@ -3,19 +3,9 @@
iem_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include <math.h>
-#include <stdio.h>
-#include <string.h>
-
-
/* -------------------------- ambi_decode ------------------------------ */
/*
@@ -325,7 +315,7 @@ static void ambi_decode_pinv(t_ambi_decode *x)
at += 2;
for(i=0; i<n; i++)
{
- SETFLOAT(at, (float)(*dv));
+ SETFLOAT(at, (t_float)(*dv));
dv++;
at++;
}
@@ -690,8 +680,8 @@ static void *ambi_decode_new(t_symbol *s, int argc, t_atom *argv)
x->x_at = (t_atom *)getbytes((x->x_n_ls * x->x_n_ambi + 2) * sizeof(t_atom));
x->x_s_matrix = gensym("matrix");
/*change*/
- SETFLOAT(x->x_at, (float)x->x_n_ls);
- SETFLOAT(x->x_at+1, (float)x->x_n_ambi);
+ SETFLOAT(x->x_at, (t_float)x->x_n_ls);
+ SETFLOAT(x->x_at+1, (t_float)x->x_n_ambi);
x->x_sqrt3 = sqrt(3.0);
x->x_sqrt5_2 = sqrt(5.0) / 2.0;
x->x_sqrt6_4 = sqrt(6.0) / 4.0;
diff --git a/src/ambi_decode2.c b/src/ambi_decode2.c
index bebb10b..643e0b4 100644
--- a/src/ambi_decode2.c
+++ b/src/ambi_decode2.c
@@ -3,19 +3,10 @@
iem_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_ambi.h"
#include <math.h>
-#include <stdio.h>
-#include <string.h>
-
/* -------------------------- ambi_decode2 ------------------------------ */
@@ -331,7 +322,7 @@ static void ambi_decode2_pseudo_inverse(t_ambi_decode2 *x, t_symbol *s, int argc
at += 2;
for(i=0; i<n; i++)
{
- SETFLOAT(at, (float)(*dv1));
+ SETFLOAT(at, (t_float)(*dv1));
dv1++;
at++;
}
@@ -341,7 +332,7 @@ static void ambi_decode2_pseudo_inverse(t_ambi_decode2 *x, t_symbol *s, int argc
dv2 += n;
for(i=0; i<n; i++)
{
- SETFLOAT(at, (float)(*dv1 + *dv2*mw));
+ SETFLOAT(at, (t_float)(*dv1 + *dv2*mw));
dv1++;
dv2++;
at++;
@@ -780,8 +771,8 @@ static void *ambi_decode2_new(t_symbol *s, int argc, t_atom *argv)
x->x_at = (t_atom *)getbytes(((x->x_n_ls+x->x_n_mir_ls) * x->x_n_ambi + 2) * sizeof(t_atom));
x->x_s_matrix = gensym("matrix");
/*change*/
- SETFLOAT(x->x_at, (float)(x->x_n_ls+x->x_n_mir_ls));
- SETFLOAT(x->x_at+1, (float)x->x_n_ambi);
+ SETFLOAT(x->x_at, (t_float)(x->x_n_ls+x->x_n_mir_ls));
+ SETFLOAT(x->x_at+1, (t_float)x->x_n_ambi);
x->x_mirror_weight = 0.0;
x->x_sqrt3 = sqrt(3.0);
diff --git a/src/ambi_decode3.c b/src/ambi_decode3.c
index ae8740a..b29d1b6 100644
--- a/src/ambi_decode3.c
+++ b/src/ambi_decode3.c
@@ -3,35 +3,15 @@
iem_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_ambi.h"
#include <math.h>
-#include <stdio.h>
-#include <string.h>
-
/* -------------------------- ambi_decode3 ------------------------------ */
/*
- ** berechnet ein reduziertes Ambisonic-Decoder-Set in die HRTF-Spektren **
- ** Inputs: ls + Liste von 3 floats: Index [1 .. 25] + Elevation [-90 .. +90 degree] + Azimut [0 .. 360 degree] **
- ** Inputs: calc_inv **
- ** Inputs: load_HRIR + float index1..25 **
- ** Outputs: List of 2 symbols: left-HRIR-File-name + HRIR-table-name **
- ** Inputs: calc_reduced **
- ** "output" ... writes the HRTF into tables **
- ** **
- ** **
- ** setzt voraus , dass die HRIR-tabele-names von LS1_L_HRIR .. LS25_L_HRIR heissen und existieren **
- ** setzt voraus , dass die HRTF-tabele-names von LS1_HRTF_re .. LS25_HRTF_re heissen und existieren **
- ** setzt voraus , dass die HRTF-tabele-names von LS1_HRTF_im .. LS25_HRTF_im heissen und existieren **
+
*/
typedef struct _ambi_decode3
@@ -326,7 +306,7 @@ static void ambi_decode3_begin_pseudo_inverse(t_ambi_decode3 *x)
at += 2;
for(i=0; i<n; i++)
{
- SETFLOAT(at, (float)(*dv1));
+ SETFLOAT(at, (t_float)(*dv1));
dv1++;
at++;
}
@@ -338,7 +318,7 @@ static void ambi_decode3_ipht_ireal_muladd(t_ambi_decode3 *x, t_symbol *s, int a
int i, n=x->x_n_ambi;
int pht_index, real_index;
double mw;
- float dat1;
+ t_float dat1;
double *dv2=x->x_prod;
if(argc < 3)
@@ -364,7 +344,7 @@ static void ambi_decode3_ipht_ireal_muladd(t_ambi_decode3 *x, t_symbol *s, int a
for(i=0; i<n; i++)
{
dat1 = atom_getfloat(at);
- SETFLOAT(at, dat1 + (float)(*dv2*mw));
+ SETFLOAT(at, dat1 + (t_float)(*dv2*mw));
dv2++;
at++;
}
@@ -730,8 +710,8 @@ static void *ambi_decode3_new(t_symbol *s, int argc, t_atom *argv)
x->x_at = (t_atom *)getbytes((x->x_n_real_ls * x->x_n_ambi + 2) * sizeof(t_atom));
x->x_s_matrix = gensym("matrix");
/*change*/
- SETFLOAT(x->x_at, (float)x->x_n_real_ls);
- SETFLOAT(x->x_at+1, (float)x->x_n_ambi);
+ SETFLOAT(x->x_at, (t_float)x->x_n_real_ls);
+ SETFLOAT(x->x_at+1, (t_float)x->x_n_ambi);
x->x_sqrt3 = sqrt(3.0);
x->x_sqrt5_2 = sqrt(5.0) / 2.0;
diff --git a/src/ambi_decode_cube.c b/src/ambi_decode_cube.c
index 8e0d643..154eab7 100644
--- a/src/ambi_decode_cube.c
+++ b/src/ambi_decode_cube.c
@@ -3,19 +3,9 @@
iem_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include <math.h>
-#include <stdio.h>
-#include <string.h>
-
-
/* -------------------------- ambi_decode_cube ------------------------------ */
/*
@@ -338,13 +328,13 @@ static void ambi_decode_cube_pinv(t_ambi_decode_cube *x)
n = x->x_mirrorsum_beg*x->x_n_ambi;
real=x->x_prod;
- SETFLOAT(at, (float)x->x_n_ambi);
+ SETFLOAT(at, (t_float)x->x_n_ambi);
at++;
- SETFLOAT(at, (float)x->x_mirrorsum_beg);
+ SETFLOAT(at, (t_float)x->x_mirrorsum_beg);
at++;
for(i=0; i<n; i++)
{
- SETFLOAT(at, (float)(*real));
+ SETFLOAT(at, (t_float)(*real));
real++;
at++;
}
@@ -356,13 +346,13 @@ static void ambi_decode_cube_pinv(t_ambi_decode_cube *x)
double *dv=x->x_prod;
// post("real");
- SETFLOAT(at, (float)x->x_n_ambi);
+ SETFLOAT(at, (t_float)x->x_n_ambi);
at++;
- SETFLOAT(at, (float)x->x_n_ls);
+ SETFLOAT(at, (t_float)x->x_n_ls);
at++;
for(i=0; i<n; i++)
{
- SETFLOAT(at, (float)(*dv));
+ SETFLOAT(at, (t_float)(*dv));
dv++;
at++;
}
@@ -759,8 +749,8 @@ static void *ambi_decode_cube_new(t_symbol *s, int argc, t_atom *argv)
x->x_at = (t_atom *)getbytes((x->x_n_ls * x->x_n_ambi + 2) * sizeof(t_atom));
x->x_s_matrix = gensym("matrix");
/*change*/
- SETFLOAT(x->x_at, (float)x->x_n_ls);
- SETFLOAT(x->x_at+1, (float)x->x_n_ambi);
+ SETFLOAT(x->x_at, (t_float)x->x_n_ls);
+ SETFLOAT(x->x_at+1, (t_float)x->x_n_ambi);
x->x_sqrt3 = sqrt(3.0);
x->x_sqrt5_2 = sqrt(5.0) / 2.0;
x->x_sqrt6_4 = sqrt(6.0) / 4.0;
diff --git a/src/ambi_encode.c b/src/ambi_encode.c
index c4b9f0f..8dd9fe0 100644
--- a/src/ambi_encode.c
+++ b/src/ambi_encode.c
@@ -3,431 +3,423 @@
iem_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include <math.h>
-#include <stdio.h>
-#include <string.h>
/* -------------------------- ambi_encode ------------------------------ */
typedef struct _ambi_encode
{
- t_object x_obj;
- t_atom *x_at;
- int x_size;
- int x_size2d;
- int x_size3d;
- float x_sqrt3;
- float x_sqrt10_4;
- float x_sqrt15;
- float x_sqrt6_4;
- float x_sqrt35_2;
- float x_sqrt70_4;
- float x_sqrt5_2;
- float x_sqrt126_16;
- float x_sqrt315_2;
- float x_sqrt105_2;
- float x_pi_over_180;
- float *x_ambi_order_weight;
- int x_colrow;
- int x_n_order;
+ t_object x_obj;
+ t_atom *x_at;
+ int x_size;
+ int x_size2d;
+ int x_size3d;
+ t_float x_sqrt3;
+ t_float x_sqrt10_4;
+ t_float x_sqrt15;
+ t_float x_sqrt6_4;
+ t_float x_sqrt35_2;
+ t_float x_sqrt70_4;
+ t_float x_sqrt5_2;
+ t_float x_sqrt126_16;
+ t_float x_sqrt315_2;
+ t_float x_sqrt105_2;
+ t_float x_pi_over_180;
+ t_float *x_ambi_order_weight;
+ int x_colrow;
+ int x_n_order;
} t_ambi_encode;
static t_class *ambi_encode_class;
static void ambi_encode_ambi_weight(t_ambi_encode *x, t_symbol *s, int argc, t_atom *argv)
{
- if(argc > x->x_n_order)
- {
- int i, n=x->x_n_order;
-
- for(i=0; i<=n; i++)
- {
- x->x_ambi_order_weight[i] = atom_getfloat(argv++);
- }
- }
- else
- post("ambi_encode-ERROR: ambi_weight needs %d float weights", x->x_n_order+1);
+ if(argc > x->x_n_order)
+ {
+ int i, n=x->x_n_order;
+
+ for(i=0; i<=n; i++)
+ {
+ x->x_ambi_order_weight[i] = atom_getfloat(argv++);
+ }
+ }
+ else
+ post("ambi_encode-ERROR: ambi_weight needs %d float weights", x->x_n_order+1);
}
static void ambi_encode_do_2d(t_ambi_encode *x, t_floatarg phi)
{
- float c, s, cc, ss, c2, s2, c3, s3, s4, c4, s5, c5, s6, c6;
- float *awght = x->x_ambi_order_weight;
- t_atom *at=x->x_at;
-
- phi *= x->x_pi_over_180;
- c = cos(phi);
- s = sin(phi);
- cc = c*c;
- ss = s*s;
-
- SETFLOAT(at, (float)x->x_colrow);
- at++;
-
- SETFLOAT(at, awght[0]);
- at++;
-
- SETFLOAT(at, c*awght[1]);
- at++;
- SETFLOAT(at, s*awght[1]);
- at++;
-
- if(x->x_n_order >= 2)
- {
- c2 = cc - ss;
- s2 = 2.0f*s*c;
- SETFLOAT(at, c2*awght[2]);
- at++;
- SETFLOAT(at, s2*awght[2]);
- at++;
-
- if(x->x_n_order >= 3)
- {
- c3 = c*(4.0f*cc - 3.0f);
- s3 = s*(3.0f - 4.0f*ss);
- SETFLOAT(at, c3*awght[3]);
- at++;
- SETFLOAT(at, s3*awght[3]);
- at++;
-
- if(x->x_n_order >= 4)
- {
- c4 = 1.0f + 8.0f*cc*(cc - 1.0f);
- s4 = 2.0f*s2*c2;
- SETFLOAT(at, c4*awght[4]);
- at++;
- SETFLOAT(at, s4*awght[4]);
- at++;
-
- if(x->x_n_order >= 5)
- {
- c5 = c*(1.0f + 4.0f*ss*(ss - 3.0f*cc));
- s5 = s*(1.0f + 4.0f*cc*(cc - 3.0f*ss));
- SETFLOAT(at, c5*awght[5]);
- at++;
- SETFLOAT(at, s5*awght[5]);
- at++;
-
- if(x->x_n_order >= 6)
- {
- c6 = c3*c3 - s3*s3;
- s6 = 2.0f*s3*c3;
- SETFLOAT(at, c6*awght[6]);
- at++;
- SETFLOAT(at, s6*awght[6]);
- at++;
-
- if(x->x_n_order >= 7)
- {
- SETFLOAT(at, cos(7.0f*phi)*awght[7]);
- at++;
- SETFLOAT(at, sin(7.0f*phi)*awght[7]);
- at++;
-
- if(x->x_n_order >= 8)
- {
- SETFLOAT(at, (c4*c4 - s4*s4)*awght[8]);
- at++;
- SETFLOAT(at, 2.0f*s4*c4*awght[8]);
- at++;
-
- if(x->x_n_order >= 9)
- {
- SETFLOAT(at, cos(9.0f*phi)*awght[9]);
- at++;
- SETFLOAT(at, sin(9.0f*phi)*awght[9]);
- at++;
-
- if(x->x_n_order >= 10)
- {
- SETFLOAT(at, (c5*c5 - s5*s5)*awght[10]);
- at++;
- SETFLOAT(at, 2.0f*s5*c5*awght[10]);
- at++;
-
- if(x->x_n_order >= 11)
- {
- SETFLOAT(at, cos(11.0f*phi)*awght[11]);
- at++;
- SETFLOAT(at, sin(11.0f*phi)*awght[11]);
- at++;
-
- if(x->x_n_order >= 12)
- {
- SETFLOAT(at, (c6*c6 - s6*s6)*awght[12]);
- at++;
- SETFLOAT(at, 2.0f*s6*c6*awght[12]);
- }
-
- if(x->x_n_order >= 13)
- post("ambi_encode-ERROR: do not support Ambisonic-Order greater than 12 in 2d !!!");
-
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
+ t_float c, s, cc, ss, c2, s2, c3, s3, s4, c4, s5, c5, s6, c6;
+ t_float *awght = x->x_ambi_order_weight;
+ t_atom *at=x->x_at;
+
+ phi *= x->x_pi_over_180;
+ c = cos(phi);
+ s = sin(phi);
+ cc = c*c;
+ ss = s*s;
+
+ SETFLOAT(at, (t_float)x->x_colrow);
+ at++;
+
+ SETFLOAT(at, awght[0]);
+ at++;
+
+ SETFLOAT(at, c*awght[1]);
+ at++;
+ SETFLOAT(at, s*awght[1]);
+ at++;
+
+ if(x->x_n_order >= 2)
+ {
+ c2 = cc - ss;
+ s2 = 2.0f*s*c;
+ SETFLOAT(at, c2*awght[2]);
+ at++;
+ SETFLOAT(at, s2*awght[2]);
+ at++;
+
+ if(x->x_n_order >= 3)
+ {
+ c3 = c*(4.0f*cc - 3.0f);
+ s3 = s*(3.0f - 4.0f*ss);
+ SETFLOAT(at, c3*awght[3]);
+ at++;
+ SETFLOAT(at, s3*awght[3]);
+ at++;
+
+ if(x->x_n_order >= 4)
+ {
+ c4 = 1.0f + 8.0f*cc*(cc - 1.0f);
+ s4 = 2.0f*s2*c2;
+ SETFLOAT(at, c4*awght[4]);
+ at++;
+ SETFLOAT(at, s4*awght[4]);
+ at++;
+
+ if(x->x_n_order >= 5)
+ {
+ c5 = c*(1.0f + 4.0f*ss*(ss - 3.0f*cc));
+ s5 = s*(1.0f + 4.0f*cc*(cc - 3.0f*ss));
+ SETFLOAT(at, c5*awght[5]);
+ at++;
+ SETFLOAT(at, s5*awght[5]);
+ at++;
+
+ if(x->x_n_order >= 6)
+ {
+ c6 = c3*c3 - s3*s3;
+ s6 = 2.0f*s3*c3;
+ SETFLOAT(at, c6*awght[6]);
+ at++;
+ SETFLOAT(at, s6*awght[6]);
+ at++;
+
+ if(x->x_n_order >= 7)
+ {
+ SETFLOAT(at, cos(7.0f*phi)*awght[7]);
+ at++;
+ SETFLOAT(at, sin(7.0f*phi)*awght[7]);
+ at++;
+
+ if(x->x_n_order >= 8)
+ {
+ SETFLOAT(at, (c4*c4 - s4*s4)*awght[8]);
+ at++;
+ SETFLOAT(at, 2.0f*s4*c4*awght[8]);
+ at++;
+
+ if(x->x_n_order >= 9)
+ {
+ SETFLOAT(at, cos(9.0f*phi)*awght[9]);
+ at++;
+ SETFLOAT(at, sin(9.0f*phi)*awght[9]);
+ at++;
+
+ if(x->x_n_order >= 10)
+ {
+ SETFLOAT(at, (c5*c5 - s5*s5)*awght[10]);
+ at++;
+ SETFLOAT(at, 2.0f*s5*c5*awght[10]);
+ at++;
+
+ if(x->x_n_order >= 11)
+ {
+ SETFLOAT(at, cos(11.0f*phi)*awght[11]);
+ at++;
+ SETFLOAT(at, sin(11.0f*phi)*awght[11]);
+ at++;
+
+ if(x->x_n_order >= 12)
+ {
+ SETFLOAT(at, (c6*c6 - s6*s6)*awght[12]);
+ at++;
+ SETFLOAT(at, 2.0f*s6*c6*awght[12]);
+ }
+
+ if(x->x_n_order >= 13)
+ post("ambi_encode-ERROR: do not support Ambisonic-Order greater than 12 in 2d !!!");
+
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
static void ambi_encode_do_3d(t_ambi_encode *x, t_symbol *s, int argc, t_atom *argv)
{
- float delta, phi;
- float cd, x1, y, z, x2, y2, z2, x2my2, x2m3y2, p3x2my2, xy, xz, yz, m1p5z2, m1p7z2, m3p7z2;
- float *awght = x->x_ambi_order_weight;
- t_atom *at=x->x_at;
-
- delta = atom_getfloat(argv++)*x->x_pi_over_180;
- phi = atom_getfloat(argv)*x->x_pi_over_180;
-
- cd = cos(delta);
- x1 = cd * cos(phi);
- y = cd * sin(phi);
- z = sin(delta);
-
- xy = x1*y;
- xz = x1*z;
- yz = y*z;
- x2 = x1*x1;
- y2 = y*y;
- z2 = z*z;
-
- x2my2 = x2 - y2;
- x2m3y2 = x2my2 - 2.0f*y2;
- p3x2my2 = 2.0f*x2 + x2my2;
- m1p5z2 = 5.0f*z2 - 1.0f;
- m1p7z2 = 2.0f*z2 + m1p5z2;
- m3p7z2 = m1p7z2 - 2.0f;
-
- SETFLOAT(at, (float)x->x_colrow);
- at++;
-
- SETFLOAT(at, awght[0]);
- at++;
-
- SETFLOAT(at, x1*awght[1]);
- at++;
- SETFLOAT(at, y*awght[1]);
- at++;
- SETFLOAT(at, z*awght[1]);
- at++;
-
- if(x->x_n_order >= 2)
- {
- SETFLOAT(at, 0.5f*x->x_sqrt3*x2my2*awght[2]);
- at++;
- SETFLOAT(at, x->x_sqrt3*xy*awght[2]);
- at++;
- SETFLOAT(at, x->x_sqrt3*xz*awght[2]);
- at++;
- SETFLOAT(at, x->x_sqrt3*yz*awght[2]);
- at++;
- SETFLOAT(at, 0.5f*(3.0f*z2 - 1.0f)*awght[2]);
- at++;
-
- if(x->x_n_order >= 3)
- {
- SETFLOAT(at, x->x_sqrt10_4*x1*x2m3y2*awght[3]);
- at++;
- SETFLOAT(at, x->x_sqrt10_4*y*p3x2my2*awght[3]);
- at++;
- SETFLOAT(at, 0.5f*x->x_sqrt15*z*x2my2*awght[3]);
- at++;
- SETFLOAT(at, x->x_sqrt15*xy*z*awght[3]);
- at++;
- SETFLOAT(at, x->x_sqrt6_4*x1*m1p5z2*awght[3]);
- at++;
- SETFLOAT(at, x->x_sqrt6_4*y*m1p5z2*awght[3]);
- at++;
- SETFLOAT(at, 0.5f*z*(m1p5z2 - 2.0f)*awght[3]);
- at++;
-
- if(x->x_n_order >= 4)
- {
- SETFLOAT(at, 0.25f*x->x_sqrt35_2*(x2my2*x2my2 - 4.0f*x2*y2)*awght[4]);
- at++;
- SETFLOAT(at, x->x_sqrt35_2*xy*x2my2*awght[4]);
- at++;
- SETFLOAT(at, x->x_sqrt70_4*xz*x2m3y2*awght[4]);
- at++;
- SETFLOAT(at, x->x_sqrt70_4*yz*p3x2my2*awght[4]);
- at++;
- SETFLOAT(at, 0.5f*x->x_sqrt5_2*x2my2*m1p7z2*awght[4]);
- at++;
- SETFLOAT(at, x->x_sqrt5_2*xy*m1p7z2*awght[4]);
- at++;
- SETFLOAT(at, x->x_sqrt10_4*xz*m3p7z2*awght[4]);
- at++;
- SETFLOAT(at, x->x_sqrt10_4*yz*m3p7z2*awght[4]);
- at++;
- SETFLOAT(at, 0.125f*(5.0f*(z2 - 1.0f)*(m1p7z2 + 2.0f) + 8.0f)*awght[4]);
- at++;
-
- if(x->x_n_order >= 5)
- {
- SETFLOAT(at, x->x_sqrt126_16*x1*(x2*(x2 - 10.0f*y2) + 5.0f*y2*y2)*awght[5]);
- at++;
- SETFLOAT(at, x->x_sqrt126_16*y*(y2*(y2 - 10.0f*x2) + 5.0f*x2*x2)*awght[5]);
- at++;
- SETFLOAT(at, 0.25f*x->x_sqrt315_2*z*(y2*(y2 - 6.0f*x2) + x2*x2)*awght[5]);
- at++;
- SETFLOAT(at, x->x_sqrt315_2*xy*z*x2my2*awght[5]);
- at++;
- SETFLOAT(at, 0.25f*x->x_sqrt70_4*x1*(9.0f*z2 - 1.0f)*x2m3y2*awght[5]);
- at++;
- SETFLOAT(at, 0.25f*x->x_sqrt70_4*y*(9.0f*z2 - 1.0f)*p3x2my2*awght[5]);
- at++;
- SETFLOAT(at, 0.5f*x->x_sqrt105_2*x2my2*z*(3.0f*z2 - 1.0f)*awght[5]);
- at++;
- SETFLOAT(at, x->x_sqrt105_2*xy*z*(3.0f*z2 - 1.0f)*awght[5]);
- at++;
- SETFLOAT(at, 0.125f*x->x_sqrt15*x1*(z2*(21.0f*z2 - 14.0f) + 1.0f)*awght[5]);
- at++;
- SETFLOAT(at, 0.125f*x->x_sqrt15*y*(z2*(21.0f*z2 - 14.0f) + 1.0f)*awght[5]);
- at++;
- SETFLOAT(at, 0.125f*z*(z2*(63.0f*z2 - 70.0f) + 15.0f)*awght[5]);
- }
-
- if(x->x_n_order > 5)
- post("ambi_encode-ERROR: do not support Ambisonic-Order greater than 5 in 3d !!!");
- }
- }
- }
+ t_float delta, phi;
+ t_float cd, x1, y, z, x2, y2, z2, x2my2, x2m3y2, p3x2my2, xy, xz, yz, m1p5z2, m1p7z2, m3p7z2;
+ t_float *awght = x->x_ambi_order_weight;
+ t_atom *at=x->x_at;
+
+ delta = atom_getfloat(argv++)*x->x_pi_over_180;
+ phi = atom_getfloat(argv)*x->x_pi_over_180;
+
+ cd = cos(delta);
+ x1 = cd * cos(phi);
+ y = cd * sin(phi);
+ z = sin(delta);
+
+ xy = x1*y;
+ xz = x1*z;
+ yz = y*z;
+ x2 = x1*x1;
+ y2 = y*y;
+ z2 = z*z;
+
+ x2my2 = x2 - y2;
+ x2m3y2 = x2my2 - 2.0f*y2;
+ p3x2my2 = 2.0f*x2 + x2my2;
+ m1p5z2 = 5.0f*z2 - 1.0f;
+ m1p7z2 = 2.0f*z2 + m1p5z2;
+ m3p7z2 = m1p7z2 - 2.0f;
+
+ SETFLOAT(at, (t_float)x->x_colrow);
+ at++;
+
+ SETFLOAT(at, awght[0]);
+ at++;
+
+ SETFLOAT(at, x1*awght[1]);
+ at++;
+ SETFLOAT(at, y*awght[1]);
+ at++;
+ SETFLOAT(at, z*awght[1]);
+ at++;
+
+ if(x->x_n_order >= 2)
+ {
+ SETFLOAT(at, 0.5f*x->x_sqrt3*x2my2*awght[2]);
+ at++;
+ SETFLOAT(at, x->x_sqrt3*xy*awght[2]);
+ at++;
+ SETFLOAT(at, x->x_sqrt3*xz*awght[2]);
+ at++;
+ SETFLOAT(at, x->x_sqrt3*yz*awght[2]);
+ at++;
+ SETFLOAT(at, 0.5f*(3.0f*z2 - 1.0f)*awght[2]);
+ at++;
+
+ if(x->x_n_order >= 3)
+ {
+ SETFLOAT(at, x->x_sqrt10_4*x1*x2m3y2*awght[3]);
+ at++;
+ SETFLOAT(at, x->x_sqrt10_4*y*p3x2my2*awght[3]);
+ at++;
+ SETFLOAT(at, 0.5f*x->x_sqrt15*z*x2my2*awght[3]);
+ at++;
+ SETFLOAT(at, x->x_sqrt15*xy*z*awght[3]);
+ at++;
+ SETFLOAT(at, x->x_sqrt6_4*x1*m1p5z2*awght[3]);
+ at++;
+ SETFLOAT(at, x->x_sqrt6_4*y*m1p5z2*awght[3]);
+ at++;
+ SETFLOAT(at, 0.5f*z*(m1p5z2 - 2.0f)*awght[3]);
+ at++;
+
+ if(x->x_n_order >= 4)
+ {
+ SETFLOAT(at, 0.25f*x->x_sqrt35_2*(x2my2*x2my2 - 4.0f*x2*y2)*awght[4]);
+ at++;
+ SETFLOAT(at, x->x_sqrt35_2*xy*x2my2*awght[4]);
+ at++;
+ SETFLOAT(at, x->x_sqrt70_4*xz*x2m3y2*awght[4]);
+ at++;
+ SETFLOAT(at, x->x_sqrt70_4*yz*p3x2my2*awght[4]);
+ at++;
+ SETFLOAT(at, 0.5f*x->x_sqrt5_2*x2my2*m1p7z2*awght[4]);
+ at++;
+ SETFLOAT(at, x->x_sqrt5_2*xy*m1p7z2*awght[4]);
+ at++;
+ SETFLOAT(at, x->x_sqrt10_4*xz*m3p7z2*awght[4]);
+ at++;
+ SETFLOAT(at, x->x_sqrt10_4*yz*m3p7z2*awght[4]);
+ at++;
+ SETFLOAT(at, 0.125f*(5.0f*(z2 - 1.0f)*(m1p7z2 + 2.0f) + 8.0f)*awght[4]);
+ at++;
+
+ if(x->x_n_order >= 5)
+ {
+ SETFLOAT(at, x->x_sqrt126_16*x1*(x2*(x2 - 10.0f*y2) + 5.0f*y2*y2)*awght[5]);
+ at++;
+ SETFLOAT(at, x->x_sqrt126_16*y*(y2*(y2 - 10.0f*x2) + 5.0f*x2*x2)*awght[5]);
+ at++;
+ SETFLOAT(at, 0.25f*x->x_sqrt315_2*z*(y2*(y2 - 6.0f*x2) + x2*x2)*awght[5]);
+ at++;
+ SETFLOAT(at, x->x_sqrt315_2*xy*z*x2my2*awght[5]);
+ at++;
+ SETFLOAT(at, 0.25f*x->x_sqrt70_4*x1*(9.0f*z2 - 1.0f)*x2m3y2*awght[5]);
+ at++;
+ SETFLOAT(at, 0.25f*x->x_sqrt70_4*y*(9.0f*z2 - 1.0f)*p3x2my2*awght[5]);
+ at++;
+ SETFLOAT(at, 0.5f*x->x_sqrt105_2*x2my2*z*(3.0f*z2 - 1.0f)*awght[5]);
+ at++;
+ SETFLOAT(at, x->x_sqrt105_2*xy*z*(3.0f*z2 - 1.0f)*awght[5]);
+ at++;
+ SETFLOAT(at, 0.125f*x->x_sqrt15*x1*(z2*(21.0f*z2 - 14.0f) + 1.0f)*awght[5]);
+ at++;
+ SETFLOAT(at, 0.125f*x->x_sqrt15*y*(z2*(21.0f*z2 - 14.0f) + 1.0f)*awght[5]);
+ at++;
+ SETFLOAT(at, 0.125f*z*(z2*(63.0f*z2 - 70.0f) + 15.0f)*awght[5]);
+ }
+
+ if(x->x_n_order > 5)
+ post("ambi_encode-ERROR: do not support Ambisonic-Order greater than 5 in 3d !!!");
+ }
+ }
+ }
}
static void ambi_encode_float(t_ambi_encode *x, t_floatarg phi)
{
- x->x_colrow = -1;
- ambi_encode_do_2d(x, phi);
- outlet_list(x->x_obj.ob_outlet, &s_list, x->x_size2d, x->x_at+1);
+ x->x_colrow = -1;
+ ambi_encode_do_2d(x, phi);
+ outlet_list(x->x_obj.ob_outlet, &s_list, x->x_size2d, x->x_at+1);
}
static void ambi_encode_list(t_ambi_encode *x, t_symbol *s, int argc, t_atom *argv)
{
- if(argc <= 0)
- {
- post("ambi_encode ERROR: list-input needs 2 angles: delta [rad] and phi [rad]");
- return;
- }
- else if(argc == 1)
- {
- ambi_encode_float(x, atom_getfloat(argv));
- }
- else
- {
- x->x_colrow = -1;
- ambi_encode_do_3d(x, &s_list, 2, argv);
- outlet_list(x->x_obj.ob_outlet, &s_list, x->x_size3d, x->x_at+1);
- }
+ if(argc <= 0)
+ {
+ post("ambi_encode ERROR: list-input needs 2 angles: delta [rad] and phi [rad]");
+ return;
+ }
+ else if(argc == 1)
+ {
+ ambi_encode_float(x, atom_getfloat(argv));
+ }
+ else
+ {
+ x->x_colrow = -1;
+ ambi_encode_do_3d(x, &s_list, 2, argv);
+ outlet_list(x->x_obj.ob_outlet, &s_list, x->x_size3d, x->x_at+1);
+ }
}
static void ambi_encode_row(t_ambi_encode *x, t_symbol *s, int argc, t_atom *argv)
{
- if(argc == 2)
- {
- x->x_colrow = (int)atom_getint(argv++);
- ambi_encode_do_2d(x, atom_getfloat(argv));
- outlet_anything(x->x_obj.ob_outlet, s, x->x_size2d+1, x->x_at);
- }
- else if(argc >= 3)
- {
- x->x_colrow = (int)atom_getint(argv++);
- ambi_encode_do_3d(x, &s_list, 2, argv);
- outlet_anything(x->x_obj.ob_outlet, s, x->x_size3d+1, x->x_at);
- }
- else
- {
- post("ambi_encode-ERROR: row needs <float> row-index + <float> angle ( + <float> angle)");
- }
+ if(argc == 2)
+ {
+ x->x_colrow = (int)atom_getint(argv++);
+ ambi_encode_do_2d(x, atom_getfloat(argv));
+ outlet_anything(x->x_obj.ob_outlet, s, x->x_size2d+1, x->x_at);
+ }
+ else if(argc >= 3)
+ {
+ x->x_colrow = (int)atom_getint(argv++);
+ ambi_encode_do_3d(x, &s_list, 2, argv);
+ outlet_anything(x->x_obj.ob_outlet, s, x->x_size3d+1, x->x_at);
+ }
+ else
+ {
+ post("ambi_encode-ERROR: row needs <float> row-index + <float> angle ( + <float> angle)");
+ }
}
static void ambi_encode_col(t_ambi_encode *x, t_symbol *s, int argc, t_atom *argv)
{
- if(argc == 2)
- {
- x->x_colrow = (int)atom_getint(argv++);
- ambi_encode_do_2d(x, atom_getfloat(argv));
- outlet_anything(x->x_obj.ob_outlet, s, x->x_size2d+1, x->x_at);
- }
- else if(argc >= 3)
- {
- x->x_colrow = (int)atom_getint(argv++);
- ambi_encode_do_3d(x, &s_list, 2, argv);
- outlet_anything(x->x_obj.ob_outlet, s, x->x_size3d+1, x->x_at);
- }
- else
- {
- post("ambi_encode-ERROR: col needs <float> col-index + <float> angle ( + <float> angle)");
- }
+ if(argc == 2)
+ {
+ x->x_colrow = (int)atom_getint(argv++);
+ ambi_encode_do_2d(x, atom_getfloat(argv));
+ outlet_anything(x->x_obj.ob_outlet, s, x->x_size2d+1, x->x_at);
+ }
+ else if(argc >= 3)
+ {
+ x->x_colrow = (int)atom_getint(argv++);
+ ambi_encode_do_3d(x, &s_list, 2, argv);
+ outlet_anything(x->x_obj.ob_outlet, s, x->x_size3d+1, x->x_at);
+ }
+ else
+ {
+ post("ambi_encode-ERROR: col needs <float> col-index + <float> angle ( + <float> angle)");
+ }
}
static void ambi_encode_free(t_ambi_encode *x)
{
- freebytes(x->x_ambi_order_weight, (x->x_n_order+1) * sizeof(float));
- freebytes(x->x_at, x->x_size * sizeof(t_atom));
+ freebytes(x->x_ambi_order_weight, (x->x_n_order+1) * sizeof(t_float));
+ freebytes(x->x_at, x->x_size * sizeof(t_atom));
}
static void *ambi_encode_new(t_floatarg forder)
{
- t_ambi_encode *x = (t_ambi_encode *)pd_new(ambi_encode_class);
- t_atom *at;
- int i=(int)forder;
-
- if(i < 1)
- i = 1;
- if(i > 12)
- i = 12;
- x->x_n_order = i;
- x->x_size = 6*6 + 1;
- x->x_size2d = 2*i + 1;
- x->x_size3d = (i + 1)*(i + 1);
-
- x->x_sqrt3 = (float)(sqrt(3.0));
- x->x_sqrt5_2 = (float)(sqrt(5.0) / 2.0);
- x->x_sqrt6_4 = (float)(sqrt(6.0) / 4.0);
- x->x_sqrt10_4 = (float)(sqrt(10.0) / 4.0);
- x->x_sqrt15 = (float)(sqrt(15.0));
- x->x_sqrt35_2 = (float)(sqrt(35.0) / 2.0);
- x->x_sqrt70_4 = (float)(sqrt(70.0) / 4.0);
- x->x_sqrt126_16 = (float)(sqrt(126.0) / 16.0);
- x->x_sqrt315_2 = (float)(sqrt(315.0) / 2.0);
- x->x_sqrt105_2 = (float)(sqrt(105.0) / 2.0);
- x->x_pi_over_180 = (float)(4.0 * atan(1.0)/180.0);
- x->x_colrow = 0;
- x->x_ambi_order_weight = (float *)getbytes((x->x_n_order+1) * sizeof(float));
- x->x_at = (t_atom *)getbytes(x->x_size * sizeof(t_atom));
- at=x->x_at;
- SETFLOAT(at, -1.0f);/*row index*/
- at++;
- SETFLOAT(at, 1.0f);/*W channel*/
-
- for(i=0; i<=x->x_n_order; i++)
- x->x_ambi_order_weight[i] = 1.0f;
-
- outlet_new(&x->x_obj, &s_list);
- return (x);
+ t_ambi_encode *x = (t_ambi_encode *)pd_new(ambi_encode_class);
+ t_atom *at;
+ int i=(int)forder;
+
+ if(i < 1)
+ i = 1;
+ if(i > 12)
+ i = 12;
+ x->x_n_order = i;
+ x->x_size = 6*6 + 1;
+ x->x_size2d = 2*i + 1;
+ x->x_size3d = (i + 1)*(i + 1);
+
+ x->x_sqrt3 = (t_float)(sqrt(3.0));
+ x->x_sqrt5_2 = (t_float)(sqrt(5.0) / 2.0);
+ x->x_sqrt6_4 = (t_float)(sqrt(6.0) / 4.0);
+ x->x_sqrt10_4 = (t_float)(sqrt(10.0) / 4.0);
+ x->x_sqrt15 = (t_float)(sqrt(15.0));
+ x->x_sqrt35_2 = (t_float)(sqrt(35.0) / 2.0);
+ x->x_sqrt70_4 = (t_float)(sqrt(70.0) / 4.0);
+ x->x_sqrt126_16 = (t_float)(sqrt(126.0) / 16.0);
+ x->x_sqrt315_2 = (t_float)(sqrt(315.0) / 2.0);
+ x->x_sqrt105_2 = (t_float)(sqrt(105.0) / 2.0);
+ x->x_pi_over_180 = (t_float)(4.0 * atan(1.0)/180.0);
+ x->x_colrow = 0;
+ x->x_ambi_order_weight = (t_float *)getbytes((x->x_n_order+1) * sizeof(t_float));
+ x->x_at = (t_atom *)getbytes(x->x_size * sizeof(t_atom));
+ at=x->x_at;
+ SETFLOAT(at, -1.0f);/*row index*/
+ at++;
+ SETFLOAT(at, 1.0f);/*W channel*/
+
+ for(i=0; i<=x->x_n_order; i++)
+ x->x_ambi_order_weight[i] = 1.0f;
+
+ outlet_new(&x->x_obj, &s_list);
+ return (x);
}
void ambi_encode_setup(void)
{
- ambi_encode_class = class_new(gensym("ambi_encode"), (t_newmethod)ambi_encode_new, (t_method)ambi_encode_free,
- sizeof(t_ambi_encode), 0, A_DEFFLOAT, 0);
- class_addlist(ambi_encode_class, (t_method)ambi_encode_list);
- class_addfloat(ambi_encode_class, (t_method)ambi_encode_float);
- class_addmethod(ambi_encode_class, (t_method)ambi_encode_row, gensym("row"), A_GIMME, 0);
- class_addmethod(ambi_encode_class, (t_method)ambi_encode_col, gensym("col"), A_GIMME, 0);
- class_addmethod(ambi_encode_class, (t_method)ambi_encode_ambi_weight, gensym("ambi_weight"), A_GIMME, 0);
- class_sethelpsymbol(ambi_encode_class, gensym("iemhelp2/ambi_encode-help"));
+ ambi_encode_class = class_new(gensym("ambi_encode"), (t_newmethod)ambi_encode_new, (t_method)ambi_encode_free,
+ sizeof(t_ambi_encode), 0, A_DEFFLOAT, 0);
+ class_addlist(ambi_encode_class, (t_method)ambi_encode_list);
+ class_addfloat(ambi_encode_class, (t_method)ambi_encode_float);
+ class_addmethod(ambi_encode_class, (t_method)ambi_encode_row, gensym("row"), A_GIMME, 0);
+ class_addmethod(ambi_encode_class, (t_method)ambi_encode_col, gensym("col"), A_GIMME, 0);
+ class_addmethod(ambi_encode_class, (t_method)ambi_encode_ambi_weight, gensym("ambi_weight"), A_GIMME, 0);
+ class_sethelpsymbol(ambi_encode_class, gensym("iemhelp2/ambi_encode-help"));
}
diff --git a/src/ambi_rot.c b/src/ambi_rot.c
index 1433bbb..9690fe9 100644
--- a/src/ambi_rot.c
+++ b/src/ambi_rot.c
@@ -3,1532 +3,1522 @@
iem_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include <math.h>
-#include <stdio.h>
-#include <string.h>
-
-
/* -------------------------- ambi_rot ------------------------------ */
/*
ambi_rot : 1. uebergabe-argument : ambisonic-ordnung 1 .. 4;
- input: <float> nur z-rotation;
- input: <list> mit 2 floats: nur z*y-rotation;
- input: <list> mit 3 floats: z*y*x-rotation;
-
- output: je nach ordnung: 1 .. 4 <list>-outputs mit selector "matrix" + row + col + ordnung*ordnung-coeff.;
+ input: <float> nur z-rotation;
+ input: <list> mit 2 floats: nur z*y-rotation;
+ input: <list> mit 3 floats: z*y*x-rotation;
+
+ output: je nach ordnung: 1 .. 4 <list>-outputs mit selector "matrix" + row + col + ordnung*ordnung-coeff.;
*/
typedef struct _ambi_rot
{
- t_object x_obj;
- t_atom *x_at2;
- int x_size2;
- t_atom *x_at3;
- int x_size3;
- void *x_out3;
- t_atom *x_at5;
- int x_size5;
- void *x_out5;
- t_atom *x_at7;
- int x_size7;
- void *x_out7;
- t_atom *x_at9;
- int x_size9;
- void *x_out9;
- t_atom *x_at11;
- int x_size11;
- void *x_out11;
- void *x_out13;
- void *x_out15;
- void *x_out17;
- void *x_out19;
- void *x_out21;
- void *x_out23;
- void *x_out25;
- float x_sqrt2_16;
- float x_sqrt3_2;
- float x_sqrt5_32;
- float x_sqrt6_4;
- float x_sqrt7_8;
- float x_sqrt10_4;
- float x_sqrt14_16;
- float x_sqrt15_8;
- float x_sqrt35_64;
- float x_sqrt70_32;
- float x_pi_over_180;
- t_symbol *x_s_matrix;
- int x_order;
+ t_object x_obj;
+ t_atom *x_at2;
+ int x_size2;
+ t_atom *x_at3;
+ int x_size3;
+ void *x_out3;
+ t_atom *x_at5;
+ int x_size5;
+ void *x_out5;
+ t_atom *x_at7;
+ int x_size7;
+ void *x_out7;
+ t_atom *x_at9;
+ int x_size9;
+ void *x_out9;
+ t_atom *x_at11;
+ int x_size11;
+ void *x_out11;
+ void *x_out13;
+ void *x_out15;
+ void *x_out17;
+ void *x_out19;
+ void *x_out21;
+ void *x_out23;
+ void *x_out25;
+ t_float x_sqrt2_16;
+ t_float x_sqrt3_2;
+ t_float x_sqrt5_32;
+ t_float x_sqrt6_4;
+ t_float x_sqrt7_8;
+ t_float x_sqrt10_4;
+ t_float x_sqrt14_16;
+ t_float x_sqrt15_8;
+ t_float x_sqrt35_64;
+ t_float x_sqrt70_32;
+ t_float x_pi_over_180;
+ t_symbol *x_s_matrix;
+ int x_order;
} t_ambi_rot;
static t_class *ambi_rot_class;
static void ambi_rot_float(t_ambi_rot *x, t_floatarg rho_z) /* = ambi_rot_z(); */
{
- float c, s, cc, ss, c2, s2, c3, s3, s4, c4, s5, c5, s6, c6, sx, cx;
- t_atom *at;
-
- rho_z *= x->x_pi_over_180;
-
- c = cos(rho_z);
- s = sin(rho_z);
- cc = c*c;
- ss = s*s;
-
- if(x->x_order >= 2)
- {
- c2 = cc - ss;
- s2 = 2.0f*s*c;
- if(x->x_order >= 3)
- {
- c3 = c*(4.0f*cc - 3.0f);
- s3 = s*(3.0f - 4.0f*ss);
- if(x->x_order >= 4)
- {
- c4 = 1.0f + 8.0f*cc*(cc - 1.0f);
- s4 = 2.0f*s2*c2;
- if(x->x_order >= 5)
- {
- c5 = c*(1.0f + 4.0f*ss*(ss - 3.0f*cc));
- s5 = s*(1.0f + 4.0f*cc*(cc - 3.0f*ss));
- if(x->x_order >= 6)
- {
- c6 = c3*c3 - s3*s3;
- s6 = 2.0f*s3*c3;
- if(x->x_order >= 7)
- {
- if(x->x_order >= 8)
- {
- if(x->x_order >= 9)
- {
- if(x->x_order >= 10)
- {
- if(x->x_order >= 11)
- {
- if(x->x_order >= 12)
- {
- if(x->x_order >= 13)
- post("ambi_rot-ERROR: do not support Ambisonic-Order greater than 12 in z-Rotation !!!");
-
- at = x->x_at2;
- at += 2;
- cx = c6*c6 - s6*s6;
- sx = 2.0f*s6*c6;
- SETFLOAT(at, cx);
- at++;
- SETFLOAT(at, -sx);
- at++;
- SETFLOAT(at, sx);
- at++;
- SETFLOAT(at, cx);
- outlet_anything(x->x_out25, x->x_s_matrix, x->x_size2, x->x_at2);
- }
- at = x->x_at2;
- at += 2;
- cx = cos(11.0f*rho_z);
- sx = sin(11.0f*rho_z);
- SETFLOAT(at, cx);
- at++;
- SETFLOAT(at, -sx);
- at++;
- SETFLOAT(at, sx);
- at++;
- SETFLOAT(at, cx);
- outlet_anything(x->x_out23, x->x_s_matrix, x->x_size2, x->x_at2);
- }
- at = x->x_at2;
- at += 2;
- cx = c5*c5 - s5*s5;
- sx = 2.0f*s5*c5;
- SETFLOAT(at, cx);
- at++;
- SETFLOAT(at, -sx);
- at++;
- SETFLOAT(at, sx);
- at++;
- SETFLOAT(at, cx);
- outlet_anything(x->x_out21, x->x_s_matrix, x->x_size2, x->x_at2);
- }
- at = x->x_at2;
- at += 2;
- cx = cos(9.0f*rho_z);
- sx = sin(9.0f*rho_z);
- SETFLOAT(at, cx);
- at++;
- SETFLOAT(at, -sx);
- at++;
- SETFLOAT(at, sx);
- at++;
- SETFLOAT(at, cx);
- outlet_anything(x->x_out19, x->x_s_matrix, x->x_size2, x->x_at2);
- }
- at = x->x_at2;
- at += 2;
- cx = c4*c4 - s4*s4;
- sx = 2.0f*s4*c4;
- SETFLOAT(at, cx);
- at++;
- SETFLOAT(at, -sx);
- at++;
- SETFLOAT(at, sx);
- at++;
- SETFLOAT(at, cx);
- outlet_anything(x->x_out17, x->x_s_matrix, x->x_size2, x->x_at2);
- }
- at = x->x_at2;
- at += 2;
- cx = cos(7.0f*rho_z);
- sx = sin(7.0f*rho_z);
- SETFLOAT(at, cx);
- at++;
- SETFLOAT(at, -sx);
- at++;
- SETFLOAT(at, sx);
- at++;
- SETFLOAT(at, cx);
- outlet_anything(x->x_out15, x->x_s_matrix, x->x_size2, x->x_at2);
- }
- at = x->x_at2;
- at += 2;
- SETFLOAT(at, c6);
- at++;
- SETFLOAT(at, -s6);
- at++;
- SETFLOAT(at, s6);
- at++;
- SETFLOAT(at, c6);
- outlet_anything(x->x_out13, x->x_s_matrix, x->x_size2, x->x_at2);
- }
- at = x->x_at2;
- at += 2;
- SETFLOAT(at, c5);
- at++;
- SETFLOAT(at, -s5);
- at++;
- SETFLOAT(at, s5);
- at++;
- SETFLOAT(at, c5);
- outlet_anything(x->x_out11, x->x_s_matrix, x->x_size2, x->x_at2);
- }
- at = x->x_at2;
- at += 2;
- SETFLOAT(at, c4);
- at++;
- SETFLOAT(at, -s4);
- at++;
- SETFLOAT(at, s4);
- at++;
- SETFLOAT(at, c4);
- outlet_anything(x->x_out9, x->x_s_matrix, x->x_size2, x->x_at2);
- }
- at = x->x_at2;
- at += 2;
- SETFLOAT(at, c3);
- at++;
- SETFLOAT(at, -s3);
- at++;
- SETFLOAT(at, s3);
- at++;
- SETFLOAT(at, c3);
- outlet_anything(x->x_out7, x->x_s_matrix, x->x_size2, x->x_at2);
- }
- at = x->x_at2;
- at += 2;
- SETFLOAT(at, c2);
- at++;
- SETFLOAT(at, -s2);
- at++;
- SETFLOAT(at, s2);
- at++;
- SETFLOAT(at, c2);
- outlet_anything(x->x_out5, x->x_s_matrix, x->x_size2, x->x_at2);
- }
- at = x->x_at2;
- at += 2;
- SETFLOAT(at, c);
- at++;
- SETFLOAT(at, -s);
- at++;
- SETFLOAT(at, s);
- at++;
- SETFLOAT(at, c);
- outlet_anything(x->x_out3, x->x_s_matrix, x->x_size2, x->x_at2);
+ t_float c, s, cc, ss, c2, s2, c3, s3, s4, c4, s5, c5, s6, c6, sx, cx;
+ t_atom *at;
+
+ rho_z *= x->x_pi_over_180;
+
+ c = cos(rho_z);
+ s = sin(rho_z);
+ cc = c*c;
+ ss = s*s;
+
+ if(x->x_order >= 2)
+ {
+ c2 = cc - ss;
+ s2 = 2.0f*s*c;
+ if(x->x_order >= 3)
+ {
+ c3 = c*(4.0f*cc - 3.0f);
+ s3 = s*(3.0f - 4.0f*ss);
+ if(x->x_order >= 4)
+ {
+ c4 = 1.0f + 8.0f*cc*(cc - 1.0f);
+ s4 = 2.0f*s2*c2;
+ if(x->x_order >= 5)
+ {
+ c5 = c*(1.0f + 4.0f*ss*(ss - 3.0f*cc));
+ s5 = s*(1.0f + 4.0f*cc*(cc - 3.0f*ss));
+ if(x->x_order >= 6)
+ {
+ c6 = c3*c3 - s3*s3;
+ s6 = 2.0f*s3*c3;
+ if(x->x_order >= 7)
+ {
+ if(x->x_order >= 8)
+ {
+ if(x->x_order >= 9)
+ {
+ if(x->x_order >= 10)
+ {
+ if(x->x_order >= 11)
+ {
+ if(x->x_order >= 12)
+ {
+ if(x->x_order >= 13)
+ post("ambi_rot-ERROR: do not support Ambisonic-Order greater than 12 in z-Rotation !!!");
+
+ at = x->x_at2;
+ at += 2;
+ cx = c6*c6 - s6*s6;
+ sx = 2.0f*s6*c6;
+ SETFLOAT(at, cx);
+ at++;
+ SETFLOAT(at, -sx);
+ at++;
+ SETFLOAT(at, sx);
+ at++;
+ SETFLOAT(at, cx);
+ outlet_anything(x->x_out25, x->x_s_matrix, x->x_size2, x->x_at2);
+ }
+ at = x->x_at2;
+ at += 2;
+ cx = cos(11.0f*rho_z);
+ sx = sin(11.0f*rho_z);
+ SETFLOAT(at, cx);
+ at++;
+ SETFLOAT(at, -sx);
+ at++;
+ SETFLOAT(at, sx);
+ at++;
+ SETFLOAT(at, cx);
+ outlet_anything(x->x_out23, x->x_s_matrix, x->x_size2, x->x_at2);
+ }
+ at = x->x_at2;
+ at += 2;
+ cx = c5*c5 - s5*s5;
+ sx = 2.0f*s5*c5;
+ SETFLOAT(at, cx);
+ at++;
+ SETFLOAT(at, -sx);
+ at++;
+ SETFLOAT(at, sx);
+ at++;
+ SETFLOAT(at, cx);
+ outlet_anything(x->x_out21, x->x_s_matrix, x->x_size2, x->x_at2);
+ }
+ at = x->x_at2;
+ at += 2;
+ cx = cos(9.0f*rho_z);
+ sx = sin(9.0f*rho_z);
+ SETFLOAT(at, cx);
+ at++;
+ SETFLOAT(at, -sx);
+ at++;
+ SETFLOAT(at, sx);
+ at++;
+ SETFLOAT(at, cx);
+ outlet_anything(x->x_out19, x->x_s_matrix, x->x_size2, x->x_at2);
+ }
+ at = x->x_at2;
+ at += 2;
+ cx = c4*c4 - s4*s4;
+ sx = 2.0f*s4*c4;
+ SETFLOAT(at, cx);
+ at++;
+ SETFLOAT(at, -sx);
+ at++;
+ SETFLOAT(at, sx);
+ at++;
+ SETFLOAT(at, cx);
+ outlet_anything(x->x_out17, x->x_s_matrix, x->x_size2, x->x_at2);
+ }
+ at = x->x_at2;
+ at += 2;
+ cx = cos(7.0f*rho_z);
+ sx = sin(7.0f*rho_z);
+ SETFLOAT(at, cx);
+ at++;
+ SETFLOAT(at, -sx);
+ at++;
+ SETFLOAT(at, sx);
+ at++;
+ SETFLOAT(at, cx);
+ outlet_anything(x->x_out15, x->x_s_matrix, x->x_size2, x->x_at2);
+ }
+ at = x->x_at2;
+ at += 2;
+ SETFLOAT(at, c6);
+ at++;
+ SETFLOAT(at, -s6);
+ at++;
+ SETFLOAT(at, s6);
+ at++;
+ SETFLOAT(at, c6);
+ outlet_anything(x->x_out13, x->x_s_matrix, x->x_size2, x->x_at2);
+ }
+ at = x->x_at2;
+ at += 2;
+ SETFLOAT(at, c5);
+ at++;
+ SETFLOAT(at, -s5);
+ at++;
+ SETFLOAT(at, s5);
+ at++;
+ SETFLOAT(at, c5);
+ outlet_anything(x->x_out11, x->x_s_matrix, x->x_size2, x->x_at2);
+ }
+ at = x->x_at2;
+ at += 2;
+ SETFLOAT(at, c4);
+ at++;
+ SETFLOAT(at, -s4);
+ at++;
+ SETFLOAT(at, s4);
+ at++;
+ SETFLOAT(at, c4);
+ outlet_anything(x->x_out9, x->x_s_matrix, x->x_size2, x->x_at2);
+ }
+ at = x->x_at2;
+ at += 2;
+ SETFLOAT(at, c3);
+ at++;
+ SETFLOAT(at, -s3);
+ at++;
+ SETFLOAT(at, s3);
+ at++;
+ SETFLOAT(at, c3);
+ outlet_anything(x->x_out7, x->x_s_matrix, x->x_size2, x->x_at2);
+ }
+ at = x->x_at2;
+ at += 2;
+ SETFLOAT(at, c2);
+ at++;
+ SETFLOAT(at, -s2);
+ at++;
+ SETFLOAT(at, s2);
+ at++;
+ SETFLOAT(at, c2);
+ outlet_anything(x->x_out5, x->x_s_matrix, x->x_size2, x->x_at2);
+ }
+ at = x->x_at2;
+ at += 2;
+ SETFLOAT(at, c);
+ at++;
+ SETFLOAT(at, -s);
+ at++;
+ SETFLOAT(at, s);
+ at++;
+ SETFLOAT(at, c);
+ outlet_anything(x->x_out3, x->x_s_matrix, x->x_size2, x->x_at2);
}
-static void ambi_rot_zy(t_ambi_rot *x, float rho_z, float rho_y)
+static void ambi_rot_zy(t_ambi_rot *x, t_floatarg rho_z, t_floatarg rho_y)
{
- float cy, sy, ccy, ssy, c2y, s2y, c3y, s3y, c4y, s4y;
- float cz, sz, ccz, ssz, c2z, s2z, c3z, s3z, c4z, s4z;
- float r9_y[9][9];
- int i;
- t_atom *at;
-
- rho_z *= x->x_pi_over_180;
- rho_y *= x->x_pi_over_180;
-
- cz = cos(rho_z);
- sz = sin(rho_z);
- ccz = cz*cz;
- ssz = sz*sz;
-
- cy = cos(rho_y);
- sy = sin(rho_y);
- ccy = cy*cy;
- ssy = sy*sy;
-
- if(x->x_order >= 2)
- {
- c2z = ccz - ssz;
- s2z = 2.0f*sz*cz;
- c2y = ccy - ssy;
- s2y = 2.0f*sy*cy;
- if(x->x_order >= 3)
- {
- c3z = cz*(4.0f*ccz - 3.0f);
- s3z = sz*(3.0f - 4.0f*ssz);
- c3y = cy*(4.0f*ccy - 3.0f);
- s3y = sy*(3.0f - 4.0f*ssy);
- if(x->x_order >= 4)
- {
- if(x->x_order >= 5)
- post("ambi_rot-ERROR: do not support Ambisonic-Order greater than 5 in zy-Rotation !!!");
-
- /*y
- r9_11=(35 + 28*c2 + c4)/64;
- r9_22=(7c + c3)/8;
- r9_31 = x->x_sqrt2*(14*s2 + s4)/32;
- r9_33=(7*c2 + c4)/8;
- r9_42 = x->x_sqrt2*(7*s + 3*s3)/16;
- r9_44=(7*c + 9*c3)/16;
- r9_51 = x->x_sqrt7*(5 - 4*c2 - c4)/32;
- r9_53 = x->x_sqrt14*(2*s2 + s4)/16;
- r9_55=(5 + 4*c2 + 7*c4)/16;
- r9_62 = x->x_sqrt7*(c - c3)/8;
- r9_64 = x->x_sqrt14*(-s + 3*s3)/16;
- r9_66=(c + 7*c3)/8;
- r9_71 = x->x_sqrt14*(2*s2 - s4)/32;
- r9_73 = x->x_sqrt7*(c2 - c4)/8;
- r9_75 = x->x_sqrt2*(-2*s2 + 7*s4)/16;
- r9_77=(c2 + 7*c4)/8;
- r9_82 = x->x_sqrt14*(3*s - s3)/16;
- r9_84 = x->x_sqrt7*(3*c - 3*c3)/16;
- r9_86 = x->x_sqrt2*(3*s + 7*s3)/16;
- r9_88=(9*c + 7*c3)/16;
- r9_91 = x->x_sqrt35*(3 - 4*c2 + c4)/64;
- r9_93 = x->x_sqrt70*(2*s2 - s4)/32;
- r9_95 = x->x_sqrt5*(3 + 4*c2 - 7*c4)/32;
- r9_97 = x->x_sqrt10*(2*s2 + 7*s4)/32;
- r9_99=(9 + 20*c2 + 35*c4)/64;
- */
-
- c4y = 1.0f + 8.0f*ccy*(ccy - 1.0f);
- s4y = 2.0f*s2y*c2y;
-
- c4z = 1.0f + 8.0f*ccz*(ccz - 1.0f);
- s4z = 2.0f*s2z*c2z;
-
- r9_y[0][0] = (35.0f + 28.0f*c2y + c4y)*0.015625f;/* -r9_31y, r9_51y, -r9_71y, r9_91y; */
- r9_y[1][1] = (7.0f*cy + c3y)*0.125f;/* -r9_42y, r9_62y, -r9_82y;*/
- r9_y[2][0] = x->x_sqrt2_16*(14.0f*s2y + s4y)*0.5f;
- r9_y[2][2] = (7.0f*c2y + c4y)*0.125f;/* -r9_53y, r9_73y, -r9_93y;*/
- r9_y[3][1] = x->x_sqrt2_16*(7.0f*sy + 3.0f*s3y);
- r9_y[3][3] = (7.0f*cy + 9.0f*c3y)*0.0625f;/* -r9_64y, r9_84y;*/
- r9_y[4][0] = x->x_sqrt7_8*(5.0f - 4.0f*c2y - c4y)*0.25f;
- r9_y[4][2] = x->x_sqrt14_16*(2.0f*s2y + s4y);
- r9_y[4][4] = (5.0f + 4.0f*c2y + 7.0f*c4y)*0.0625f;/* -r9_75y, r9_95y;*/
- r9_y[5][1] = x->x_sqrt7_8*(cy - c3y);
- r9_y[5][3] = x->x_sqrt14_16*(3.0f*s3y - sy);
- r9_y[5][5] = (cy + 7.0f*c3y)*0.125f;/* -r9_86y;*/
- r9_y[6][0] = x->x_sqrt14_16*(2.0f*s2y - s4y)*0.5f;
- r9_y[6][2] = x->x_sqrt7_8*(c2y - c4y);
- r9_y[6][4] = x->x_sqrt2_16*(7.0f*s4y - 2.0f*s2y);
- r9_y[6][6] = (c2y + 7.0f*c4y)*0.125f;/* -r9_97y;*/
- r9_y[7][1] = x->x_sqrt14_16*(3.0f*sy - s3y);
- r9_y[7][3] = x->x_sqrt7_8*(cy - c3y)*1.5f;
- r9_y[7][5] = x->x_sqrt2_16*(3.0f*sy + 7.0f*s3y);
- r9_y[7][7] = (9.0f*cy + 7.0f*c3y)*0.0625f;
- r9_y[8][0] = x->x_sqrt35_64*(3.0f - 4.0f*c2y + c4y);
- r9_y[8][2] = x->x_sqrt70_32*(2.0f*s2y - s4y);
- r9_y[8][4] = x->x_sqrt5_32*(3.0f + 4.0f*c2y - 7.0f*c4y);
- r9_y[8][6] = x->x_sqrt10_4*(2.0f*s2y + 7.0f*s4y)*0.125f;
- r9_y[8][8] = (9.0f + 20.0f*c2y + 35.0f*c4y)*0.015625f;
-
- r9_y[0][2] = -r9_y[2][0];
- r9_y[0][4] = r9_y[4][0];
- r9_y[0][6] = -r9_y[6][0];
- r9_y[0][8] = r9_y[8][0];
- r9_y[1][3] = -r9_y[3][1];
- r9_y[1][5] = r9_y[5][1];
- r9_y[1][7] = -r9_y[7][1];
- r9_y[2][4] = -r9_y[4][2];
- r9_y[2][6] = r9_y[6][2];
- r9_y[2][8] = -r9_y[8][2];
- r9_y[3][5] = -r9_y[5][3];
- r9_y[3][7] = r9_y[7][3];
- r9_y[4][6] = -r9_y[6][4];
- r9_y[4][8] = r9_y[8][4];
- r9_y[5][7] = -r9_y[7][5];
- r9_y[6][8] = -r9_y[8][6];
-
- at = x->x_at9;
- at += 2;
-
- for(i=0; i<8; i+=2)
- {
- SETFLOAT(at, c4z*r9_y[0][i]);
- at++;
- SETFLOAT(at, -s4z*r9_y[1][i+1]);
- at++;
- }
- SETFLOAT(at, c4z*r9_y[0][8]);
- at++;
-
- for(i=0; i<8; i+=2)
- {
- SETFLOAT(at, c4z*r9_y[0][i]);
- at++;
- SETFLOAT(at, s4z*r9_y[1][i+1]);
- at++;
- }
- SETFLOAT(at, s4z*r9_y[0][8]);
- at++;
-
- for(i=0; i<8; i+=2)
- {
- SETFLOAT(at, c3z*r9_y[2][i]);
- at++;
- SETFLOAT(at, -s3z*r9_y[3][i+1]);
- at++;
- }
- SETFLOAT(at, c3z*r9_y[2][8]);
- at++;
-
- for(i=0; i<8; i+=2)
- {
- SETFLOAT(at, c3z*r9_y[2][i]);
- at++;
- SETFLOAT(at, s3z*r9_y[3][i+1]);
- at++;
- }
- SETFLOAT(at, s3z*r9_y[2][8]);
- at++;
-
- for(i=0; i<8; i+=2)
- {
- SETFLOAT(at, c2z*r9_y[4][i]);
- at++;
- SETFLOAT(at, -s2z*r9_y[5][i+1]);
- at++;
- }
- SETFLOAT(at, c2z*r9_y[4][8]);
- at++;
-
- for(i=0; i<8; i+=2)
- {
- SETFLOAT(at, c2z*r9_y[4][i]);
- at++;
- SETFLOAT(at, s2z*r9_y[5][i+1]);
- at++;
- }
- SETFLOAT(at, s2z*r9_y[4][8]);
- at++;
-
- for(i=0; i<8; i+=2)
- {
- SETFLOAT(at, cz*r9_y[6][i]);
- at++;
- SETFLOAT(at, -sz*r9_y[7][i+1]);
- at++;
- }
- SETFLOAT(at, cz*r9_y[6][8]);
- at++;
-
- for(i=0; i<8; i+=2)
- {
- SETFLOAT(at, cz*r9_y[6][i]);
- at++;
- SETFLOAT(at, sz*r9_y[7][i+1]);
- at++;
- }
- SETFLOAT(at, sz*r9_y[6][8]);
- at++;
-
- for(i=0; i<8; i+=2)
- {
- SETFLOAT(at, r9_y[8][i]);
- at++;
- SETFLOAT(at, 0.0f);
- at++;
- }
- SETFLOAT(at, r9_y[8][8]);
-
- outlet_anything(x->x_out9, x->x_s_matrix, x->x_size9, x->x_at9);
- }
-
- /*y
- r7_11=(15*c + c3)/16;
- r7_22=(5 + 3*c2)/8;
- r7_31 = x->x_sqrt6*(5*s + s3)/16;
- r7_33=(5*c + 3*c3)/8;
- r7_42 = x->x_sqrt6*(s2)/4;
- r7_44=(c2);
- r7_51 = x->x_sqrt15*(c - c3)/16;
- r7_53 = x->x_sqrt10*(-s + 3*s3)/16;
- r7_55=(c + 15*c3)/16;
- r7_62 = x->x_sqrt15*(1 - c2)/8;
- r7_64 = x->x_sqrt10*(s2)/4;
- r7_66=(3 + 5*c2)/8;
- r7_71 = x->x_sqrt10*(3*s - s3)/16;
- r7_73 = x->x_sqrt15*(c - c3)/8 = 2*r7_51;
- r7_75 = x->x_sqrt6*(s + 5*s3)/16;
- r7_77=(3*c + 5*c3)/8;
-
- */
- r9_y[0][0] = (15.0f*cy + c3y)*0.0625f;/* -r7_31y, r7_51y, -r7_71y;*/
- r9_y[1][1] = (5.0f + 3.0f*c2y)*0.125f;/* -r7_42y, r7_62y;*/
- r9_y[2][0] = x->x_sqrt6_4*(5.0f*sy + s3y)*0.25f;
- r9_y[2][2] = (5.0f*cy + 3.0f*c3y)*0.125f;/* -r7_53y, r7_73y;*/
- r9_y[3][1] = x->x_sqrt6_4*s2y;
- r9_y[3][3] = c2y;/* -r7_64y;*/
- r9_y[6][2] = x->x_sqrt15_8*(cy - c3y);
- r9_y[4][0] = r9_y[6][2]*0.5f;
- r9_y[4][2] = x->x_sqrt10_4*(3.0f*s3y - sy)*0.25f;
- r9_y[4][4] = (cy + 15.0f*c3y)*0.0625f;/* -r7_75y;*/
- r9_y[5][1] = x->x_sqrt15_8*(1.0f - c2y);
- r9_y[5][3] = x->x_sqrt10_4*s2y;
- r9_y[5][5] = (3.0f + 5.0f*c2y)*0.125f;
- r9_y[6][0] = x->x_sqrt10_4*(3.0f*sy - s3y)*0.25f;
-
- r9_y[6][4] = x->x_sqrt6_4*(sy + 5.0f*s3y)*0.25f;
- r9_y[6][6] = (3.0f*cy + 5.0f*c3y)*0.125f;
-
- r9_y[0][2] = -r9_y[2][0];
- r9_y[0][4] = r9_y[4][0];
- r9_y[0][6] = -r9_y[6][0];
- r9_y[1][3] = -r9_y[3][1];
- r9_y[1][5] = r9_y[5][1];
- r9_y[2][4] = -r9_y[4][2];
- r9_y[2][6] = r9_y[6][2];
- r9_y[3][5] = -r9_y[5][3];
- r9_y[4][6] = -r9_y[6][4];
-
- at = x->x_at7;
- at += 2;
-
- for(i=0; i<6; i+=2)
- {
- SETFLOAT(at, c3z*r9_y[0][i]);
- at++;
- SETFLOAT(at, -s3z*r9_y[1][i+1]);
- at++;
- }
- SETFLOAT(at, c3z*r9_y[0][6]);
- at++;
-
- for(i=0; i<6; i+=2)
- {
- SETFLOAT(at, c3z*r9_y[0][i]);
- at++;
- SETFLOAT(at, s3z*r9_y[1][i+1]);
- at++;
- }
- SETFLOAT(at, s3z*r9_y[0][6]);
- at++;
-
- for(i=0; i<6; i+=2)
- {
- SETFLOAT(at, c2z*r9_y[2][i]);
- at++;
- SETFLOAT(at, -s2z*r9_y[3][i+1]);
- at++;
- }
- SETFLOAT(at, c2z*r9_y[2][6]);
- at++;
-
- for(i=0; i<6; i+=2)
- {
- SETFLOAT(at, c2z*r9_y[2][i]);
- at++;
- SETFLOAT(at, s2z*r9_y[3][i+1]);
- at++;
- }
- SETFLOAT(at, s2z*r9_y[2][6]);
- at++;
-
- for(i=0; i<6; i+=2)
- {
- SETFLOAT(at, cz*r9_y[4][i]);
- at++;
- SETFLOAT(at, -sz*r9_y[5][i+1]);
- at++;
- }
- SETFLOAT(at, cz*r9_y[4][6]);
- at++;
-
- for(i=0; i<6; i+=2)
- {
- SETFLOAT(at, cz*r9_y[4][i]);
- at++;
- SETFLOAT(at, sz*r9_y[5][i+1]);
- at++;
- }
- SETFLOAT(at, sz*r9_y[4][6]);
- at++;
-
- for(i=0; i<6; i+=2)
- {
- SETFLOAT(at, r9_y[6][i]);
- at++;
- SETFLOAT(at, 0.0f);
- at++;
- }
- SETFLOAT(at, r9_y[6][6]);
-
- outlet_anything(x->x_out7, x->x_s_matrix, x->x_size7, x->x_at7);
- }
-
- /*y
- r5_11=(3 + c2)/4;
- r5_22=(c);
- r5_31 = (s2)/2;
- r5_33=(c2);
- r5_42 = (s);
- r5_44=(c);
- r5_51 = x->x_sqrt3*(1 - c2)/4;
- r5_53 = x->x_sqrt3*(s2)/2;
- r5_55=(1 + 3*c2)/4;
- */
- r9_y[0][0] = (3.0f + c2y)*0.25f;/* -r5_31y, r5_51y;*/
- r9_y[1][1] = cy;/* -r5_42y;*/
- r9_y[2][0] = s2y*0.5f;
- r9_y[2][2] = c2y;/* -r5_53y;*/
- r9_y[3][1] = sy;
- r9_y[3][3] = cy;
- r9_y[4][0] = x->x_sqrt3_2*(1.0f - c2y)*0.5f;
- r9_y[4][2] = x->x_sqrt3_2*s2y;
- r9_y[4][4] = (1.0f + 3.0f*c2y)*0.25f;
-
- r9_y[0][2] = -r9_y[2][0];
- r9_y[0][4] = r9_y[4][0];
- r9_y[1][3] = -r9_y[3][1];
- r9_y[2][4] = -r9_y[4][2];
-
- at = x->x_at5;
- at += 2;
-
- for(i=0; i<4; i+=2)
- {
- SETFLOAT(at, c2z*r9_y[0][i]);
- at++;
- SETFLOAT(at, -s2z*r9_y[1][i+1]);
- at++;
- }
- SETFLOAT(at, c2z*r9_y[0][4]);
- at++;
-
- for(i=0; i<4; i+=2)
- {
- SETFLOAT(at, c2z*r9_y[0][i]);
- at++;
- SETFLOAT(at, s2z*r9_y[1][i+1]);
- at++;
- }
- SETFLOAT(at, s2z*r9_y[0][4]);
- at++;
-
- for(i=0; i<4; i+=2)
- {
- SETFLOAT(at, cz*r9_y[2][i]);
- at++;
- SETFLOAT(at, -sz*r9_y[3][i+1]);
- at++;
- }
- SETFLOAT(at, cz*r9_y[2][4]);
- at++;
-
- for(i=0; i<4; i+=2)
- {
- SETFLOAT(at, cz*r9_y[2][i]);
- at++;
- SETFLOAT(at, sz*r9_y[3][i+1]);
- at++;
- }
- SETFLOAT(at, sz*r9_y[2][4]);
- at++;
-
- for(i=0; i<4; i+=2)
- {
- SETFLOAT(at, r9_y[4][i]);
- at++;
- SETFLOAT(at, 0.0f);
- at++;
- }
- SETFLOAT(at, r9_y[4][4]);
-
- outlet_anything(x->x_out5, x->x_s_matrix, x->x_size5, x->x_at5);
- }
-
- /*y
- r3_11=(c);
- r3_22=(1);
- r3_31 = (s);
- r3_33=(c);
- */
- r9_y[0][0] = cy;/* -r3_31y;*/
- r9_y[1][1] = 1.0f;
- r9_y[2][0] = sy;
- r9_y[2][2] = cy;
- r9_y[0][2] = -r9_y[2][0];
-
- at = x->x_at3;
- at += 2;
-
- SETFLOAT(at, cz*r9_y[0][0]);
- at++;
- SETFLOAT(at, -sz*r9_y[1][1]);
- at++;
- SETFLOAT(at, cz*r9_y[0][2]);
- at++;
-
- SETFLOAT(at, sz*r9_y[0][0]);
- at++;
- SETFLOAT(at, cz*r9_y[1][1]);
- at++;
- SETFLOAT(at, sz*r9_y[0][2]);
- at++;
-
- SETFLOAT(at, r9_y[2][0]);
- at++;
- SETFLOAT(at, 0.0f);
- at++;
- SETFLOAT(at, r9_y[2][2]);
-
- outlet_anything(x->x_out3, x->x_s_matrix, x->x_size3, x->x_at3);
+ t_float cy, sy, ccy, ssy, c2y, s2y, c3y, s3y, c4y, s4y;
+ t_float cz, sz, ccz, ssz, c2z, s2z, c3z, s3z, c4z, s4z;
+ t_float r9_y[9][9];
+ int i;
+ t_atom *at;
+
+ rho_z *= x->x_pi_over_180;
+ rho_y *= x->x_pi_over_180;
+
+ cz = cos(rho_z);
+ sz = sin(rho_z);
+ ccz = cz*cz;
+ ssz = sz*sz;
+
+ cy = cos(rho_y);
+ sy = sin(rho_y);
+ ccy = cy*cy;
+ ssy = sy*sy;
+
+ if(x->x_order >= 2)
+ {
+ c2z = ccz - ssz;
+ s2z = 2.0f*sz*cz;
+ c2y = ccy - ssy;
+ s2y = 2.0f*sy*cy;
+ if(x->x_order >= 3)
+ {
+ c3z = cz*(4.0f*ccz - 3.0f);
+ s3z = sz*(3.0f - 4.0f*ssz);
+ c3y = cy*(4.0f*ccy - 3.0f);
+ s3y = sy*(3.0f - 4.0f*ssy);
+ if(x->x_order >= 4)
+ {
+ if(x->x_order >= 5)
+ post("ambi_rot-ERROR: do not support Ambisonic-Order greater than 5 in zy-Rotation !!!");
+
+ /*y
+ r9_11=(35 + 28*c2 + c4)/64;
+ r9_22=(7c + c3)/8;
+ r9_31 = x->x_sqrt2*(14*s2 + s4)/32;
+ r9_33=(7*c2 + c4)/8;
+ r9_42 = x->x_sqrt2*(7*s + 3*s3)/16;
+ r9_44=(7*c + 9*c3)/16;
+ r9_51 = x->x_sqrt7*(5 - 4*c2 - c4)/32;
+ r9_53 = x->x_sqrt14*(2*s2 + s4)/16;
+ r9_55=(5 + 4*c2 + 7*c4)/16;
+ r9_62 = x->x_sqrt7*(c - c3)/8;
+ r9_64 = x->x_sqrt14*(-s + 3*s3)/16;
+ r9_66=(c + 7*c3)/8;
+ r9_71 = x->x_sqrt14*(2*s2 - s4)/32;
+ r9_73 = x->x_sqrt7*(c2 - c4)/8;
+ r9_75 = x->x_sqrt2*(-2*s2 + 7*s4)/16;
+ r9_77=(c2 + 7*c4)/8;
+ r9_82 = x->x_sqrt14*(3*s - s3)/16;
+ r9_84 = x->x_sqrt7*(3*c - 3*c3)/16;
+ r9_86 = x->x_sqrt2*(3*s + 7*s3)/16;
+ r9_88=(9*c + 7*c3)/16;
+ r9_91 = x->x_sqrt35*(3 - 4*c2 + c4)/64;
+ r9_93 = x->x_sqrt70*(2*s2 - s4)/32;
+ r9_95 = x->x_sqrt5*(3 + 4*c2 - 7*c4)/32;
+ r9_97 = x->x_sqrt10*(2*s2 + 7*s4)/32;
+ r9_99=(9 + 20*c2 + 35*c4)/64;
+ */
+
+ c4y = 1.0f + 8.0f*ccy*(ccy - 1.0f);
+ s4y = 2.0f*s2y*c2y;
+
+ c4z = 1.0f + 8.0f*ccz*(ccz - 1.0f);
+ s4z = 2.0f*s2z*c2z;
+
+ r9_y[0][0] = (35.0f + 28.0f*c2y + c4y)*0.015625f;/* -r9_31y, r9_51y, -r9_71y, r9_91y; */
+ r9_y[1][1] = (7.0f*cy + c3y)*0.125f;/* -r9_42y, r9_62y, -r9_82y;*/
+ r9_y[2][0] = x->x_sqrt2_16*(14.0f*s2y + s4y)*0.5f;
+ r9_y[2][2] = (7.0f*c2y + c4y)*0.125f;/* -r9_53y, r9_73y, -r9_93y;*/
+ r9_y[3][1] = x->x_sqrt2_16*(7.0f*sy + 3.0f*s3y);
+ r9_y[3][3] = (7.0f*cy + 9.0f*c3y)*0.0625f;/* -r9_64y, r9_84y;*/
+ r9_y[4][0] = x->x_sqrt7_8*(5.0f - 4.0f*c2y - c4y)*0.25f;
+ r9_y[4][2] = x->x_sqrt14_16*(2.0f*s2y + s4y);
+ r9_y[4][4] = (5.0f + 4.0f*c2y + 7.0f*c4y)*0.0625f;/* -r9_75y, r9_95y;*/
+ r9_y[5][1] = x->x_sqrt7_8*(cy - c3y);
+ r9_y[5][3] = x->x_sqrt14_16*(3.0f*s3y - sy);
+ r9_y[5][5] = (cy + 7.0f*c3y)*0.125f;/* -r9_86y;*/
+ r9_y[6][0] = x->x_sqrt14_16*(2.0f*s2y - s4y)*0.5f;
+ r9_y[6][2] = x->x_sqrt7_8*(c2y - c4y);
+ r9_y[6][4] = x->x_sqrt2_16*(7.0f*s4y - 2.0f*s2y);
+ r9_y[6][6] = (c2y + 7.0f*c4y)*0.125f;/* -r9_97y;*/
+ r9_y[7][1] = x->x_sqrt14_16*(3.0f*sy - s3y);
+ r9_y[7][3] = x->x_sqrt7_8*(cy - c3y)*1.5f;
+ r9_y[7][5] = x->x_sqrt2_16*(3.0f*sy + 7.0f*s3y);
+ r9_y[7][7] = (9.0f*cy + 7.0f*c3y)*0.0625f;
+ r9_y[8][0] = x->x_sqrt35_64*(3.0f - 4.0f*c2y + c4y);
+ r9_y[8][2] = x->x_sqrt70_32*(2.0f*s2y - s4y);
+ r9_y[8][4] = x->x_sqrt5_32*(3.0f + 4.0f*c2y - 7.0f*c4y);
+ r9_y[8][6] = x->x_sqrt10_4*(2.0f*s2y + 7.0f*s4y)*0.125f;
+ r9_y[8][8] = (9.0f + 20.0f*c2y + 35.0f*c4y)*0.015625f;
+
+ r9_y[0][2] = -r9_y[2][0];
+ r9_y[0][4] = r9_y[4][0];
+ r9_y[0][6] = -r9_y[6][0];
+ r9_y[0][8] = r9_y[8][0];
+ r9_y[1][3] = -r9_y[3][1];
+ r9_y[1][5] = r9_y[5][1];
+ r9_y[1][7] = -r9_y[7][1];
+ r9_y[2][4] = -r9_y[4][2];
+ r9_y[2][6] = r9_y[6][2];
+ r9_y[2][8] = -r9_y[8][2];
+ r9_y[3][5] = -r9_y[5][3];
+ r9_y[3][7] = r9_y[7][3];
+ r9_y[4][6] = -r9_y[6][4];
+ r9_y[4][8] = r9_y[8][4];
+ r9_y[5][7] = -r9_y[7][5];
+ r9_y[6][8] = -r9_y[8][6];
+
+ at = x->x_at9;
+ at += 2;
+
+ for(i=0; i<8; i+=2)
+ {
+ SETFLOAT(at, c4z*r9_y[0][i]);
+ at++;
+ SETFLOAT(at, -s4z*r9_y[1][i+1]);
+ at++;
+ }
+ SETFLOAT(at, c4z*r9_y[0][8]);
+ at++;
+
+ for(i=0; i<8; i+=2)
+ {
+ SETFLOAT(at, c4z*r9_y[0][i]);
+ at++;
+ SETFLOAT(at, s4z*r9_y[1][i+1]);
+ at++;
+ }
+ SETFLOAT(at, s4z*r9_y[0][8]);
+ at++;
+
+ for(i=0; i<8; i+=2)
+ {
+ SETFLOAT(at, c3z*r9_y[2][i]);
+ at++;
+ SETFLOAT(at, -s3z*r9_y[3][i+1]);
+ at++;
+ }
+ SETFLOAT(at, c3z*r9_y[2][8]);
+ at++;
+
+ for(i=0; i<8; i+=2)
+ {
+ SETFLOAT(at, c3z*r9_y[2][i]);
+ at++;
+ SETFLOAT(at, s3z*r9_y[3][i+1]);
+ at++;
+ }
+ SETFLOAT(at, s3z*r9_y[2][8]);
+ at++;
+
+ for(i=0; i<8; i+=2)
+ {
+ SETFLOAT(at, c2z*r9_y[4][i]);
+ at++;
+ SETFLOAT(at, -s2z*r9_y[5][i+1]);
+ at++;
+ }
+ SETFLOAT(at, c2z*r9_y[4][8]);
+ at++;
+
+ for(i=0; i<8; i+=2)
+ {
+ SETFLOAT(at, c2z*r9_y[4][i]);
+ at++;
+ SETFLOAT(at, s2z*r9_y[5][i+1]);
+ at++;
+ }
+ SETFLOAT(at, s2z*r9_y[4][8]);
+ at++;
+
+ for(i=0; i<8; i+=2)
+ {
+ SETFLOAT(at, cz*r9_y[6][i]);
+ at++;
+ SETFLOAT(at, -sz*r9_y[7][i+1]);
+ at++;
+ }
+ SETFLOAT(at, cz*r9_y[6][8]);
+ at++;
+
+ for(i=0; i<8; i+=2)
+ {
+ SETFLOAT(at, cz*r9_y[6][i]);
+ at++;
+ SETFLOAT(at, sz*r9_y[7][i+1]);
+ at++;
+ }
+ SETFLOAT(at, sz*r9_y[6][8]);
+ at++;
+
+ for(i=0; i<8; i+=2)
+ {
+ SETFLOAT(at, r9_y[8][i]);
+ at++;
+ SETFLOAT(at, 0.0f);
+ at++;
+ }
+ SETFLOAT(at, r9_y[8][8]);
+
+ outlet_anything(x->x_out9, x->x_s_matrix, x->x_size9, x->x_at9);
+ }
+
+ /*y
+ r7_11=(15*c + c3)/16;
+ r7_22=(5 + 3*c2)/8;
+ r7_31 = x->x_sqrt6*(5*s + s3)/16;
+ r7_33=(5*c + 3*c3)/8;
+ r7_42 = x->x_sqrt6*(s2)/4;
+ r7_44=(c2);
+ r7_51 = x->x_sqrt15*(c - c3)/16;
+ r7_53 = x->x_sqrt10*(-s + 3*s3)/16;
+ r7_55=(c + 15*c3)/16;
+ r7_62 = x->x_sqrt15*(1 - c2)/8;
+ r7_64 = x->x_sqrt10*(s2)/4;
+ r7_66=(3 + 5*c2)/8;
+ r7_71 = x->x_sqrt10*(3*s - s3)/16;
+ r7_73 = x->x_sqrt15*(c - c3)/8 = 2*r7_51;
+ r7_75 = x->x_sqrt6*(s + 5*s3)/16;
+ r7_77=(3*c + 5*c3)/8;
+
+ */
+ r9_y[0][0] = (15.0f*cy + c3y)*0.0625f;/* -r7_31y, r7_51y, -r7_71y;*/
+ r9_y[1][1] = (5.0f + 3.0f*c2y)*0.125f;/* -r7_42y, r7_62y;*/
+ r9_y[2][0] = x->x_sqrt6_4*(5.0f*sy + s3y)*0.25f;
+ r9_y[2][2] = (5.0f*cy + 3.0f*c3y)*0.125f;/* -r7_53y, r7_73y;*/
+ r9_y[3][1] = x->x_sqrt6_4*s2y;
+ r9_y[3][3] = c2y;/* -r7_64y;*/
+ r9_y[6][2] = x->x_sqrt15_8*(cy - c3y);
+ r9_y[4][0] = r9_y[6][2]*0.5f;
+ r9_y[4][2] = x->x_sqrt10_4*(3.0f*s3y - sy)*0.25f;
+ r9_y[4][4] = (cy + 15.0f*c3y)*0.0625f;/* -r7_75y;*/
+ r9_y[5][1] = x->x_sqrt15_8*(1.0f - c2y);
+ r9_y[5][3] = x->x_sqrt10_4*s2y;
+ r9_y[5][5] = (3.0f + 5.0f*c2y)*0.125f;
+ r9_y[6][0] = x->x_sqrt10_4*(3.0f*sy - s3y)*0.25f;
+
+ r9_y[6][4] = x->x_sqrt6_4*(sy + 5.0f*s3y)*0.25f;
+ r9_y[6][6] = (3.0f*cy + 5.0f*c3y)*0.125f;
+
+ r9_y[0][2] = -r9_y[2][0];
+ r9_y[0][4] = r9_y[4][0];
+ r9_y[0][6] = -r9_y[6][0];
+ r9_y[1][3] = -r9_y[3][1];
+ r9_y[1][5] = r9_y[5][1];
+ r9_y[2][4] = -r9_y[4][2];
+ r9_y[2][6] = r9_y[6][2];
+ r9_y[3][5] = -r9_y[5][3];
+ r9_y[4][6] = -r9_y[6][4];
+
+ at = x->x_at7;
+ at += 2;
+
+ for(i=0; i<6; i+=2)
+ {
+ SETFLOAT(at, c3z*r9_y[0][i]);
+ at++;
+ SETFLOAT(at, -s3z*r9_y[1][i+1]);
+ at++;
+ }
+ SETFLOAT(at, c3z*r9_y[0][6]);
+ at++;
+
+ for(i=0; i<6; i+=2)
+ {
+ SETFLOAT(at, c3z*r9_y[0][i]);
+ at++;
+ SETFLOAT(at, s3z*r9_y[1][i+1]);
+ at++;
+ }
+ SETFLOAT(at, s3z*r9_y[0][6]);
+ at++;
+
+ for(i=0; i<6; i+=2)
+ {
+ SETFLOAT(at, c2z*r9_y[2][i]);
+ at++;
+ SETFLOAT(at, -s2z*r9_y[3][i+1]);
+ at++;
+ }
+ SETFLOAT(at, c2z*r9_y[2][6]);
+ at++;
+
+ for(i=0; i<6; i+=2)
+ {
+ SETFLOAT(at, c2z*r9_y[2][i]);
+ at++;
+ SETFLOAT(at, s2z*r9_y[3][i+1]);
+ at++;
+ }
+ SETFLOAT(at, s2z*r9_y[2][6]);
+ at++;
+
+ for(i=0; i<6; i+=2)
+ {
+ SETFLOAT(at, cz*r9_y[4][i]);
+ at++;
+ SETFLOAT(at, -sz*r9_y[5][i+1]);
+ at++;
+ }
+ SETFLOAT(at, cz*r9_y[4][6]);
+ at++;
+
+ for(i=0; i<6; i+=2)
+ {
+ SETFLOAT(at, cz*r9_y[4][i]);
+ at++;
+ SETFLOAT(at, sz*r9_y[5][i+1]);
+ at++;
+ }
+ SETFLOAT(at, sz*r9_y[4][6]);
+ at++;
+
+ for(i=0; i<6; i+=2)
+ {
+ SETFLOAT(at, r9_y[6][i]);
+ at++;
+ SETFLOAT(at, 0.0f);
+ at++;
+ }
+ SETFLOAT(at, r9_y[6][6]);
+
+ outlet_anything(x->x_out7, x->x_s_matrix, x->x_size7, x->x_at7);
+ }
+
+ /*y
+ r5_11=(3 + c2)/4;
+ r5_22=(c);
+ r5_31 = (s2)/2;
+ r5_33=(c2);
+ r5_42 = (s);
+ r5_44=(c);
+ r5_51 = x->x_sqrt3*(1 - c2)/4;
+ r5_53 = x->x_sqrt3*(s2)/2;
+ r5_55=(1 + 3*c2)/4;
+ */
+ r9_y[0][0] = (3.0f + c2y)*0.25f;/* -r5_31y, r5_51y;*/
+ r9_y[1][1] = cy;/* -r5_42y;*/
+ r9_y[2][0] = s2y*0.5f;
+ r9_y[2][2] = c2y;/* -r5_53y;*/
+ r9_y[3][1] = sy;
+ r9_y[3][3] = cy;
+ r9_y[4][0] = x->x_sqrt3_2*(1.0f - c2y)*0.5f;
+ r9_y[4][2] = x->x_sqrt3_2*s2y;
+ r9_y[4][4] = (1.0f + 3.0f*c2y)*0.25f;
+
+ r9_y[0][2] = -r9_y[2][0];
+ r9_y[0][4] = r9_y[4][0];
+ r9_y[1][3] = -r9_y[3][1];
+ r9_y[2][4] = -r9_y[4][2];
+
+ at = x->x_at5;
+ at += 2;
+
+ for(i=0; i<4; i+=2)
+ {
+ SETFLOAT(at, c2z*r9_y[0][i]);
+ at++;
+ SETFLOAT(at, -s2z*r9_y[1][i+1]);
+ at++;
+ }
+ SETFLOAT(at, c2z*r9_y[0][4]);
+ at++;
+
+ for(i=0; i<4; i+=2)
+ {
+ SETFLOAT(at, c2z*r9_y[0][i]);
+ at++;
+ SETFLOAT(at, s2z*r9_y[1][i+1]);
+ at++;
+ }
+ SETFLOAT(at, s2z*r9_y[0][4]);
+ at++;
+
+ for(i=0; i<4; i+=2)
+ {
+ SETFLOAT(at, cz*r9_y[2][i]);
+ at++;
+ SETFLOAT(at, -sz*r9_y[3][i+1]);
+ at++;
+ }
+ SETFLOAT(at, cz*r9_y[2][4]);
+ at++;
+
+ for(i=0; i<4; i+=2)
+ {
+ SETFLOAT(at, cz*r9_y[2][i]);
+ at++;
+ SETFLOAT(at, sz*r9_y[3][i+1]);
+ at++;
+ }
+ SETFLOAT(at, sz*r9_y[2][4]);
+ at++;
+
+ for(i=0; i<4; i+=2)
+ {
+ SETFLOAT(at, r9_y[4][i]);
+ at++;
+ SETFLOAT(at, 0.0f);
+ at++;
+ }
+ SETFLOAT(at, r9_y[4][4]);
+
+ outlet_anything(x->x_out5, x->x_s_matrix, x->x_size5, x->x_at5);
+ }
+
+ /*y
+ r3_11=(c);
+ r3_22=(1);
+ r3_31 = (s);
+ r3_33=(c);
+ */
+ r9_y[0][0] = cy;/* -r3_31y;*/
+ r9_y[1][1] = 1.0f;
+ r9_y[2][0] = sy;
+ r9_y[2][2] = cy;
+ r9_y[0][2] = -r9_y[2][0];
+
+ at = x->x_at3;
+ at += 2;
+
+ SETFLOAT(at, cz*r9_y[0][0]);
+ at++;
+ SETFLOAT(at, -sz*r9_y[1][1]);
+ at++;
+ SETFLOAT(at, cz*r9_y[0][2]);
+ at++;
+
+ SETFLOAT(at, sz*r9_y[0][0]);
+ at++;
+ SETFLOAT(at, cz*r9_y[1][1]);
+ at++;
+ SETFLOAT(at, sz*r9_y[0][2]);
+ at++;
+
+ SETFLOAT(at, r9_y[2][0]);
+ at++;
+ SETFLOAT(at, 0.0f);
+ at++;
+ SETFLOAT(at, r9_y[2][2]);
+
+ outlet_anything(x->x_out3, x->x_s_matrix, x->x_size3, x->x_at3);
}
-static void ambi_rot_zyx(t_ambi_rot *x, float rho_z, float rho_y, float rho_x)
+static void ambi_rot_zyx(t_ambi_rot *x, t_floatarg rho_z, t_floatarg rho_y, t_floatarg rho_x)
{
- float cx, sx, ccx, ssx, c2x, s2x, c3x, s3x, c4x, s4x;
- float cy, sy, ccy, ssy, c2y, s2y, c3y, s3y, c4y, s4y;
- float cz, sz, ccz, ssz, c2z, s2z, c3z, s3z, c4z, s4z;
- float r9_zy[9][9];
- float r9_z[9][9];
- float r9_y[9][9];
- float r9_x[9][9];
- int i, j;
- t_atom *at;
-
- rho_z *= x->x_pi_over_180;
- rho_y *= x->x_pi_over_180;
- rho_x *= x->x_pi_over_180;
-
- cz = cos(rho_z);
- sz = sin(rho_z);
- ccz = cz*cz;
- ssz = sz*sz;
-
- cy = cos(rho_y);
- sy = sin(rho_y);
- ccy = cy*cy;
- ssy = sy*sy;
-
- cx = cos(rho_x);
- sx = sin(rho_x);
- ccx = cx*cx;
- ssx = sx*sx;
-
- if(x->x_order >= 2)
- {
- c2z = ccz - ssz;
- s2z = 2.0f*sz*cz;
- c2y = ccy - ssy;
- s2y = 2.0f*sy*cy;
- c2x = ccx - ssx;
- s2x = 2.0f*sx*cx;
-
- if(x->x_order >= 3)
- {
- c3z = cz*(4.0f*ccz - 3.0f);
- s3z = sz*(3.0f - 4.0f*ssz);
- c3y = cy*(4.0f*ccy - 3.0f);
- s3y = sy*(3.0f - 4.0f*ssy);
- c3x = cx*(4.0f*ccx - 3.0f);
- s3x = sx*(3.0f - 4.0f*ssx);
-
- if(x->x_order >= 4)
- {
- if(x->x_order >= 5)
- post("ambi_rot-ERROR: do not support Ambisonic-Order greater than 5 in zyx-Rotation !!!");
-
- c4z = 1.0f + 8.0f*ccz*(ccz - 1.0f);
- s4z = 2.0f*s2z*c2z;
-
- c4y = 1.0f + 8.0f*ccy*(ccy - 1.0f);
- s4y = 2.0f*s2y*c2y;
-
- c4x = 1.0f + 8.0f*ccx*(ccx - 1.0f);
- s4x = 2.0f*s2x*c2x;
-
- r9_z[0][0] = c4z;
- r9_z[0][1] = -s4z;
- r9_z[1][0] = s4z;
- r9_z[1][1] = c4z;
- r9_z[2][2] = c3z;
- r9_z[2][3] = -s3z;
- r9_z[3][2] = s3z;
- r9_z[3][3] = c3z;
- r9_z[4][4] = c2z;
- r9_z[4][5] = -s2z;
- r9_z[5][4] = s2z;
- r9_z[5][5] = c2z;
- r9_z[6][6] = cz;
- r9_z[6][7] = -sz;
- r9_z[7][6] = sz;
- r9_z[7][7] = cz;
- r9_z[8][8] = 1.0f;
- /*y
- r9_11=(35 + 28*c2 + c4)/64;
- r9_22=(7c + c3)/8;
- r9_31 = x->x_sqrt2*(14*s2 + s4)/32;
- r9_33=(7*c2 + c4)/8;
- r9_42 = x->x_sqrt2*(7*s + 3*s3)/16;
- r9_44=(7*c + 9*c3)/16;
- r9_51 = x->x_sqrt7*(5 - 4*c2 - c4)/32;
- r9_53 = x->x_sqrt14*(2*s2 + s4)/16;
- r9_55=(5 + 4*c2 + 7*c4)/16;
- r9_62 = x->x_sqrt7*(c - c3)/8;
- r9_64 = x->x_sqrt14*(-s + 3*s3)/16;
- r9_66=(c + 7*c3)/8;
- r9_71 = x->x_sqrt14*(2*s2 - s4)/32;
- r9_73 = x->x_sqrt7*(c2 - c4)/8;
- r9_75 = x->x_sqrt2*(-2*s2 + 7*s4)/16;
- r9_77=(c2 + 7*c4)/8;
- r9_82 = x->x_sqrt14*(3*s - s3)/16;
- r9_84 = x->x_sqrt7*(3*c - 3*c3)/16;
- r9_86 = x->x_sqrt2*(3*s + 7*s3)/16;
- r9_88=(9*c + 7*c3)/16;
- r9_91 = x->x_sqrt35*(3 - 4*c2 + c4)/64;
- r9_93 = x->x_sqrt70*(2*s2 - s4)/32;
- r9_95 = x->x_sqrt5*(3 + 4*c2 - 7*c4)/32;
- r9_97 = x->x_sqrt10*(2*s2 + 7*s4)/32;
- r9_99=(9 + 20*c2 + 35*c4)/64;
- */
- r9_y[0][0] = (35.0f + 28.0f*c2y + c4y)*0.015625f;/* -r9_31y, r9_51y, -r9_71y, r9_91y; */
- r9_y[1][1] = (7.0f*cy + c3y)*0.125f;/* -r9_42y, r9_62y, -r9_82y;*/
- r9_y[2][0] = x->x_sqrt2_16*(14.0f*s2y + s4y)*0.5f;
- r9_y[2][2] = (7.0f*c2y + c4y)*0.125f;/* -r9_53y, r9_73y, -r9_93y;*/
- r9_y[3][1] = x->x_sqrt2_16*(7.0f*sy + 3.0f*s3y);
- r9_y[3][3] = (7.0f*cy + 9.0f*c3y)*0.0625f;/* -r9_64y, r9_84y;*/
- r9_y[4][0] = x->x_sqrt7_8*(5.0f - 4.0f*c2y - c4y)*0.25f;
- r9_y[4][2] = x->x_sqrt14_16*(2.0f*s2y + s4y);
- r9_y[4][4] = (5.0f + 4.0f*c2y + 7.0f*c4y)*0.0625f;/* -r9_75y, r9_95y;*/
- r9_y[5][1] = x->x_sqrt7_8*(cy - c3y);
- r9_y[5][3] = x->x_sqrt14_16*(3.0f*s3y - sy);
- r9_y[5][5] = (cy + 7.0f*c3y)*0.125f;/* -r9_86y;*/
- r9_y[6][0] = x->x_sqrt14_16*(2.0f*s2y - s4y)*0.5f;
- r9_y[6][2] = x->x_sqrt7_8*(c2y - c4y);
- r9_y[6][4] = x->x_sqrt2_16*(7.0f*s4y - 2.0f*s2y);
- r9_y[6][6] = (c2y + 7.0f*c4y)*0.125f;/* -r9_97y;*/
- r9_y[7][1] = x->x_sqrt14_16*(3.0f*sy - s3y);
- r9_y[7][3] = x->x_sqrt7_8*(cy - c3y)*1.5f;
- r9_y[7][5] = x->x_sqrt2_16*(3.0f*sy + 7.0f*s3y);
- r9_y[7][7] = (9.0f*cy + 7.0f*c3y)*0.0625f;
- r9_y[8][0] = x->x_sqrt35_64*(3.0f - 4.0f*c2y + c4y);
- r9_y[8][2] = x->x_sqrt70_32*(2.0f*s2y - s4y);
- r9_y[8][4] = x->x_sqrt5_32*(3.0f + 4.0f*c2y - 7.0f*c4y);
- r9_y[8][6] = x->x_sqrt10_4*(2.0f*s2y + 7.0f*s4y)*0.125f;
- r9_y[8][8] = (9.0f + 20.0f*c2y + 35.0f*c4y)*0.015625f;
-
- r9_y[0][2] = -r9_y[2][0];
- r9_y[0][4] = r9_y[4][0];
- r9_y[0][6] = -r9_y[6][0];
- r9_y[0][8] = r9_y[8][0];
- r9_y[1][3] = -r9_y[3][1];
- r9_y[1][5] = r9_y[5][1];
- r9_y[1][7] = -r9_y[7][1];
- r9_y[2][4] = -r9_y[4][2];
- r9_y[2][6] = r9_y[6][2];
- r9_y[2][8] = -r9_y[8][2];
- r9_y[3][5] = -r9_y[5][3];
- r9_y[3][7] = r9_y[7][3];
- r9_y[4][6] = -r9_y[6][4];
- r9_y[4][8] = r9_y[8][4];
- r9_y[5][7] = -r9_y[7][5];
- r9_y[6][8] = -r9_y[8][6];
-
- /*x
- r9_11=(35 + 28*c2 + c4)/64;
- r9_22=(7c + c3)/8;
- r9_32 = x->x_sqrt2*(7*s + 3*s3)/16;
- r9_33=(7*c + 9*c3)/16;
- r9_41 = x->x_sqrt2*(-14*s2 - s4)/32;
- r9_44=(7*c2 + c4)/8;
- r9_51 = x->x_sqrt7*(-5 + 4*c2 + c4)/32;
- r9_54 = x->x_sqrt14*(2*s2 + s4)/16;
- r9_55=(5 + 4*c2 + 7*c4)/16;
- r9_62 = x->x_sqrt7*(-c + c3)/8;
- r9_63 = x->x_sqrt14*(s - 3*s3)/16;
- r9_66=(c + 7*c3)/8;
- r9_72 = x->x_sqrt14*(-3s + s3)/16;
- r9_73 = x->x_sqrt7*(-3*c + 3*c3)/16;
- r9_76 = x->x_sqrt2*(3*s + 7*s3)/16;
- r9_77=(9*c + 7*c3)/16;
- r9_81 = x->x_sqrt14*(2*s2 - s4)/32;
- r9_84 = x->x_sqrt7*(-c2 + c4)/8;
- r9_85 = x->x_sqrt2*(2*s2 - 7*s4)/16;
- r9_88=(c2 + 7*c4)/8;
- r9_91 = x->x_sqrt35*(3 - 4*c2 + c4)/64;
- r9_94 = x->x_sqrt70*(-2*s2 + s4)/32;
- r9_95 = x->x_sqrt5*(-3 - 4*c2 + 7*c4)/32;
- r9_98 = x->x_sqrt10*(2*s2 + 7*s4)/32;
- r9_99=(9 + 20*c2 + 35*c4)/64;
- */
-
- r9_x[0][0] = (35.0f + 28.0f*c2x + c4x)*0.015625f;/* -r9_41x, r9_51x, -r9_81x, r9_91x;*/
- r9_x[1][1] = (7.0f*cx + c3x)*0.125f;/* -r9_32x, r9_62x, -r9_72x;*/
- r9_x[2][1] = x->x_sqrt2_16*(7.0f*sx + 3.0f*s3x);
- r9_x[2][2] = (7.0f*cx + 9.0f*c3x)*0.0625f;/* -r9_63x, r9_73x;*/
- r9_x[3][0] = -x->x_sqrt2_16*(14.0f*s2x + s4x)*0.5f;
- r9_x[3][3] = (7.0f*c2x + c4x)*0.125f;/* -r9_54x, r9_84x, -r9_94x;*/
- r9_x[4][0] = x->x_sqrt7_8*(4.0f*c2x + c4x - 5.0f)*0.25f;
- r9_x[4][3] = x->x_sqrt14_16*(2.0f*s2x + s4x);
- r9_x[4][4] = (5.0f + 4.0f*c2x + 7.0f*c4x)*0.0625f;/* -r9_85x, r9_95x;*/
- r9_x[5][1] = x->x_sqrt7_8*(c3x - cx);
- r9_x[5][2] = x->x_sqrt14_16*(sx - 3.0f*s3x);
- r9_x[5][5] = (cx + 7.0f*c3x)*0.125f;/* -r9_76x;*/
- r9_x[6][1] = x->x_sqrt14_16*(s3x - 3.0f*sx);
- r9_x[6][2] = x->x_sqrt7_8*(c3x - cx)*1.5f;
- r9_x[6][5] = x->x_sqrt2_16*(3.0f*sx + 7.0f*s3x);
- r9_x[6][6] = (9.0f*cx + 7.0f*c3x)*0.0625f;
- r9_x[7][0] = x->x_sqrt14_16*(2.0f*s2x - s4x)*0.5f;
- r9_x[7][3] = x->x_sqrt7_8*(c4x - c2x);
- r9_x[7][4] = x->x_sqrt2_16*(2.0f*s2x - 7.0f*s4x);
- r9_x[7][7] = (c2x + 7.0f*c4x)*0.125f;/* -r9_98x*/
- r9_x[8][0] = x->x_sqrt35_64*(3.0f - 4.0f*c2x + c4x);
- r9_x[8][3] = x->x_sqrt70_32*(s4x - 2.0f*s2x);
- r9_x[8][4] = x->x_sqrt5_32*(7.0f*c4x - 3.0f - 4.0f*c2x);
- r9_x[8][7] = x->x_sqrt10_4*(2.0f*s2x + 7.0f*s4x)*0.125f;
- r9_x[8][8] = (9.0f + 20.0f*c2x + 35.0f*c4x)*0.015625f;
-
- r9_x[0][3] = -r9_x[3][0];
- r9_x[0][4] = r9_x[4][0];
- r9_x[0][7] = -r9_x[7][0];
- r9_x[0][8] = r9_x[8][0];
- r9_x[1][2] = -r9_x[2][1];
- r9_x[1][5] = r9_x[5][1];
- r9_x[1][6] = -r9_x[6][1];
- r9_x[2][5] = -r9_x[5][2];
- r9_x[2][6] = r9_x[6][2];
- r9_x[3][4] = -r9_x[4][3];
- r9_x[3][7] = r9_x[7][3];
- r9_x[3][8] = -r9_x[8][3];
- r9_x[4][7] = -r9_x[7][4];
- r9_x[4][8] = r9_x[8][4];
- r9_x[5][6] = -r9_x[6][5];
- r9_x[7][8] = -r9_x[8][7];
-
- for(j=0; j<8; j+=2)
- {
- for(i=0; i<8; i+=2)
- {
- r9_zy[j][i] = r9_z[j][j]*r9_y[j][i];
- r9_zy[j][i+1] = r9_z[j][j+1]*r9_y[j+1][i+1];
-
- r9_zy[j+1][i] = r9_z[j+1][j]*r9_y[j][i];
- r9_zy[j+1][i+1] = r9_z[j+1][j+1]*r9_y[j+1][i+1];
- }
- r9_zy[j][8] = r9_z[j][j]*r9_y[j][8];
- r9_zy[j+1][8] = r9_z[j+1][j]*r9_y[j][8];
- }
- for(i=0; i<=8; i+=2)
- {
- r9_zy[8][i] = r9_y[8][i];
- }
-
- at = x->x_at9;
- at += 2;
-
- for(i=0; i<8; i++)
- {
- SETFLOAT(at, (r9_zy[i][0]*r9_x[0][0] + r9_zy[i][3]*r9_x[3][0] + r9_zy[i][4]*r9_x[4][0] + r9_zy[i][7]*r9_x[7][0] + r9_zy[i][8]*r9_x[8][0]));
- at++;
- SETFLOAT(at, (r9_zy[i][1]*r9_x[1][1] + r9_zy[i][2]*r9_x[2][1] + r9_zy[i][5]*r9_x[5][1] + r9_zy[i][6]*r9_x[6][1]));
- at++;
- SETFLOAT(at, (r9_zy[i][1]*r9_x[1][2] + r9_zy[i][2]*r9_x[2][2] + r9_zy[i][5]*r9_x[5][2] + r9_zy[i][6]*r9_x[6][2]));
- at++;
- SETFLOAT(at, (r9_zy[i][0]*r9_x[0][3] + r9_zy[i][3]*r9_x[3][3] + r9_zy[i][4]*r9_x[4][3] + r9_zy[i][7]*r9_x[7][3] + r9_zy[i][8]*r9_x[8][3]));
- at++;
- SETFLOAT(at, (r9_zy[i][0]*r9_x[0][4] + r9_zy[i][3]*r9_x[3][4] + r9_zy[i][4]*r9_x[4][4] + r9_zy[i][7]*r9_x[7][4] + r9_zy[i][8]*r9_x[8][4]));
- at++;
- SETFLOAT(at, (r9_zy[i][1]*r9_x[1][5] + r9_zy[i][2]*r9_x[2][5] + r9_zy[i][5]*r9_x[5][5] + r9_zy[i][6]*r9_x[6][5]));
- at++;
- SETFLOAT(at, (r9_zy[i][1]*r9_x[1][6] + r9_zy[i][2]*r9_x[2][6] + r9_zy[i][5]*r9_x[5][6] + r9_zy[i][6]*r9_x[6][6]));
- at++;
- SETFLOAT(at, (r9_zy[i][0]*r9_x[0][7] + r9_zy[i][3]*r9_x[3][7] + r9_zy[i][4]*r9_x[4][7] + r9_zy[i][7]*r9_x[7][7] + r9_zy[i][8]*r9_x[8][7]));
- at++;
- SETFLOAT(at, (r9_zy[i][0]*r9_x[0][8] + r9_zy[i][3]*r9_x[3][8] + r9_zy[i][4]*r9_x[4][8] + r9_zy[i][7]*r9_x[7][8] + r9_zy[i][8]*r9_x[8][8]));
- at++;
- }
-
- SETFLOAT(at, (r9_zy[8][0]*r9_x[0][0] + r9_zy[8][4]*r9_x[4][0] + r9_zy[8][8]*r9_x[8][0]));
- at++;
- SETFLOAT(at, (r9_zy[8][2]*r9_x[2][1] + r9_zy[8][6]*r9_x[6][1]));
- at++;
- SETFLOAT(at, (r9_zy[8][2]*r9_x[2][2] + r9_zy[8][6]*r9_x[6][2]));
- at++;
- SETFLOAT(at, (r9_zy[8][0]*r9_x[0][3] + r9_zy[8][4]*r9_x[4][3] + r9_zy[8][8]*r9_x[8][3]));
- at++;
- SETFLOAT(at, (r9_zy[8][0]*r9_x[0][4] + r9_zy[8][4]*r9_x[4][4] + r9_zy[8][8]*r9_x[8][4]));
- at++;
- SETFLOAT(at, (r9_zy[8][2]*r9_x[2][5] + r9_zy[8][6]*r9_x[6][5]));
- at++;
- SETFLOAT(at, (r9_zy[8][2]*r9_x[2][6] + r9_zy[8][6]*r9_x[6][6]));
- at++;
- SETFLOAT(at, (r9_zy[8][0]*r9_x[0][7] + r9_zy[8][4]*r9_x[4][7] + r9_zy[8][8]*r9_x[8][7]));
- at++;
- SETFLOAT(at, (r9_zy[8][0]*r9_x[0][8] + r9_zy[8][4]*r9_x[4][8] + r9_zy[8][8]*r9_x[8][8]));
-
- outlet_anything(x->x_out9, x->x_s_matrix, x->x_size9, x->x_at9);
- }
-
- r9_z[0][0] = c3z;
- r9_z[0][1] = -s3z;
- r9_z[1][0] = s3z;
- r9_z[1][1] = c3z;
- r9_z[2][2] = c2z;
- r9_z[2][3] = -s2z;
- r9_z[3][2] = s2z;
- r9_z[3][3] = c2z;
- r9_z[4][4] = cz;
- r9_z[4][5] = -sz;
- r9_z[5][4] = sz;
- r9_z[5][5] = cz;
- r9_z[6][6] = 1.0f;
- /*y
- r7_11=(15*c + c3)/16;
- r7_22=(5 + 3*c2)/8;
- r7_31 = x->x_sqrt6*(5*s + s3)/16;
- r7_33=(5*c + 3*c3)/8;
- r7_42 = x->x_sqrt6*(s2)/4;
- r7_44=(c2);
- r7_51 = x->x_sqrt15*(c - c3)/16;
- r7_53 = x->x_sqrt10*(-s + 3*s3)/16;
- r7_55=(c + 15*c3)/16;
- r7_62 = x->x_sqrt15*(1 - c2)/8;
- r7_64 = x->x_sqrt10*(s2)/4;
- r7_66=(3 + 5*c2)/8;
- r7_71 = x->x_sqrt10*(3*s - s3)/16;
- r7_73 = x->x_sqrt15*(c - c3)/8 = 2*r7_51;
- r7_75 = x->x_sqrt6*(s + 5*s3)/16;
- r7_77=(3*c + 5*c3)/8;
-
- */
- r9_y[0][0] = (15.0f*cy + c3y)*0.0625f;/* -r7_31y, r7_51y, -r7_71y;*/
- r9_y[1][1] = (5.0f + 3.0f*c2y)*0.125f;/* -r7_42y, r7_62y;*/
- r9_y[2][0] = x->x_sqrt6_4*(5.0f*sy + s3y)*0.25f;
- r9_y[2][2] = (5.0f*cy + 3.0f*c3y)*0.125f;/* -r7_53y, r7_73y;*/
- r9_y[3][1] = x->x_sqrt6_4*s2y;
- r9_y[3][3] = c2y;/* -r7_64y;*/
- r9_y[6][2] = x->x_sqrt15_8*(cy - c3y);
- r9_y[4][0] = r9_y[6][2]*0.5f;
- r9_y[4][2] = x->x_sqrt10_4*(3.0f*s3y - sy)*0.25f;
- r9_y[4][4] = (cy + 15.0f*c3y)*0.0625f;/* -r7_75y;*/
- r9_y[5][1] = x->x_sqrt15_8*(1.0f - c2y);
- r9_y[5][3] = x->x_sqrt10_4*s2y;
- r9_y[5][5] = (3.0f + 5.0f*c2y)*0.125f;
- r9_y[6][0] = x->x_sqrt10_4*(3.0f*sy - s3y)*0.25f;
-
- r9_y[6][4] = x->x_sqrt6_4*(sy + 5.0f*s3y)*0.25f;
- r9_y[6][6] = (3.0f*cy + 5.0f*c3y)*0.125f;
-
- r9_y[0][2] = -r9_y[2][0];
- r9_y[0][4] = r9_y[4][0];
- r9_y[0][6] = -r9_y[6][0];
- r9_y[1][3] = -r9_y[3][1];
- r9_y[1][5] = r9_y[5][1];
- r9_y[2][4] = -r9_y[4][2];
- r9_y[2][6] = r9_y[6][2];
- r9_y[3][5] = -r9_y[5][3];
- r9_y[4][6] = -r9_y[6][4];
-
- /*x
- r7_11=(5 + 3*c2)/8;
- r7_22=(15*c + c3)/16;
- r7_32 = x->x_sqrt6*(5*s + s3)/16;
- r7_33=(5*c + 3*c3)/8;
- r7_41 = x->x_sqrt6*(-s2)/4;
- r7_44=(c2);
- r7_51 = x->x_sqrt15*(-1 + c2)/8;
- r7_54 = x->x_sqrt10*(s2)/4;
- r7_55=(3 + 5*c2)/8;
- r7_62 = x->x_sqrt15*(-c + c3)/16;
- r7_63 = x->x_sqrt10*(s - 3*s3)/16;
- r7_66=(c + 15*c3)/16;
- r7_72 = x->x_sqrt10*(-3*s + s3)/16;
- r7_73 = x->x_sqrt15*(-c + c3)/8 = 2*r7_62;
- r7_76 = x->x_sqrt6*(s + 5*s3)/16;
- r7_77=(3*c + 5*c3)/8;
- */
-
- r9_x[0][0] = (5.0f + 3.0f*c2x)*0.125f;/* -r7_41, r7_51;*/
- r9_x[1][1] = (15.0f*cx + c3x)*0.0625f;/* -r7_32, r7_62, -r7_72;*/
- r9_x[2][1] = x->x_sqrt6_4*(5.0f*sx + s3x)*0.25f;
- r9_x[2][2] = (5.0f*cx + 3.0f*c3x)*0.125f;/* */
- r9_x[3][0] = -x->x_sqrt6_4*s2x;
- r9_x[3][3] = c2x;
- r9_x[4][0] = x->x_sqrt15_8*(c2x - 1.0f);
- r9_x[4][3] = x->x_sqrt10_4*s2x;
- r9_x[4][4] = (3.0f + 5.0f*c2x)*0.125f;
- r9_x[6][2] = x->x_sqrt15_8*(c3x - cx);
- r9_x[5][1] = r9_x[6][2]*0.5f;
- r9_x[5][2] = x->x_sqrt10_4*(sx - 3.0f*s3x)*0.25f;
- r9_x[5][5] = (cx + 15.0f*c3x)*0.0625f;
- r9_x[6][1] = x->x_sqrt10_4*(s3x - 3.0f*sx)*0.25f;
-
- r9_x[6][5] = x->x_sqrt6_4*(sx + 5.0f*s3x)*0.25f;
- r9_x[6][6] = (3.0f*cx + 5.0f*c3x)*0.125f;
-
- r9_x[0][3] = -r9_x[3][0];
- r9_x[0][4] = r9_x[4][0];
- r9_x[1][2] = -r9_x[2][1];
- r9_x[1][5] = r9_x[5][1];
- r9_x[1][6] = -r9_x[6][1];
- r9_x[2][5] = -r9_x[5][2];
- r9_x[2][6] = r9_x[6][2];
- r9_x[3][4] = -r9_x[4][3];
- r9_x[5][6] = -r9_x[6][5];
-
- for(j=0; j<6; j+=2)
- {
- for(i=0; i<6; i+=2)
- {
- r9_zy[j][i] = r9_z[j][j]*r9_y[j][i];
- r9_zy[j][i+1] = r9_z[j][j+1]*r9_y[j+1][i+1];
-
- r9_zy[j+1][i] = r9_z[j+1][j]*r9_y[j][i];
- r9_zy[j+1][i+1] = r9_z[j+1][j+1]*r9_y[j+1][i+1];
- }
- r9_zy[j][6] = r9_z[j][j]*r9_y[j][6];
- r9_zy[j+1][6] = r9_z[j+1][j]*r9_y[j][6];
- }
- for(i=0; i<=6; i+=2)
- {
- r9_zy[6][i] = r9_y[6][i];
- }
-
- at = x->x_at7;
- at += 2;
-
- for(i=0; i<6; i++)
- {
- SETFLOAT(at, (r9_zy[i][0]*r9_x[0][0] + r9_zy[i][3]*r9_x[3][0] + r9_zy[i][4]*r9_x[4][0]));
- at++;
- SETFLOAT(at, (r9_zy[i][1]*r9_x[1][1] + r9_zy[i][2]*r9_x[2][1] + r9_zy[i][5]*r9_x[5][1] + r9_zy[i][6]*r9_x[6][1]));
- at++;
- SETFLOAT(at, (r9_zy[i][1]*r9_x[1][2] + r9_zy[i][2]*r9_x[2][2] + r9_zy[i][5]*r9_x[5][2] + r9_zy[i][6]*r9_x[6][2]));
- at++;
- SETFLOAT(at, (r9_zy[i][0]*r9_x[0][3] + r9_zy[i][3]*r9_x[3][3] + r9_zy[i][4]*r9_x[4][3]));
- at++;
- SETFLOAT(at, (r9_zy[i][0]*r9_x[0][4] + r9_zy[i][3]*r9_x[3][4] + r9_zy[i][4]*r9_x[4][4]));
- at++;
- SETFLOAT(at, (r9_zy[i][1]*r9_x[1][5] + r9_zy[i][2]*r9_x[2][5] + r9_zy[i][5]*r9_x[5][5] + r9_zy[i][6]*r9_x[6][5]));
- at++;
- SETFLOAT(at, (r9_zy[i][1]*r9_x[1][6] + r9_zy[i][2]*r9_x[2][6] + r9_zy[i][5]*r9_x[5][6] + r9_zy[i][6]*r9_x[6][6]));
- at++;
- }
-
- SETFLOAT(at, (r9_zy[6][0]*r9_x[0][0] + r9_zy[6][4]*r9_x[4][0]));
- at++;
- SETFLOAT(at, (r9_zy[6][2]*r9_x[2][1] + r9_zy[6][6]*r9_x[6][1]));
- at++;
- SETFLOAT(at, (r9_zy[6][2]*r9_x[2][2] + r9_zy[6][6]*r9_x[6][2]));
- at++;
- SETFLOAT(at, (r9_zy[6][0]*r9_x[0][3] + r9_zy[6][4]*r9_x[4][3]));
- at++;
- SETFLOAT(at, (r9_zy[6][0]*r9_x[0][4] + r9_zy[6][4]*r9_x[4][4]));
- at++;
- SETFLOAT(at, (r9_zy[6][2]*r9_x[2][5] + r9_zy[6][6]*r9_x[6][5]));
- at++;
- SETFLOAT(at, (r9_zy[6][2]*r9_x[2][6] + r9_zy[6][6]*r9_x[6][6]));
-
- outlet_anything(x->x_out7, x->x_s_matrix, x->x_size7, x->x_at7);
- }
-
- r9_z[0][0] = c2z;
- r9_z[0][1] = -s2z;
- r9_z[1][0] = s2z;
- r9_z[1][1] = c2z;
- r9_z[2][2] = cz;
- r9_z[2][3] = -sz;
- r9_z[3][2] = sz;
- r9_z[3][3] = cz;
- r9_z[4][4] = 1.0f;
- /*y
- r5_11=(3 + c2)/4;
- r5_22=(c);
- r5_31 = (s2)/2;
- r5_33=(c2);
- r5_42 = (s);
- r5_44=(c);
- r5_51 = x->x_sqrt3*(1 - c2)/4;
- r5_53 = x->x_sqrt3*(s2)/2;
- r5_55=(1 + 3*c2)/4;
- */
- r9_y[0][0] = (3.0f + c2y)*0.25f;/* -r5_31y, r5_51y;*/
- r9_y[1][1] = cy;/* -r5_42y;*/
- r9_y[2][0] = s2y*0.5f;
- r9_y[2][2] = c2y;/* -r5_53y;*/
- r9_y[3][1] = sy;
- r9_y[3][3] = cy;
- r9_y[4][0] = x->x_sqrt3_2*(1.0f - c2y)*0.5f;
- r9_y[4][2] = x->x_sqrt3_2*s2y;
- r9_y[4][4] = (1.0f + 3.0f*c2y)*0.25f;
-
- r9_y[0][2] = -r9_y[2][0];
- r9_y[0][4] = r9_y[4][0];
- r9_y[1][3] = -r9_y[3][1];
- r9_y[2][4] = -r9_y[4][2];
-
- /*x
- r5_11=(3 + c2)/4;
- r5_22=(c);
- r5_32 = (s);
- r5_33=(c);
- r5_41 = (-s2)/2;
- r5_44=(c2);
- r5_51 = x->x_sqrt3*(-1 + c2)/4;
- r5_54 = x->x_sqrt3*(s2)/2;
- r5_55=(1 + 3*c2)/4;
- */
-
- r9_x[0][0] = (3.0f + c2x)*0.25f;
- r9_x[1][1] = cx;
- r9_x[2][1] = sx;
- r9_x[2][2] = cx;
- r9_x[3][0] = -0.5f*s2x;
- r9_x[3][3] = c2x;
- r9_x[4][0] = x->x_sqrt3_2*(c2x - 1.0f)*0.5f;
- r9_x[4][3] = x->x_sqrt3_2*s2x;
- r9_x[4][4] = (1.0f + 3.0f*c2x)*0.25f;
-
- r9_x[0][3] = -r9_x[3][0];
- r9_x[0][4] = r9_x[4][0];
- r9_x[1][2] = -r9_x[2][1];
- r9_x[3][4] = -r9_x[4][3];
-
- for(j=0; j<4; j+=2)
- {
- for(i=0; i<4; i+=2)
- {
- r9_zy[j][i] = r9_z[j][j]*r9_y[j][i];
- r9_zy[j][i+1] = r9_z[j][j+1]*r9_y[j+1][i+1];
-
- r9_zy[j+1][i] = r9_z[j+1][j]*r9_y[j][i];
- r9_zy[j+1][i+1] = r9_z[j+1][j+1]*r9_y[j+1][i+1];
- }
- r9_zy[j][4] = r9_z[j][j]*r9_y[j][4];
- r9_zy[j+1][4] = r9_z[j+1][j]*r9_y[j][4];
- }
- for(i=0; i<=4; i+=2)
- {
- r9_zy[4][i] = r9_y[4][i];
- }
-
- at = x->x_at5;
- at += 2;
-
- for(i=0; i<4; i++)
- {
- SETFLOAT(at, (r9_zy[i][0]*r9_x[0][0] + r9_zy[i][3]*r9_x[3][0] + r9_zy[i][4]*r9_x[4][0]));
- at++;
- SETFLOAT(at, (r9_zy[i][1]*r9_x[1][1] + r9_zy[i][2]*r9_x[2][1]));
- at++;
- SETFLOAT(at, (r9_zy[i][1]*r9_x[1][2] + r9_zy[i][2]*r9_x[2][2]));
- at++;
- SETFLOAT(at, (r9_zy[i][0]*r9_x[0][3] + r9_zy[i][3]*r9_x[3][3] + r9_zy[i][4]*r9_x[4][3]));
- at++;
- SETFLOAT(at, (r9_zy[i][0]*r9_x[0][4] + r9_zy[i][3]*r9_x[3][4] + r9_zy[i][4]*r9_x[4][4]));
- at++;
- }
-
- SETFLOAT(at, (r9_zy[4][0]*r9_x[0][0] + r9_zy[4][4]*r9_x[4][0]));
- at++;
- SETFLOAT(at, (r9_zy[4][2]*r9_x[2][1]));
- at++;
- SETFLOAT(at, (r9_zy[4][2]*r9_x[2][2]));
- at++;
- SETFLOAT(at, (r9_zy[4][0]*r9_x[0][3] + r9_zy[4][4]*r9_x[4][3]));
- at++;
- SETFLOAT(at, (r9_zy[4][0]*r9_x[0][4] + r9_zy[4][4]*r9_x[4][4]));
-
- outlet_anything(x->x_out5, x->x_s_matrix, x->x_size5, x->x_at5);
- }
-
- r9_z[0][0] = cz;
- r9_z[0][1] = -sz;
- r9_z[1][0] = sz;
- r9_z[1][1] = cz;
- r9_z[2][2] = 1.0f;
- /*y
- r3_11=(c);
- r3_22=(1);
- r3_31 = (s);
- r3_33=(c);
- */
- r9_y[0][0] = cy;/* -r3_31y;*/
- r9_y[1][1] = 1.0f;
- r9_y[2][0] = sy;
- r9_y[2][2] = cy;
-
- r9_y[0][2] = -r9_y[2][0];
-
- /*x
- r3_11=(1);
- r3_22=(c);
- r3_32 = (s);
- r3_33=(c);
- */
- r9_x[0][0] = 1.0f;
- r9_x[1][1] = cx;/* -r3_32x;*/
- r9_x[2][1] = sx;
- r9_x[2][2] = cx;
-
- r9_x[1][2] = -r9_x[2][1];
-
- r9_zy[0][0] = cz*r9_y[0][0];
- r9_zy[0][1] = -sz*r9_y[1][1];
- r9_zy[0][2] = cz*r9_y[0][2];
-
- r9_zy[1][0] = sz*r9_y[0][0];
- r9_zy[1][1] = cz*r9_y[1][1];
- r9_zy[1][2] = sz*r9_y[0][2];
-
- r9_zy[2][0] = r9_y[2][0];
- r9_zy[2][1] = 0.0f;
- r9_zy[2][2] = r9_y[2][2];
-
- at = x->x_at3;
- at += 2;
-
- for(i=0; i<2; i++)
- {
- SETFLOAT(at, (r9_zy[i][0]*r9_x[0][0]));
- at++;
- SETFLOAT(at, (r9_zy[i][1]*r9_x[1][1] + r9_zy[i][2]*r9_x[2][1]));
- at++;
- SETFLOAT(at, (r9_zy[i][1]*r9_x[1][2] + r9_zy[i][2]*r9_x[2][2]));
- at++;
- }
-
- SETFLOAT(at, (r9_zy[2][0]*r9_x[0][0]));
- at++;
- SETFLOAT(at, (r9_zy[2][2]*r9_x[2][1]));
- at++;
- SETFLOAT(at, (r9_zy[2][2]*r9_x[2][2]));
-
- outlet_anything(x->x_out3, x->x_s_matrix, x->x_size3, x->x_at3);
+ t_float cx, sx, ccx, ssx, c2x, s2x, c3x, s3x, c4x, s4x;
+ t_float cy, sy, ccy, ssy, c2y, s2y, c3y, s3y, c4y, s4y;
+ t_float cz, sz, ccz, ssz, c2z, s2z, c3z, s3z, c4z, s4z;
+ t_float r9_zy[9][9];
+ t_float r9_z[9][9];
+ t_float r9_y[9][9];
+ t_float r9_x[9][9];
+ int i, j;
+ t_atom *at;
+
+ rho_z *= x->x_pi_over_180;
+ rho_y *= x->x_pi_over_180;
+ rho_x *= x->x_pi_over_180;
+
+ cz = cos(rho_z);
+ sz = sin(rho_z);
+ ccz = cz*cz;
+ ssz = sz*sz;
+
+ cy = cos(rho_y);
+ sy = sin(rho_y);
+ ccy = cy*cy;
+ ssy = sy*sy;
+
+ cx = cos(rho_x);
+ sx = sin(rho_x);
+ ccx = cx*cx;
+ ssx = sx*sx;
+
+ if(x->x_order >= 2)
+ {
+ c2z = ccz - ssz;
+ s2z = 2.0f*sz*cz;
+ c2y = ccy - ssy;
+ s2y = 2.0f*sy*cy;
+ c2x = ccx - ssx;
+ s2x = 2.0f*sx*cx;
+
+ if(x->x_order >= 3)
+ {
+ c3z = cz*(4.0f*ccz - 3.0f);
+ s3z = sz*(3.0f - 4.0f*ssz);
+ c3y = cy*(4.0f*ccy - 3.0f);
+ s3y = sy*(3.0f - 4.0f*ssy);
+ c3x = cx*(4.0f*ccx - 3.0f);
+ s3x = sx*(3.0f - 4.0f*ssx);
+
+ if(x->x_order >= 4)
+ {
+ if(x->x_order >= 5)
+ post("ambi_rot-ERROR: do not support Ambisonic-Order greater than 5 in zyx-Rotation !!!");
+
+ c4z = 1.0f + 8.0f*ccz*(ccz - 1.0f);
+ s4z = 2.0f*s2z*c2z;
+
+ c4y = 1.0f + 8.0f*ccy*(ccy - 1.0f);
+ s4y = 2.0f*s2y*c2y;
+
+ c4x = 1.0f + 8.0f*ccx*(ccx - 1.0f);
+ s4x = 2.0f*s2x*c2x;
+
+ r9_z[0][0] = c4z;
+ r9_z[0][1] = -s4z;
+ r9_z[1][0] = s4z;
+ r9_z[1][1] = c4z;
+ r9_z[2][2] = c3z;
+ r9_z[2][3] = -s3z;
+ r9_z[3][2] = s3z;
+ r9_z[3][3] = c3z;
+ r9_z[4][4] = c2z;
+ r9_z[4][5] = -s2z;
+ r9_z[5][4] = s2z;
+ r9_z[5][5] = c2z;
+ r9_z[6][6] = cz;
+ r9_z[6][7] = -sz;
+ r9_z[7][6] = sz;
+ r9_z[7][7] = cz;
+ r9_z[8][8] = 1.0f;
+ /*y
+ r9_11=(35 + 28*c2 + c4)/64;
+ r9_22=(7c + c3)/8;
+ r9_31 = x->x_sqrt2*(14*s2 + s4)/32;
+ r9_33=(7*c2 + c4)/8;
+ r9_42 = x->x_sqrt2*(7*s + 3*s3)/16;
+ r9_44=(7*c + 9*c3)/16;
+ r9_51 = x->x_sqrt7*(5 - 4*c2 - c4)/32;
+ r9_53 = x->x_sqrt14*(2*s2 + s4)/16;
+ r9_55=(5 + 4*c2 + 7*c4)/16;
+ r9_62 = x->x_sqrt7*(c - c3)/8;
+ r9_64 = x->x_sqrt14*(-s + 3*s3)/16;
+ r9_66=(c + 7*c3)/8;
+ r9_71 = x->x_sqrt14*(2*s2 - s4)/32;
+ r9_73 = x->x_sqrt7*(c2 - c4)/8;
+ r9_75 = x->x_sqrt2*(-2*s2 + 7*s4)/16;
+ r9_77=(c2 + 7*c4)/8;
+ r9_82 = x->x_sqrt14*(3*s - s3)/16;
+ r9_84 = x->x_sqrt7*(3*c - 3*c3)/16;
+ r9_86 = x->x_sqrt2*(3*s + 7*s3)/16;
+ r9_88=(9*c + 7*c3)/16;
+ r9_91 = x->x_sqrt35*(3 - 4*c2 + c4)/64;
+ r9_93 = x->x_sqrt70*(2*s2 - s4)/32;
+ r9_95 = x->x_sqrt5*(3 + 4*c2 - 7*c4)/32;
+ r9_97 = x->x_sqrt10*(2*s2 + 7*s4)/32;
+ r9_99=(9 + 20*c2 + 35*c4)/64;
+ */
+ r9_y[0][0] = (35.0f + 28.0f*c2y + c4y)*0.015625f;/* -r9_31y, r9_51y, -r9_71y, r9_91y; */
+ r9_y[1][1] = (7.0f*cy + c3y)*0.125f;/* -r9_42y, r9_62y, -r9_82y;*/
+ r9_y[2][0] = x->x_sqrt2_16*(14.0f*s2y + s4y)*0.5f;
+ r9_y[2][2] = (7.0f*c2y + c4y)*0.125f;/* -r9_53y, r9_73y, -r9_93y;*/
+ r9_y[3][1] = x->x_sqrt2_16*(7.0f*sy + 3.0f*s3y);
+ r9_y[3][3] = (7.0f*cy + 9.0f*c3y)*0.0625f;/* -r9_64y, r9_84y;*/
+ r9_y[4][0] = x->x_sqrt7_8*(5.0f - 4.0f*c2y - c4y)*0.25f;
+ r9_y[4][2] = x->x_sqrt14_16*(2.0f*s2y + s4y);
+ r9_y[4][4] = (5.0f + 4.0f*c2y + 7.0f*c4y)*0.0625f;/* -r9_75y, r9_95y;*/
+ r9_y[5][1] = x->x_sqrt7_8*(cy - c3y);
+ r9_y[5][3] = x->x_sqrt14_16*(3.0f*s3y - sy);
+ r9_y[5][5] = (cy + 7.0f*c3y)*0.125f;/* -r9_86y;*/
+ r9_y[6][0] = x->x_sqrt14_16*(2.0f*s2y - s4y)*0.5f;
+ r9_y[6][2] = x->x_sqrt7_8*(c2y - c4y);
+ r9_y[6][4] = x->x_sqrt2_16*(7.0f*s4y - 2.0f*s2y);
+ r9_y[6][6] = (c2y + 7.0f*c4y)*0.125f;/* -r9_97y;*/
+ r9_y[7][1] = x->x_sqrt14_16*(3.0f*sy - s3y);
+ r9_y[7][3] = x->x_sqrt7_8*(cy - c3y)*1.5f;
+ r9_y[7][5] = x->x_sqrt2_16*(3.0f*sy + 7.0f*s3y);
+ r9_y[7][7] = (9.0f*cy + 7.0f*c3y)*0.0625f;
+ r9_y[8][0] = x->x_sqrt35_64*(3.0f - 4.0f*c2y + c4y);
+ r9_y[8][2] = x->x_sqrt70_32*(2.0f*s2y - s4y);
+ r9_y[8][4] = x->x_sqrt5_32*(3.0f + 4.0f*c2y - 7.0f*c4y);
+ r9_y[8][6] = x->x_sqrt10_4*(2.0f*s2y + 7.0f*s4y)*0.125f;
+ r9_y[8][8] = (9.0f + 20.0f*c2y + 35.0f*c4y)*0.015625f;
+
+ r9_y[0][2] = -r9_y[2][0];
+ r9_y[0][4] = r9_y[4][0];
+ r9_y[0][6] = -r9_y[6][0];
+ r9_y[0][8] = r9_y[8][0];
+ r9_y[1][3] = -r9_y[3][1];
+ r9_y[1][5] = r9_y[5][1];
+ r9_y[1][7] = -r9_y[7][1];
+ r9_y[2][4] = -r9_y[4][2];
+ r9_y[2][6] = r9_y[6][2];
+ r9_y[2][8] = -r9_y[8][2];
+ r9_y[3][5] = -r9_y[5][3];
+ r9_y[3][7] = r9_y[7][3];
+ r9_y[4][6] = -r9_y[6][4];
+ r9_y[4][8] = r9_y[8][4];
+ r9_y[5][7] = -r9_y[7][5];
+ r9_y[6][8] = -r9_y[8][6];
+
+ /*x
+ r9_11=(35 + 28*c2 + c4)/64;
+ r9_22=(7c + c3)/8;
+ r9_32 = x->x_sqrt2*(7*s + 3*s3)/16;
+ r9_33=(7*c + 9*c3)/16;
+ r9_41 = x->x_sqrt2*(-14*s2 - s4)/32;
+ r9_44=(7*c2 + c4)/8;
+ r9_51 = x->x_sqrt7*(-5 + 4*c2 + c4)/32;
+ r9_54 = x->x_sqrt14*(2*s2 + s4)/16;
+ r9_55=(5 + 4*c2 + 7*c4)/16;
+ r9_62 = x->x_sqrt7*(-c + c3)/8;
+ r9_63 = x->x_sqrt14*(s - 3*s3)/16;
+ r9_66=(c + 7*c3)/8;
+ r9_72 = x->x_sqrt14*(-3s + s3)/16;
+ r9_73 = x->x_sqrt7*(-3*c + 3*c3)/16;
+ r9_76 = x->x_sqrt2*(3*s + 7*s3)/16;
+ r9_77=(9*c + 7*c3)/16;
+ r9_81 = x->x_sqrt14*(2*s2 - s4)/32;
+ r9_84 = x->x_sqrt7*(-c2 + c4)/8;
+ r9_85 = x->x_sqrt2*(2*s2 - 7*s4)/16;
+ r9_88=(c2 + 7*c4)/8;
+ r9_91 = x->x_sqrt35*(3 - 4*c2 + c4)/64;
+ r9_94 = x->x_sqrt70*(-2*s2 + s4)/32;
+ r9_95 = x->x_sqrt5*(-3 - 4*c2 + 7*c4)/32;
+ r9_98 = x->x_sqrt10*(2*s2 + 7*s4)/32;
+ r9_99=(9 + 20*c2 + 35*c4)/64;
+ */
+
+ r9_x[0][0] = (35.0f + 28.0f*c2x + c4x)*0.015625f;/* -r9_41x, r9_51x, -r9_81x, r9_91x;*/
+ r9_x[1][1] = (7.0f*cx + c3x)*0.125f;/* -r9_32x, r9_62x, -r9_72x;*/
+ r9_x[2][1] = x->x_sqrt2_16*(7.0f*sx + 3.0f*s3x);
+ r9_x[2][2] = (7.0f*cx + 9.0f*c3x)*0.0625f;/* -r9_63x, r9_73x;*/
+ r9_x[3][0] = -x->x_sqrt2_16*(14.0f*s2x + s4x)*0.5f;
+ r9_x[3][3] = (7.0f*c2x + c4x)*0.125f;/* -r9_54x, r9_84x, -r9_94x;*/
+ r9_x[4][0] = x->x_sqrt7_8*(4.0f*c2x + c4x - 5.0f)*0.25f;
+ r9_x[4][3] = x->x_sqrt14_16*(2.0f*s2x + s4x);
+ r9_x[4][4] = (5.0f + 4.0f*c2x + 7.0f*c4x)*0.0625f;/* -r9_85x, r9_95x;*/
+ r9_x[5][1] = x->x_sqrt7_8*(c3x - cx);
+ r9_x[5][2] = x->x_sqrt14_16*(sx - 3.0f*s3x);
+ r9_x[5][5] = (cx + 7.0f*c3x)*0.125f;/* -r9_76x;*/
+ r9_x[6][1] = x->x_sqrt14_16*(s3x - 3.0f*sx);
+ r9_x[6][2] = x->x_sqrt7_8*(c3x - cx)*1.5f;
+ r9_x[6][5] = x->x_sqrt2_16*(3.0f*sx + 7.0f*s3x);
+ r9_x[6][6] = (9.0f*cx + 7.0f*c3x)*0.0625f;
+ r9_x[7][0] = x->x_sqrt14_16*(2.0f*s2x - s4x)*0.5f;
+ r9_x[7][3] = x->x_sqrt7_8*(c4x - c2x);
+ r9_x[7][4] = x->x_sqrt2_16*(2.0f*s2x - 7.0f*s4x);
+ r9_x[7][7] = (c2x + 7.0f*c4x)*0.125f;/* -r9_98x*/
+ r9_x[8][0] = x->x_sqrt35_64*(3.0f - 4.0f*c2x + c4x);
+ r9_x[8][3] = x->x_sqrt70_32*(s4x - 2.0f*s2x);
+ r9_x[8][4] = x->x_sqrt5_32*(7.0f*c4x - 3.0f - 4.0f*c2x);
+ r9_x[8][7] = x->x_sqrt10_4*(2.0f*s2x + 7.0f*s4x)*0.125f;
+ r9_x[8][8] = (9.0f + 20.0f*c2x + 35.0f*c4x)*0.015625f;
+
+ r9_x[0][3] = -r9_x[3][0];
+ r9_x[0][4] = r9_x[4][0];
+ r9_x[0][7] = -r9_x[7][0];
+ r9_x[0][8] = r9_x[8][0];
+ r9_x[1][2] = -r9_x[2][1];
+ r9_x[1][5] = r9_x[5][1];
+ r9_x[1][6] = -r9_x[6][1];
+ r9_x[2][5] = -r9_x[5][2];
+ r9_x[2][6] = r9_x[6][2];
+ r9_x[3][4] = -r9_x[4][3];
+ r9_x[3][7] = r9_x[7][3];
+ r9_x[3][8] = -r9_x[8][3];
+ r9_x[4][7] = -r9_x[7][4];
+ r9_x[4][8] = r9_x[8][4];
+ r9_x[5][6] = -r9_x[6][5];
+ r9_x[7][8] = -r9_x[8][7];
+
+ for(j=0; j<8; j+=2)
+ {
+ for(i=0; i<8; i+=2)
+ {
+ r9_zy[j][i] = r9_z[j][j]*r9_y[j][i];
+ r9_zy[j][i+1] = r9_z[j][j+1]*r9_y[j+1][i+1];
+
+ r9_zy[j+1][i] = r9_z[j+1][j]*r9_y[j][i];
+ r9_zy[j+1][i+1] = r9_z[j+1][j+1]*r9_y[j+1][i+1];
+ }
+ r9_zy[j][8] = r9_z[j][j]*r9_y[j][8];
+ r9_zy[j+1][8] = r9_z[j+1][j]*r9_y[j][8];
+ }
+ for(i=0; i<=8; i+=2)
+ {
+ r9_zy[8][i] = r9_y[8][i];
+ }
+
+ at = x->x_at9;
+ at += 2;
+
+ for(i=0; i<8; i++)
+ {
+ SETFLOAT(at, (r9_zy[i][0]*r9_x[0][0] + r9_zy[i][3]*r9_x[3][0] + r9_zy[i][4]*r9_x[4][0] + r9_zy[i][7]*r9_x[7][0] + r9_zy[i][8]*r9_x[8][0]));
+ at++;
+ SETFLOAT(at, (r9_zy[i][1]*r9_x[1][1] + r9_zy[i][2]*r9_x[2][1] + r9_zy[i][5]*r9_x[5][1] + r9_zy[i][6]*r9_x[6][1]));
+ at++;
+ SETFLOAT(at, (r9_zy[i][1]*r9_x[1][2] + r9_zy[i][2]*r9_x[2][2] + r9_zy[i][5]*r9_x[5][2] + r9_zy[i][6]*r9_x[6][2]));
+ at++;
+ SETFLOAT(at, (r9_zy[i][0]*r9_x[0][3] + r9_zy[i][3]*r9_x[3][3] + r9_zy[i][4]*r9_x[4][3] + r9_zy[i][7]*r9_x[7][3] + r9_zy[i][8]*r9_x[8][3]));
+ at++;
+ SETFLOAT(at, (r9_zy[i][0]*r9_x[0][4] + r9_zy[i][3]*r9_x[3][4] + r9_zy[i][4]*r9_x[4][4] + r9_zy[i][7]*r9_x[7][4] + r9_zy[i][8]*r9_x[8][4]));
+ at++;
+ SETFLOAT(at, (r9_zy[i][1]*r9_x[1][5] + r9_zy[i][2]*r9_x[2][5] + r9_zy[i][5]*r9_x[5][5] + r9_zy[i][6]*r9_x[6][5]));
+ at++;
+ SETFLOAT(at, (r9_zy[i][1]*r9_x[1][6] + r9_zy[i][2]*r9_x[2][6] + r9_zy[i][5]*r9_x[5][6] + r9_zy[i][6]*r9_x[6][6]));
+ at++;
+ SETFLOAT(at, (r9_zy[i][0]*r9_x[0][7] + r9_zy[i][3]*r9_x[3][7] + r9_zy[i][4]*r9_x[4][7] + r9_zy[i][7]*r9_x[7][7] + r9_zy[i][8]*r9_x[8][7]));
+ at++;
+ SETFLOAT(at, (r9_zy[i][0]*r9_x[0][8] + r9_zy[i][3]*r9_x[3][8] + r9_zy[i][4]*r9_x[4][8] + r9_zy[i][7]*r9_x[7][8] + r9_zy[i][8]*r9_x[8][8]));
+ at++;
+ }
+
+ SETFLOAT(at, (r9_zy[8][0]*r9_x[0][0] + r9_zy[8][4]*r9_x[4][0] + r9_zy[8][8]*r9_x[8][0]));
+ at++;
+ SETFLOAT(at, (r9_zy[8][2]*r9_x[2][1] + r9_zy[8][6]*r9_x[6][1]));
+ at++;
+ SETFLOAT(at, (r9_zy[8][2]*r9_x[2][2] + r9_zy[8][6]*r9_x[6][2]));
+ at++;
+ SETFLOAT(at, (r9_zy[8][0]*r9_x[0][3] + r9_zy[8][4]*r9_x[4][3] + r9_zy[8][8]*r9_x[8][3]));
+ at++;
+ SETFLOAT(at, (r9_zy[8][0]*r9_x[0][4] + r9_zy[8][4]*r9_x[4][4] + r9_zy[8][8]*r9_x[8][4]));
+ at++;
+ SETFLOAT(at, (r9_zy[8][2]*r9_x[2][5] + r9_zy[8][6]*r9_x[6][5]));
+ at++;
+ SETFLOAT(at, (r9_zy[8][2]*r9_x[2][6] + r9_zy[8][6]*r9_x[6][6]));
+ at++;
+ SETFLOAT(at, (r9_zy[8][0]*r9_x[0][7] + r9_zy[8][4]*r9_x[4][7] + r9_zy[8][8]*r9_x[8][7]));
+ at++;
+ SETFLOAT(at, (r9_zy[8][0]*r9_x[0][8] + r9_zy[8][4]*r9_x[4][8] + r9_zy[8][8]*r9_x[8][8]));
+
+ outlet_anything(x->x_out9, x->x_s_matrix, x->x_size9, x->x_at9);
+ }
+
+ r9_z[0][0] = c3z;
+ r9_z[0][1] = -s3z;
+ r9_z[1][0] = s3z;
+ r9_z[1][1] = c3z;
+ r9_z[2][2] = c2z;
+ r9_z[2][3] = -s2z;
+ r9_z[3][2] = s2z;
+ r9_z[3][3] = c2z;
+ r9_z[4][4] = cz;
+ r9_z[4][5] = -sz;
+ r9_z[5][4] = sz;
+ r9_z[5][5] = cz;
+ r9_z[6][6] = 1.0f;
+ /*y
+ r7_11=(15*c + c3)/16;
+ r7_22=(5 + 3*c2)/8;
+ r7_31 = x->x_sqrt6*(5*s + s3)/16;
+ r7_33=(5*c + 3*c3)/8;
+ r7_42 = x->x_sqrt6*(s2)/4;
+ r7_44=(c2);
+ r7_51 = x->x_sqrt15*(c - c3)/16;
+ r7_53 = x->x_sqrt10*(-s + 3*s3)/16;
+ r7_55=(c + 15*c3)/16;
+ r7_62 = x->x_sqrt15*(1 - c2)/8;
+ r7_64 = x->x_sqrt10*(s2)/4;
+ r7_66=(3 + 5*c2)/8;
+ r7_71 = x->x_sqrt10*(3*s - s3)/16;
+ r7_73 = x->x_sqrt15*(c - c3)/8 = 2*r7_51;
+ r7_75 = x->x_sqrt6*(s + 5*s3)/16;
+ r7_77=(3*c + 5*c3)/8;
+
+ */
+ r9_y[0][0] = (15.0f*cy + c3y)*0.0625f;/* -r7_31y, r7_51y, -r7_71y;*/
+ r9_y[1][1] = (5.0f + 3.0f*c2y)*0.125f;/* -r7_42y, r7_62y;*/
+ r9_y[2][0] = x->x_sqrt6_4*(5.0f*sy + s3y)*0.25f;
+ r9_y[2][2] = (5.0f*cy + 3.0f*c3y)*0.125f;/* -r7_53y, r7_73y;*/
+ r9_y[3][1] = x->x_sqrt6_4*s2y;
+ r9_y[3][3] = c2y;/* -r7_64y;*/
+ r9_y[6][2] = x->x_sqrt15_8*(cy - c3y);
+ r9_y[4][0] = r9_y[6][2]*0.5f;
+ r9_y[4][2] = x->x_sqrt10_4*(3.0f*s3y - sy)*0.25f;
+ r9_y[4][4] = (cy + 15.0f*c3y)*0.0625f;/* -r7_75y;*/
+ r9_y[5][1] = x->x_sqrt15_8*(1.0f - c2y);
+ r9_y[5][3] = x->x_sqrt10_4*s2y;
+ r9_y[5][5] = (3.0f + 5.0f*c2y)*0.125f;
+ r9_y[6][0] = x->x_sqrt10_4*(3.0f*sy - s3y)*0.25f;
+
+ r9_y[6][4] = x->x_sqrt6_4*(sy + 5.0f*s3y)*0.25f;
+ r9_y[6][6] = (3.0f*cy + 5.0f*c3y)*0.125f;
+
+ r9_y[0][2] = -r9_y[2][0];
+ r9_y[0][4] = r9_y[4][0];
+ r9_y[0][6] = -r9_y[6][0];
+ r9_y[1][3] = -r9_y[3][1];
+ r9_y[1][5] = r9_y[5][1];
+ r9_y[2][4] = -r9_y[4][2];
+ r9_y[2][6] = r9_y[6][2];
+ r9_y[3][5] = -r9_y[5][3];
+ r9_y[4][6] = -r9_y[6][4];
+
+ /*x
+ r7_11=(5 + 3*c2)/8;
+ r7_22=(15*c + c3)/16;
+ r7_32 = x->x_sqrt6*(5*s + s3)/16;
+ r7_33=(5*c + 3*c3)/8;
+ r7_41 = x->x_sqrt6*(-s2)/4;
+ r7_44=(c2);
+ r7_51 = x->x_sqrt15*(-1 + c2)/8;
+ r7_54 = x->x_sqrt10*(s2)/4;
+ r7_55=(3 + 5*c2)/8;
+ r7_62 = x->x_sqrt15*(-c + c3)/16;
+ r7_63 = x->x_sqrt10*(s - 3*s3)/16;
+ r7_66=(c + 15*c3)/16;
+ r7_72 = x->x_sqrt10*(-3*s + s3)/16;
+ r7_73 = x->x_sqrt15*(-c + c3)/8 = 2*r7_62;
+ r7_76 = x->x_sqrt6*(s + 5*s3)/16;
+ r7_77=(3*c + 5*c3)/8;
+ */
+
+ r9_x[0][0] = (5.0f + 3.0f*c2x)*0.125f;/* -r7_41, r7_51;*/
+ r9_x[1][1] = (15.0f*cx + c3x)*0.0625f;/* -r7_32, r7_62, -r7_72;*/
+ r9_x[2][1] = x->x_sqrt6_4*(5.0f*sx + s3x)*0.25f;
+ r9_x[2][2] = (5.0f*cx + 3.0f*c3x)*0.125f;/* */
+ r9_x[3][0] = -x->x_sqrt6_4*s2x;
+ r9_x[3][3] = c2x;
+ r9_x[4][0] = x->x_sqrt15_8*(c2x - 1.0f);
+ r9_x[4][3] = x->x_sqrt10_4*s2x;
+ r9_x[4][4] = (3.0f + 5.0f*c2x)*0.125f;
+ r9_x[6][2] = x->x_sqrt15_8*(c3x - cx);
+ r9_x[5][1] = r9_x[6][2]*0.5f;
+ r9_x[5][2] = x->x_sqrt10_4*(sx - 3.0f*s3x)*0.25f;
+ r9_x[5][5] = (cx + 15.0f*c3x)*0.0625f;
+ r9_x[6][1] = x->x_sqrt10_4*(s3x - 3.0f*sx)*0.25f;
+
+ r9_x[6][5] = x->x_sqrt6_4*(sx + 5.0f*s3x)*0.25f;
+ r9_x[6][6] = (3.0f*cx + 5.0f*c3x)*0.125f;
+
+ r9_x[0][3] = -r9_x[3][0];
+ r9_x[0][4] = r9_x[4][0];
+ r9_x[1][2] = -r9_x[2][1];
+ r9_x[1][5] = r9_x[5][1];
+ r9_x[1][6] = -r9_x[6][1];
+ r9_x[2][5] = -r9_x[5][2];
+ r9_x[2][6] = r9_x[6][2];
+ r9_x[3][4] = -r9_x[4][3];
+ r9_x[5][6] = -r9_x[6][5];
+
+ for(j=0; j<6; j+=2)
+ {
+ for(i=0; i<6; i+=2)
+ {
+ r9_zy[j][i] = r9_z[j][j]*r9_y[j][i];
+ r9_zy[j][i+1] = r9_z[j][j+1]*r9_y[j+1][i+1];
+
+ r9_zy[j+1][i] = r9_z[j+1][j]*r9_y[j][i];
+ r9_zy[j+1][i+1] = r9_z[j+1][j+1]*r9_y[j+1][i+1];
+ }
+ r9_zy[j][6] = r9_z[j][j]*r9_y[j][6];
+ r9_zy[j+1][6] = r9_z[j+1][j]*r9_y[j][6];
+ }
+ for(i=0; i<=6; i+=2)
+ {
+ r9_zy[6][i] = r9_y[6][i];
+ }
+
+ at = x->x_at7;
+ at += 2;
+
+ for(i=0; i<6; i++)
+ {
+ SETFLOAT(at, (r9_zy[i][0]*r9_x[0][0] + r9_zy[i][3]*r9_x[3][0] + r9_zy[i][4]*r9_x[4][0]));
+ at++;
+ SETFLOAT(at, (r9_zy[i][1]*r9_x[1][1] + r9_zy[i][2]*r9_x[2][1] + r9_zy[i][5]*r9_x[5][1] + r9_zy[i][6]*r9_x[6][1]));
+ at++;
+ SETFLOAT(at, (r9_zy[i][1]*r9_x[1][2] + r9_zy[i][2]*r9_x[2][2] + r9_zy[i][5]*r9_x[5][2] + r9_zy[i][6]*r9_x[6][2]));
+ at++;
+ SETFLOAT(at, (r9_zy[i][0]*r9_x[0][3] + r9_zy[i][3]*r9_x[3][3] + r9_zy[i][4]*r9_x[4][3]));
+ at++;
+ SETFLOAT(at, (r9_zy[i][0]*r9_x[0][4] + r9_zy[i][3]*r9_x[3][4] + r9_zy[i][4]*r9_x[4][4]));
+ at++;
+ SETFLOAT(at, (r9_zy[i][1]*r9_x[1][5] + r9_zy[i][2]*r9_x[2][5] + r9_zy[i][5]*r9_x[5][5] + r9_zy[i][6]*r9_x[6][5]));
+ at++;
+ SETFLOAT(at, (r9_zy[i][1]*r9_x[1][6] + r9_zy[i][2]*r9_x[2][6] + r9_zy[i][5]*r9_x[5][6] + r9_zy[i][6]*r9_x[6][6]));
+ at++;
+ }
+
+ SETFLOAT(at, (r9_zy[6][0]*r9_x[0][0] + r9_zy[6][4]*r9_x[4][0]));
+ at++;
+ SETFLOAT(at, (r9_zy[6][2]*r9_x[2][1] + r9_zy[6][6]*r9_x[6][1]));
+ at++;
+ SETFLOAT(at, (r9_zy[6][2]*r9_x[2][2] + r9_zy[6][6]*r9_x[6][2]));
+ at++;
+ SETFLOAT(at, (r9_zy[6][0]*r9_x[0][3] + r9_zy[6][4]*r9_x[4][3]));
+ at++;
+ SETFLOAT(at, (r9_zy[6][0]*r9_x[0][4] + r9_zy[6][4]*r9_x[4][4]));
+ at++;
+ SETFLOAT(at, (r9_zy[6][2]*r9_x[2][5] + r9_zy[6][6]*r9_x[6][5]));
+ at++;
+ SETFLOAT(at, (r9_zy[6][2]*r9_x[2][6] + r9_zy[6][6]*r9_x[6][6]));
+
+ outlet_anything(x->x_out7, x->x_s_matrix, x->x_size7, x->x_at7);
+ }
+
+ r9_z[0][0] = c2z;
+ r9_z[0][1] = -s2z;
+ r9_z[1][0] = s2z;
+ r9_z[1][1] = c2z;
+ r9_z[2][2] = cz;
+ r9_z[2][3] = -sz;
+ r9_z[3][2] = sz;
+ r9_z[3][3] = cz;
+ r9_z[4][4] = 1.0f;
+ /*y
+ r5_11=(3 + c2)/4;
+ r5_22=(c);
+ r5_31 = (s2)/2;
+ r5_33=(c2);
+ r5_42 = (s);
+ r5_44=(c);
+ r5_51 = x->x_sqrt3*(1 - c2)/4;
+ r5_53 = x->x_sqrt3*(s2)/2;
+ r5_55=(1 + 3*c2)/4;
+ */
+ r9_y[0][0] = (3.0f + c2y)*0.25f;/* -r5_31y, r5_51y;*/
+ r9_y[1][1] = cy;/* -r5_42y;*/
+ r9_y[2][0] = s2y*0.5f;
+ r9_y[2][2] = c2y;/* -r5_53y;*/
+ r9_y[3][1] = sy;
+ r9_y[3][3] = cy;
+ r9_y[4][0] = x->x_sqrt3_2*(1.0f - c2y)*0.5f;
+ r9_y[4][2] = x->x_sqrt3_2*s2y;
+ r9_y[4][4] = (1.0f + 3.0f*c2y)*0.25f;
+
+ r9_y[0][2] = -r9_y[2][0];
+ r9_y[0][4] = r9_y[4][0];
+ r9_y[1][3] = -r9_y[3][1];
+ r9_y[2][4] = -r9_y[4][2];
+
+ /*x
+ r5_11=(3 + c2)/4;
+ r5_22=(c);
+ r5_32 = (s);
+ r5_33=(c);
+ r5_41 = (-s2)/2;
+ r5_44=(c2);
+ r5_51 = x->x_sqrt3*(-1 + c2)/4;
+ r5_54 = x->x_sqrt3*(s2)/2;
+ r5_55=(1 + 3*c2)/4;
+ */
+
+ r9_x[0][0] = (3.0f + c2x)*0.25f;
+ r9_x[1][1] = cx;
+ r9_x[2][1] = sx;
+ r9_x[2][2] = cx;
+ r9_x[3][0] = -0.5f*s2x;
+ r9_x[3][3] = c2x;
+ r9_x[4][0] = x->x_sqrt3_2*(c2x - 1.0f)*0.5f;
+ r9_x[4][3] = x->x_sqrt3_2*s2x;
+ r9_x[4][4] = (1.0f + 3.0f*c2x)*0.25f;
+
+ r9_x[0][3] = -r9_x[3][0];
+ r9_x[0][4] = r9_x[4][0];
+ r9_x[1][2] = -r9_x[2][1];
+ r9_x[3][4] = -r9_x[4][3];
+
+ for(j=0; j<4; j+=2)
+ {
+ for(i=0; i<4; i+=2)
+ {
+ r9_zy[j][i] = r9_z[j][j]*r9_y[j][i];
+ r9_zy[j][i+1] = r9_z[j][j+1]*r9_y[j+1][i+1];
+
+ r9_zy[j+1][i] = r9_z[j+1][j]*r9_y[j][i];
+ r9_zy[j+1][i+1] = r9_z[j+1][j+1]*r9_y[j+1][i+1];
+ }
+ r9_zy[j][4] = r9_z[j][j]*r9_y[j][4];
+ r9_zy[j+1][4] = r9_z[j+1][j]*r9_y[j][4];
+ }
+ for(i=0; i<=4; i+=2)
+ {
+ r9_zy[4][i] = r9_y[4][i];
+ }
+
+ at = x->x_at5;
+ at += 2;
+
+ for(i=0; i<4; i++)
+ {
+ SETFLOAT(at, (r9_zy[i][0]*r9_x[0][0] + r9_zy[i][3]*r9_x[3][0] + r9_zy[i][4]*r9_x[4][0]));
+ at++;
+ SETFLOAT(at, (r9_zy[i][1]*r9_x[1][1] + r9_zy[i][2]*r9_x[2][1]));
+ at++;
+ SETFLOAT(at, (r9_zy[i][1]*r9_x[1][2] + r9_zy[i][2]*r9_x[2][2]));
+ at++;
+ SETFLOAT(at, (r9_zy[i][0]*r9_x[0][3] + r9_zy[i][3]*r9_x[3][3] + r9_zy[i][4]*r9_x[4][3]));
+ at++;
+ SETFLOAT(at, (r9_zy[i][0]*r9_x[0][4] + r9_zy[i][3]*r9_x[3][4] + r9_zy[i][4]*r9_x[4][4]));
+ at++;
+ }
+
+ SETFLOAT(at, (r9_zy[4][0]*r9_x[0][0] + r9_zy[4][4]*r9_x[4][0]));
+ at++;
+ SETFLOAT(at, (r9_zy[4][2]*r9_x[2][1]));
+ at++;
+ SETFLOAT(at, (r9_zy[4][2]*r9_x[2][2]));
+ at++;
+ SETFLOAT(at, (r9_zy[4][0]*r9_x[0][3] + r9_zy[4][4]*r9_x[4][3]));
+ at++;
+ SETFLOAT(at, (r9_zy[4][0]*r9_x[0][4] + r9_zy[4][4]*r9_x[4][4]));
+
+ outlet_anything(x->x_out5, x->x_s_matrix, x->x_size5, x->x_at5);
+ }
+
+ r9_z[0][0] = cz;
+ r9_z[0][1] = -sz;
+ r9_z[1][0] = sz;
+ r9_z[1][1] = cz;
+ r9_z[2][2] = 1.0f;
+ /*y
+ r3_11=(c);
+ r3_22=(1);
+ r3_31 = (s);
+ r3_33=(c);
+ */
+ r9_y[0][0] = cy;/* -r3_31y;*/
+ r9_y[1][1] = 1.0f;
+ r9_y[2][0] = sy;
+ r9_y[2][2] = cy;
+
+ r9_y[0][2] = -r9_y[2][0];
+
+ /*x
+ r3_11=(1);
+ r3_22=(c);
+ r3_32 = (s);
+ r3_33=(c);
+ */
+ r9_x[0][0] = 1.0f;
+ r9_x[1][1] = cx;/* -r3_32x;*/
+ r9_x[2][1] = sx;
+ r9_x[2][2] = cx;
+
+ r9_x[1][2] = -r9_x[2][1];
+
+ r9_zy[0][0] = cz*r9_y[0][0];
+ r9_zy[0][1] = -sz*r9_y[1][1];
+ r9_zy[0][2] = cz*r9_y[0][2];
+
+ r9_zy[1][0] = sz*r9_y[0][0];
+ r9_zy[1][1] = cz*r9_y[1][1];
+ r9_zy[1][2] = sz*r9_y[0][2];
+
+ r9_zy[2][0] = r9_y[2][0];
+ r9_zy[2][1] = 0.0f;
+ r9_zy[2][2] = r9_y[2][2];
+
+ at = x->x_at3;
+ at += 2;
+
+ for(i=0; i<2; i++)
+ {
+ SETFLOAT(at, (r9_zy[i][0]*r9_x[0][0]));
+ at++;
+ SETFLOAT(at, (r9_zy[i][1]*r9_x[1][1] + r9_zy[i][2]*r9_x[2][1]));
+ at++;
+ SETFLOAT(at, (r9_zy[i][1]*r9_x[1][2] + r9_zy[i][2]*r9_x[2][2]));
+ at++;
+ }
+
+ SETFLOAT(at, (r9_zy[2][0]*r9_x[0][0]));
+ at++;
+ SETFLOAT(at, (r9_zy[2][2]*r9_x[2][1]));
+ at++;
+ SETFLOAT(at, (r9_zy[2][2]*r9_x[2][2]));
+
+ outlet_anything(x->x_out3, x->x_s_matrix, x->x_size3, x->x_at3);
}
static void ambi_rot_list(t_ambi_rot *x, t_symbol *s, int argc, t_atom *argv)
{
- if(argc == 1)
- ambi_rot_float(x, atom_getfloatarg(0, argc, argv));/* = ambi_rot_z(); */
- else if(argc == 2)
- ambi_rot_zy(x, atom_getfloatarg(0, argc, argv), atom_getfloatarg(1, argc, argv));
- else if(argc >= 3)
- ambi_rot_zyx(x, atom_getfloatarg(0, argc, argv), atom_getfloatarg(1, argc, argv), atom_getfloatarg(2, argc, argv));
+ if(argc == 1)
+ ambi_rot_float(x, atom_getfloatarg(0, argc, argv));/* = ambi_rot_z(); */
+ else if(argc == 2)
+ ambi_rot_zy(x, atom_getfloatarg(0, argc, argv), atom_getfloatarg(1, argc, argv));
+ else if(argc >= 3)
+ ambi_rot_zyx(x, atom_getfloatarg(0, argc, argv), atom_getfloatarg(1, argc, argv), atom_getfloatarg(2, argc, argv));
}
static void ambi_rot_free(t_ambi_rot *x)
{
- if(x->x_size11)
- freebytes(x->x_at11, x->x_size11 * sizeof(t_atom));
- if(x->x_size9)
- freebytes(x->x_at9, x->x_size9 * sizeof(t_atom));
- if(x->x_size7)
- freebytes(x->x_at7, x->x_size7 * sizeof(t_atom));
- if(x->x_size5)
- freebytes(x->x_at5, x->x_size5 * sizeof(t_atom));
- if(x->x_size3)
- freebytes(x->x_at3, x->x_size3 * sizeof(t_atom));
- if(x->x_size2)
- freebytes(x->x_at2, x->x_size2 * sizeof(t_atom));
+ if(x->x_size11)
+ freebytes(x->x_at11, x->x_size11 * sizeof(t_atom));
+ if(x->x_size9)
+ freebytes(x->x_at9, x->x_size9 * sizeof(t_atom));
+ if(x->x_size7)
+ freebytes(x->x_at7, x->x_size7 * sizeof(t_atom));
+ if(x->x_size5)
+ freebytes(x->x_at5, x->x_size5 * sizeof(t_atom));
+ if(x->x_size3)
+ freebytes(x->x_at3, x->x_size3 * sizeof(t_atom));
+ if(x->x_size2)
+ freebytes(x->x_at2, x->x_size2 * sizeof(t_atom));
}
static void *ambi_rot_new(t_floatarg forder)
{
- t_ambi_rot *x = (t_ambi_rot *)pd_new(ambi_rot_class);
- t_atom *at;
- int i=(int)forder;
-
- if(i < 1)
- i = 1;
- if(i > 12)
- i = 12;
- x->x_order = i;
- x->x_size2 = 2*2 + 2;
- x->x_at2 = (t_atom *)getbytes(x->x_size2 * sizeof(t_atom));
- at = x->x_at2;
- SETFLOAT(at, 2.0f);
- at++;
- SETFLOAT(at, 2.0f);
- at++;
- for(i=0; i<4; i++)
- {
- SETFLOAT(at, 0.0f);
- at++;
- }
- x->x_size3 = 3*3 + 2;
- x->x_at3 = (t_atom *)getbytes(x->x_size3 * sizeof(t_atom));
- at = x->x_at3;
- SETFLOAT(at, 3.0f);
- at++;
- SETFLOAT(at, 3.0f);
- at++;
- for(i=0; i<9; i++)
- {
- SETFLOAT(at, 0.0f);
- at++;
- }
- x->x_out3 = outlet_new(&x->x_obj, &s_list);
- if(x->x_order >= 2)
- {
- x->x_size5 = 5*5 + 2;
- x->x_at5 = (t_atom *)getbytes(x->x_size5 * sizeof(t_atom));
- at = x->x_at5;
- SETFLOAT(at, 5.0f);
- at++;
- SETFLOAT(at, 5.0f);
- at++;
- for(i=0; i<25; i++)
- {
- SETFLOAT(at, 0.0f);
- at++;
- }
- x->x_out5 = outlet_new(&x->x_obj, &s_list);
- }
- else
- {
- x->x_size5 = 0;
- x->x_at5 = (t_atom *)0;
- }
- if(x->x_order >= 3)
- {
- x->x_size7 = 7*7 + 2;
- x->x_at7 = (t_atom *)getbytes(x->x_size7 * sizeof(t_atom));
- at = x->x_at7;
- SETFLOAT(at, 7.0f);
- at++;
- SETFLOAT(at, 7.0f);
- at++;
- for(i=0; i<49; i++)
- {
- SETFLOAT(at, 0.0f);
- at++;
- }
- x->x_out7 = outlet_new(&x->x_obj, &s_list);
- }
- else
- {
- x->x_size7 = 0;
- x->x_at7 = (t_atom *)0;
- }
- if(x->x_order >= 4)
- {
- x->x_size9 = 9*9 + 2;
- x->x_at9 = (t_atom *)getbytes(x->x_size9 * sizeof(t_atom));
- at = x->x_at9;
- SETFLOAT(at, 9.0f);
- at++;
- SETFLOAT(at, 9.0f);
- at++;
- for(i=0; i<81; i++)
- {
- SETFLOAT(at, 0.0f);
- at++;
- }
- x->x_out9 = outlet_new(&x->x_obj, &s_list);
- }
- else
- {
- x->x_size9 = 0;
- x->x_at9 = (t_atom *)0;
- }
-
- if(x->x_order >= 5)
- {
- x->x_size11 = 11*11 + 2;
- x->x_at11 = (t_atom *)getbytes(x->x_size11 * sizeof(t_atom));
- at = x->x_at11;
- SETFLOAT(at, 11.0f);
- at++;
- SETFLOAT(at, 11.0f);
- at++;
- for(i=0; i<121; i++)
- {
- SETFLOAT(at, 0.0f);
- at++;
- }
- x->x_out11 = outlet_new(&x->x_obj, &s_list);
- }
- else
- {
- x->x_size11 = 0;
- x->x_at11 = (t_atom *)0;
- }
-
- if(x->x_order >= 6)
- x->x_out13 = outlet_new(&x->x_obj, &s_list);
-
- if(x->x_order >= 7)
- x->x_out15 = outlet_new(&x->x_obj, &s_list);
-
- if(x->x_order >= 8)
- x->x_out17 = outlet_new(&x->x_obj, &s_list);
-
- if(x->x_order >= 9)
- x->x_out19 = outlet_new(&x->x_obj, &s_list);
-
- if(x->x_order >= 10)
- x->x_out21 = outlet_new(&x->x_obj, &s_list);
-
- if(x->x_order >= 11)
- x->x_out23 = outlet_new(&x->x_obj, &s_list);
-
- if(x->x_order >= 12)
- x->x_out25 = outlet_new(&x->x_obj, &s_list);
-
- x->x_sqrt2_16 = (float)(sqrt(2.0) / 16.0);
- x->x_sqrt3_2 = (float)(sqrt(3.0) / 2.0);
- x->x_sqrt5_32 = (float)(sqrt(5.0) / 32.0);
- x->x_sqrt6_4 = (float)(sqrt(6.0) / 4.0);
- x->x_sqrt7_8 = (float)(sqrt(7.0) / 8.0);
- x->x_sqrt10_4 = (float)(sqrt(10.0) / 4.0);
- x->x_sqrt14_16 = (float)(sqrt(14.0) / 16.0);
- x->x_sqrt15_8 = (float)(sqrt(15.0) / 8.0);
- x->x_sqrt35_64 = (float)(sqrt(35.0) / 64.0);
- x->x_sqrt70_32 = (float)(sqrt(70.0) / 32.0);
-
- x->x_pi_over_180 = (float)(4.0 * atan(1.0) / 180.0);
-
- x->x_s_matrix = gensym("matrix");
- return (x);
+ t_ambi_rot *x = (t_ambi_rot *)pd_new(ambi_rot_class);
+ t_atom *at;
+ int i=(int)forder;
+
+ if(i < 1)
+ i = 1;
+ if(i > 12)
+ i = 12;
+ x->x_order = i;
+ x->x_size2 = 2*2 + 2;
+ x->x_at2 = (t_atom *)getbytes(x->x_size2 * sizeof(t_atom));
+ at = x->x_at2;
+ SETFLOAT(at, 2.0f);
+ at++;
+ SETFLOAT(at, 2.0f);
+ at++;
+ for(i=0; i<4; i++)
+ {
+ SETFLOAT(at, 0.0f);
+ at++;
+ }
+ x->x_size3 = 3*3 + 2;
+ x->x_at3 = (t_atom *)getbytes(x->x_size3 * sizeof(t_atom));
+ at = x->x_at3;
+ SETFLOAT(at, 3.0f);
+ at++;
+ SETFLOAT(at, 3.0f);
+ at++;
+ for(i=0; i<9; i++)
+ {
+ SETFLOAT(at, 0.0f);
+ at++;
+ }
+ x->x_out3 = outlet_new(&x->x_obj, &s_list);
+ if(x->x_order >= 2)
+ {
+ x->x_size5 = 5*5 + 2;
+ x->x_at5 = (t_atom *)getbytes(x->x_size5 * sizeof(t_atom));
+ at = x->x_at5;
+ SETFLOAT(at, 5.0f);
+ at++;
+ SETFLOAT(at, 5.0f);
+ at++;
+ for(i=0; i<25; i++)
+ {
+ SETFLOAT(at, 0.0f);
+ at++;
+ }
+ x->x_out5 = outlet_new(&x->x_obj, &s_list);
+ }
+ else
+ {
+ x->x_size5 = 0;
+ x->x_at5 = (t_atom *)0;
+ }
+ if(x->x_order >= 3)
+ {
+ x->x_size7 = 7*7 + 2;
+ x->x_at7 = (t_atom *)getbytes(x->x_size7 * sizeof(t_atom));
+ at = x->x_at7;
+ SETFLOAT(at, 7.0f);
+ at++;
+ SETFLOAT(at, 7.0f);
+ at++;
+ for(i=0; i<49; i++)
+ {
+ SETFLOAT(at, 0.0f);
+ at++;
+ }
+ x->x_out7 = outlet_new(&x->x_obj, &s_list);
+ }
+ else
+ {
+ x->x_size7 = 0;
+ x->x_at7 = (t_atom *)0;
+ }
+ if(x->x_order >= 4)
+ {
+ x->x_size9 = 9*9 + 2;
+ x->x_at9 = (t_atom *)getbytes(x->x_size9 * sizeof(t_atom));
+ at = x->x_at9;
+ SETFLOAT(at, 9.0f);
+ at++;
+ SETFLOAT(at, 9.0f);
+ at++;
+ for(i=0; i<81; i++)
+ {
+ SETFLOAT(at, 0.0f);
+ at++;
+ }
+ x->x_out9 = outlet_new(&x->x_obj, &s_list);
+ }
+ else
+ {
+ x->x_size9 = 0;
+ x->x_at9 = (t_atom *)0;
+ }
+
+ if(x->x_order >= 5)
+ {
+ x->x_size11 = 11*11 + 2;
+ x->x_at11 = (t_atom *)getbytes(x->x_size11 * sizeof(t_atom));
+ at = x->x_at11;
+ SETFLOAT(at, 11.0f);
+ at++;
+ SETFLOAT(at, 11.0f);
+ at++;
+ for(i=0; i<121; i++)
+ {
+ SETFLOAT(at, 0.0f);
+ at++;
+ }
+ x->x_out11 = outlet_new(&x->x_obj, &s_list);
+ }
+ else
+ {
+ x->x_size11 = 0;
+ x->x_at11 = (t_atom *)0;
+ }
+
+ if(x->x_order >= 6)
+ x->x_out13 = outlet_new(&x->x_obj, &s_list);
+
+ if(x->x_order >= 7)
+ x->x_out15 = outlet_new(&x->x_obj, &s_list);
+
+ if(x->x_order >= 8)
+ x->x_out17 = outlet_new(&x->x_obj, &s_list);
+
+ if(x->x_order >= 9)
+ x->x_out19 = outlet_new(&x->x_obj, &s_list);
+
+ if(x->x_order >= 10)
+ x->x_out21 = outlet_new(&x->x_obj, &s_list);
+
+ if(x->x_order >= 11)
+ x->x_out23 = outlet_new(&x->x_obj, &s_list);
+
+ if(x->x_order >= 12)
+ x->x_out25 = outlet_new(&x->x_obj, &s_list);
+
+ x->x_sqrt2_16 = (t_float)(sqrt(2.0) / 16.0);
+ x->x_sqrt3_2 = (t_float)(sqrt(3.0) / 2.0);
+ x->x_sqrt5_32 = (t_float)(sqrt(5.0) / 32.0);
+ x->x_sqrt6_4 = (t_float)(sqrt(6.0) / 4.0);
+ x->x_sqrt7_8 = (t_float)(sqrt(7.0) / 8.0);
+ x->x_sqrt10_4 = (t_float)(sqrt(10.0) / 4.0);
+ x->x_sqrt14_16 = (t_float)(sqrt(14.0) / 16.0);
+ x->x_sqrt15_8 = (t_float)(sqrt(15.0) / 8.0);
+ x->x_sqrt35_64 = (t_float)(sqrt(35.0) / 64.0);
+ x->x_sqrt70_32 = (t_float)(sqrt(70.0) / 32.0);
+
+ x->x_pi_over_180 = (t_float)(4.0 * atan(1.0) / 180.0);
+
+ x->x_s_matrix = gensym("matrix");
+ return (x);
}
void ambi_rot_setup(void)
{
- ambi_rot_class = class_new(gensym("ambi_rot"), (t_newmethod)ambi_rot_new, (t_method)ambi_rot_free,
- sizeof(t_ambi_rot), 0, A_DEFFLOAT, 0);
- class_addfloat(ambi_rot_class, (t_method)ambi_rot_float);
- class_addlist(ambi_rot_class, (t_method)ambi_rot_list);
- class_sethelpsymbol(ambi_rot_class, gensym("iemhelp2/ambi_rot-help"));
+ ambi_rot_class = class_new(gensym("ambi_rot"), (t_newmethod)ambi_rot_new, (t_method)ambi_rot_free,
+ sizeof(t_ambi_rot), 0, A_DEFFLOAT, 0);
+ class_addfloat(ambi_rot_class, (t_method)ambi_rot_float);
+ class_addlist(ambi_rot_class, (t_method)ambi_rot_list);
+ class_sethelpsymbol(ambi_rot_class, gensym("iemhelp2/ambi_rot-help"));
}
diff --git a/src/iem_ambi.c b/src/iem_ambi.c
index 7b06298..e4fc2a2 100644
--- a/src/iem_ambi.c
+++ b/src/iem_ambi.c
@@ -3,12 +3,6 @@
iem_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-
-
#include "m_pd.h"
#include "iemlib.h"
diff --git a/src/iemlib.h b/src/iemlib.h
index c71b0ed..6be2de0 100644
--- a/src/iemlib.h
+++ b/src/iemlib.h
@@ -1,7 +1,7 @@
/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
-iemlib.h written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
+iemlib written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
#ifndef __IEMLIB_H__
#define __IEMLIB_H__
@@ -95,8 +95,14 @@ union tabfudge
int32 tf_i[2];
};
+#ifdef __i386__
#define IEM_DENORMAL(f) ((((*(unsigned int*)&(f))&0x60000000)==0) || \
(((*(unsigned int*)&(f))&0x60000000)==0x60000000))
/* more stringent test: anything not between 1e-19 and 1e19 in absolute val */
+#else
+
+#define IEM_DENORMAL(f) 0
+
+#endif
#endif
diff --git a/src/makefile b/src/makefile
index 37557e9..d250fe9 100644
--- a/src/makefile
+++ b/src/makefile
@@ -10,7 +10,7 @@ LIB = -ldl -lm -lpthread
#select either the DBG and OPT compiler flags below:
CFLAGS = -DPD -DUNIX -W -Werror -Wno-unused \
- -Wno-parentheses -Wno-switch -O6 -funroll-loops -fomit-frame-pointer \
+ -Wno-parentheses -Wno-switch -O6 -funroll-loops -fomit-frame-pointer -fno-strict-aliasing \
-DDL_OPEN
SYSTEM = $(shell uname -m)
diff --git a/src/makefile_linux b/src/makefile_linux
new file mode 100644
index 0000000..d250fe9
--- /dev/null
+++ b/src/makefile_linux
@@ -0,0 +1,51 @@
+current: all
+
+.SUFFIXES: .pd_linux
+
+INCLUDE = -I. -I/usr/local/src/pd/src
+
+LDFLAGS = -export-dynamic -shared
+LIB = -ldl -lm -lpthread
+
+#select either the DBG and OPT compiler flags below:
+
+CFLAGS = -DPD -DUNIX -W -Werror -Wno-unused \
+ -Wno-parentheses -Wno-switch -O6 -funroll-loops -fomit-frame-pointer -fno-strict-aliasing \
+ -DDL_OPEN
+
+SYSTEM = $(shell uname -m)
+
+# the sources
+
+SRC = ambi_decode.c \
+ ambi_decode2.c \
+ ambi_decode3.c \
+ ambi_decode_cube.c \
+ ambi_encode.c \
+ ambi_rot.c \
+ iem_ambi.c
+
+TARGET = iem_ambi.pd_linux
+
+
+OBJ = $(SRC:.c=.o)
+
+#
+# ------------------ targets ------------------------------------
+#
+
+clean:
+ rm $(TARGET)
+ rm *.o
+
+all: $(OBJ)
+ @echo :: $(OBJ)
+ $(LD) $(LDFLAGS) -o $(TARGET) *.o $(LIB)
+ strip --strip-unneeded $(TARGET)
+
+$(OBJ) : %.o : %.c
+ $(CC) $(CFLAGS) $(INCLUDE) -c -o $*.o $*.c
+
+
+
+