diff options
author | Katja <katjav@users.sourceforge.net> | 2011-11-16 15:40:38 +0000 |
---|---|---|
committer | Katja <katjav@users.sourceforge.net> | 2011-11-16 15:40:38 +0000 |
commit | 22ef47d0ebbc638554e65a7383ab56fb2bfbc14c (patch) | |
tree | ad471d5653036af93d9d7e5f73b9c09778d90d62 | |
parent | a4e1eadbe138dbf3a804b3056b4f6edcc36e7ade (diff) |
changed 'float' to 't_float' in vbap
svn path=/trunk/externals/vbap/; revision=15765
-rw-r--r-- | define_loudspeakers.c | 60 | ||||
-rw-r--r-- | define_loudspeakers.h | 12 | ||||
-rw-r--r-- | rvbap.c | 161 | ||||
-rw-r--r-- | vbap.c | 88 | ||||
-rw-r--r-- | vbap.h | 26 |
5 files changed, 174 insertions, 173 deletions
diff --git a/define_loudspeakers.c b/define_loudspeakers.c index b2fd351..ef0baa4 100644 --- a/define_loudspeakers.c +++ b/define_loudspeakers.c @@ -167,11 +167,11 @@ static void def_ls_read_directions(t_def_ls *x, t_symbol *s, int ac, Atom *av) static void ls_angles_to_cart(t_ls *ls) // convert angular direction to cartesian { - float azi = ls->azi; - float ele = ls->ele; - ls->x = cos((float) azi * atorad) * cos((float) ele * atorad); - ls->y = sin((float) azi * atorad) * cos((float) ele * atorad); - ls->z = sin((float) ele * atorad); + t_float azi = ls->azi; + t_float ele = ls->ele; + ls->x = cos((t_float) azi * atorad) * cos((t_float) ele * atorad); + ls->y = sin((t_float) azi * atorad) * cos((t_float) ele * atorad); + ls->z = sin((t_float) ele * atorad); } /* create new instance of object... MUST send it an int even if you do nothing with this int!! */ @@ -236,7 +236,7 @@ static void initContent_ls_directions(t_def_ls *x,int ac,Atom*av) pointer++; - float ele = 0; // in 2d elevation is zero + t_float ele = 0; // in 2d elevation is zero if(x->x_def_ls_dimension == 3) { // 3-D /* if(av[pointer].a_type == A_LONG) ele = (float) av[pointer].a_w.w_long; @@ -279,10 +279,10 @@ static void choose_ls_triplets(t_def_ls *x) int connections[MAX_LS_AMOUNT][MAX_LS_AMOUNT]; //float angles[MAX_LS_AMOUNT]; //int sorted_angles[MAX_LS_AMOUNT]; - float distance_table[((MAX_LS_AMOUNT * (MAX_LS_AMOUNT - 1)) / 2)]; + t_float distance_table[((MAX_LS_AMOUNT * (MAX_LS_AMOUNT - 1)) / 2)]; int distance_table_i[((MAX_LS_AMOUNT * (MAX_LS_AMOUNT - 1)) / 2)]; int distance_table_j[((MAX_LS_AMOUNT * (MAX_LS_AMOUNT - 1)) / 2)]; - float distance; + t_float distance; t_ls_set *trip_ptr, *prev, *tmp_ptr; int ls_amount = x->x_def_ls_amount; t_ls *lss = x->x_ls; @@ -404,11 +404,11 @@ static void choose_ls_triplets(t_def_ls *x) int any_ls_inside_triplet(int a, int b, int c,t_ls lss[MAX_LS_AMOUNT],int ls_amount) /* returns 1 if there is loudspeaker(s) inside given ls triplet */ { - float invdet; + t_float invdet; t_ls *lp1, *lp2, *lp3; - float invmx[9]; + t_float invmx[9]; int i,j; - float tmp; + t_float tmp; int any_ls_inside, this_inside; lp1 = &(lss[a]); @@ -476,10 +476,10 @@ static void add_ldsp_triplet(int i, int j, int k, t_def_ls *x) -float vec_angle(t_ls v1, t_ls v2) +t_float vec_angle(t_ls v1, t_ls v2) // angle between two loudspeakers { - float inner= ((v1.x*v2.x + v1.y*v2.y + v1.z*v2.z)/ + t_float inner= ((v1.x*v2.x + v1.y*v2.y + v1.z*v2.z)/ (vec_length(v1) * vec_length(v2))); if(inner > 1.0) inner= 1.0; @@ -488,26 +488,26 @@ float vec_angle(t_ls v1, t_ls v2) return fabs( acos( inner)); } -float vec_length(t_ls v1) +t_float vec_length(t_ls v1) // length of a vector { return (sqrt(v1.x*v1.x + v1.y*v1.y + v1.z*v1.z)); } -float vec_prod(t_ls v1, t_ls v2) +t_float vec_prod(t_ls v1, t_ls v2) // vector dot product { return (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z); } -float vol_p_side_lgth(int i, int j,int k, t_ls lss[MAX_LS_AMOUNT] ) +t_float vol_p_side_lgth(int i, int j,int k, t_ls lss[MAX_LS_AMOUNT] ) { /* calculate volume of the parallelepiped defined by the loudspeaker direction vectors and divide it with total length of the triangle sides. This is used when removing too narrow triangles. */ - float volper, lgth; + t_float volper, lgth; t_ls xprod; ls_cross_prod(lss[i], lss[j], &xprod); volper = fabsf(vec_prod(xprod, lss[k])); @@ -524,7 +524,7 @@ static void ls_cross_prod(t_ls v1,t_ls v2, t_ls *res) // vector cross product { - float length; + t_float length; res->x = (v1.y * v2.z ) - (v1.z * v2.y); res->y = (v1.z * v2.x ) - (v1.x * v2.z); res->z = (v1.x * v2.y ) - (v1.y * v2.x); @@ -544,8 +544,8 @@ static int lines_intersect(int i,int j,int k,int l,t_ls lss[MAX_LS_AMOUNT]) t_ls v2; t_ls v3, neg_v3; //float angle; - float dist_ij,dist_kl,dist_iv3,dist_jv3,dist_inv3,dist_jnv3; - float dist_kv3,dist_lv3,dist_knv3,dist_lnv3; + t_float dist_ij,dist_kl,dist_iv3,dist_jv3,dist_inv3,dist_jnv3; + t_float dist_kv3,dist_lv3,dist_knv3,dist_lnv3; ls_cross_prod(lss[i],lss[j],&v1); ls_cross_prod(lss[k],lss[l],&v2); @@ -587,9 +587,9 @@ static int lines_intersect(int i,int j,int k,int l,t_ls lss[MAX_LS_AMOUNT]) static void calculate_3x3_matrixes(t_def_ls *x) /* Calculates the inverse matrices for 3D */ { - float invdet; + t_float invdet; t_ls *lp1, *lp2, *lp3; - float *invmx; + t_float *invmx; //float *ptr; struct t_ls_set *tr_ptr = x->x_ls_set; int triplet_amount = 0, /*ftable_size,*/i,pointer,list_length=0; @@ -674,8 +674,8 @@ static void choose_ls_tuplets(t_def_ls *x) int sorted_lss[MAX_LS_AMOUNT]; int exist[MAX_LS_AMOUNT]; int amount=0; - float inv_mat[MAX_LS_AMOUNT][4]; // In 2-D ls amount == max amount of LS pairs - float mat[MAX_LS_AMOUNT][4]; + t_float inv_mat[MAX_LS_AMOUNT][4]; // In 2-D ls amount == max amount of LS pairs + t_float mat[MAX_LS_AMOUNT][4]; //float *ptr; //float *ls_table; t_ls *lss = x->x_ls; @@ -762,7 +762,7 @@ void sort_2D_lss(t_ls lss[MAX_LS_AMOUNT], int sorted_lss[MAX_LS_AMOUNT], int ls_amount) // sort loudspeakers according to azimuth angle { - float tmp, tmp_azi; + t_float tmp, tmp_azi; // float rad2ang = 360.0f / ( 2.0f * M_PI ); //float x,y; @@ -793,22 +793,22 @@ for (i=0;i<ls_amount;i++) } sorted_lss[i]=index; tmp_azi = (lss[index].azi); - lss[index].azi = (tmp_azi + (float) 4000.0); + lss[index].azi = (tmp_azi + (t_float) 4000.0); } for (i=0;i<ls_amount;i++) { tmp_azi = (lss[i].azi); - lss[i].azi = (tmp_azi - (float) 4000.0); + lss[i].azi = (tmp_azi - (t_float) 4000.0); } } -static int calc_2D_inv_tmatrix(float azi1,float azi2, float inv_mat[4],float mat[4]) +static int calc_2D_inv_tmatrix(t_float azi1,t_float azi2, t_float inv_mat[4],t_float mat[4]) // calculate inverse 2x2 matrix { - float x1,x2,x3,x4; /* x1 x3 */ + t_float x1,x2,x3,x4; /* x1 x3 */ //float y1,y2,y3,y4; /* x2 x4 */ - float det; + t_float det; mat[0]=x1 = cos(azi1 / rad2ang); mat[1]=x2 = sin(azi1 / rad2ang); diff --git a/define_loudspeakers.h b/define_loudspeakers.h index de5d0a9..afaf036 100644 --- a/define_loudspeakers.h +++ b/define_loudspeakers.h @@ -20,16 +20,16 @@ static void ls_angles_to_cart(t_ls *ls); static void choose_ls_triplets(t_def_ls *x); static int any_ls_inside_triplet(int a, int b, int c,t_ls lss[MAX_LS_AMOUNT],int ls_amount); static void add_ldsp_triplet(int i, int j, int k, t_def_ls *x); -static float vec_angle(t_ls v1, t_ls v2); -static float vec_length(t_ls v1); -static float vec_prod(t_ls v1, t_ls v2); -static float vec_prod(t_ls v1, t_ls v2); -static float vol_p_side_lgth(int i, int j,int k, t_ls lss[MAX_LS_AMOUNT] ); +static t_float vec_angle(t_ls v1, t_ls v2); +static t_float vec_length(t_ls v1); +static t_float vec_prod(t_ls v1, t_ls v2); +static t_float vec_prod(t_ls v1, t_ls v2); +static t_float vol_p_side_lgth(int i, int j,int k, t_ls lss[MAX_LS_AMOUNT] ); static void ls_cross_prod(t_ls v1,t_ls v2, t_ls *res); static int lines_intersect(int i,int j,int k,int l,t_ls lss[MAX_LS_AMOUNT]); static void calculate_3x3_matrixes(t_def_ls *x); static void choose_ls_tuplets(t_def_ls *x); -static int calc_2D_inv_tmatrix(float azi1,float azi2, float inv_mat[4],float mat[4]); +static int calc_2D_inv_tmatrix(t_float azi1,t_float azi2, t_float inv_mat[4],t_float mat[4]); static void sort_2D_lss(t_ls lss[MAX_LS_AMOUNT], int sorted_lss[MAX_LS_AMOUNT], int ls_amount); static void initContent_ls_directions(t_def_ls *x,int ac,Atom*av); @@ -14,6 +14,7 @@ See copyright in file with name LICENSE.txt */ #ifdef MAXMSP #include "ext.h" /* you must include this - it contains the external object's link to max */ +#define t_float float #endif #ifdef PD @@ -33,22 +34,22 @@ typedef struct vbap /* This defines the object as an entity made up t_object x_ob; long x_azi; // panning direction azimuth long x_ele; // panning direction elevation - float x_dist; // sound source distance (1.0-infinity) + t_float x_dist; // sound source distance (1.0-infinity) void *x_outlet0; /* outlet creation - inlets are automatic */ void *x_outlet1; void *x_outlet2; void *x_outlet3; void *x_outlet4; - float x_set_inv_matx[MAX_LS_SETS][9]; // inverse matrice for each loudspeaker set - float x_set_matx[MAX_LS_SETS][9]; // matrice for each loudspeaker set + t_float x_set_inv_matx[MAX_LS_SETS][9];// inverse matrice for each loudspeaker set + t_float x_set_matx[MAX_LS_SETS][9]; // matrice for each loudspeaker set long x_lsset[MAX_LS_SETS][3]; // channel numbers of loudspeakers in each LS set long x_lsset_available; // have loudspeaker sets been defined with define_loudspeakers long x_lsset_amount; // amount of loudspeaker sets long x_ls_amount; // amount of loudspeakers long x_dimension; // 2 or 3 long x_spread; // speading amount of virtual source (0-100) - float x_spread_base[3]; // used to create uniform spreading - float x_reverb_gs[MAX_LS_SETS]; // correction value for each loudspeaker set to get equal volume + t_float x_spread_base[3]; // used to create uniform spreading + t_float x_reverb_gs[MAX_LS_SETS]; // correction value for each loudspeaker set to get equal volume } t_rvbap; #endif @@ -65,23 +66,23 @@ typedef struct vbap /* This defines the object as an entity made up void *x_outlet2; void *x_outlet3; void *x_outlet4; - float x_set_inv_matx[MAX_LS_SETS][9]; // inverse matrice for each loudspeaker set - t_float x_set_matx[MAX_LS_SETS][9]; // matrice for each loudspeaker set + t_float x_set_inv_matx[MAX_LS_SETS][9];// inverse matrice for each loudspeaker set + t_float x_set_matx[MAX_LS_SETS][9]; // matrice for each loudspeaker set long x_lsset[MAX_LS_SETS][3]; // channel numbers of loudspeakers in each LS set long x_lsset_available; // have loudspeaker sets been defined with define_loudspeakers long x_lsset_amount; // amount of loudspeaker sets long x_ls_amount; // amount of loudspeakers long x_dimension; // 2 or 3 - t_float x_spread; // speading amount of virtual source (0-100) - float x_spread_base[3]; // used to create uniform spreading - float x_reverb_gs[MAX_LS_SETS]; // correction value for each loudspeaker set to get equal volume + t_float x_spread; // speading amount of virtual source (0-100) + t_float x_spread_base[3]; // used to create uniform spreading + t_float x_reverb_gs[MAX_LS_SETS]; // correction value for each loudspeaker set to get equal volume } t_rvbap; #endif // Globals -static void new_spread_dir(t_rvbap *x, float spreaddir[3], float vscartdir[3], float spread_base[3]); -static void new_spread_base(t_rvbap *x, float spreaddir[3], float vscartdir[3]); +static void new_spread_dir(t_rvbap *x, t_float spreaddir[3], t_float vscartdir[3], t_float spread_base[3]); +static void new_spread_base(t_rvbap *x, t_float spreaddir[3], t_float vscartdir[3]); #ifdef MAXMSP static void *rvbap_class; static void rvbap_assist(t_rvbap *x, void *b, long m, long a, char *s); @@ -97,17 +98,17 @@ static void rvbap_ft4(t_rvbap *x, double n); #ifdef PD static t_class *rvbap_class; #endif -static void cross_prod(float v1[3], float v2[3], - float v3[3]); -static void additive_vbap(float *final_gs, float cartdir[3], t_rvbap *x); +static void cross_prod(t_float v1[3], t_float v2[3], + t_float v3[3]); +static void additive_vbap(t_float *final_gs, t_float cartdir[3], t_rvbap *x); static void rvbap_bang(t_rvbap *x); static void rvbap_matrix(t_rvbap *x, t_symbol *s, int ac, t_atom *av); -static void spread_it(t_rvbap *x, float *final_gs); +static void spread_it(t_rvbap *x, t_float *final_gs); static void *rvbap_new(t_symbol *s, int ac, t_atom *av); // using A_GIMME - typed message list -static void vbap(float g[3], long ls[3], t_rvbap *x); -static void angle_to_cart(long azi, long ele, float res[3]); -static void cart_to_angle(float cvec[3], float avec[3]); -static void equal_reverb(t_rvbap *x, float *final_gs); +static void vbap(t_float g[3], long ls[3], t_rvbap *x); +static void angle_to_cart(long azi, long ele, t_float res[3]); +static void cart_to_angle(t_float cvec[3], t_float avec[3]); +static void equal_reverb(t_rvbap *x, t_float *final_gs); /* above are the prototypes for the methods/procedures/functions you will use */ @@ -137,7 +138,7 @@ int main(void) addftx((method)rvbap_ft3, 3); addftx((method)rvbap_ft4, 4); addmess((method)rvbap_matrix, "loudspeaker-matrices", A_GIMME, 0); - post("rvbap v1.1, © 2003-2007 by Olaf Matthes, based on vbap by Ville Pulkki"); + post("rvbap v1.1, © 2003-2007 by Olaf Matthes, based on vbap by Ville Pulkki"); return 0; } @@ -159,7 +160,7 @@ static void rvbap_assist(t_rvbap *x, void *b, long m, long a, char *s) sprintf(s, "(int) spreading"); break; case 4: - sprintf(s, "(float) distance"); + sprintf(s, "(t_float) distance"); break; } break; @@ -178,7 +179,7 @@ static void rvbap_assist(t_rvbap *x, void *b, long m, long a, char *s) sprintf(s, "(int) actual spreading"); break; case 4: - sprintf(s, "(float) actual distance"); + sprintf(s, "(t_float) actual distance"); break; } break; @@ -187,24 +188,24 @@ static void rvbap_assist(t_rvbap *x, void *b, long m, long a, char *s) #endif /* end MAXMSP */ -static void angle_to_cart(long azi, long ele, float res[3]) +static void angle_to_cart(long azi, long ele, t_float res[3]) /* converts angular coordinates to cartesian */ { - float atorad = (2.0 * 3.1415927 / 360.0) ; - res[0] = cos((float) azi * atorad) * cos((float) ele * atorad); - res[1] = sin((float) azi * atorad) * cos((float) ele * atorad); - res[2] = sin((float) ele * atorad); + t_float atorad = (2.0 * 3.141592653589793 / 360.0) ; + res[0] = cos((t_float) azi * atorad) * cos((t_float) ele * atorad); + res[1] = sin((t_float) azi * atorad) * cos((t_float) ele * atorad); + res[2] = sin((t_float) ele * atorad); } -static void cart_to_angle(float cvec[3], float avec[3]) +static void cart_to_angle(t_float cvec[3], t_float avec[3]) // converts cartesian coordinates to angular { - float tmp, tmp2, tmp3, tmp4; - float atorad = (float)(2.0 * 3.1415927 / 360.0) ; - float pi = (float)3.1415927; - float power; - float dist, atan_y_per_x, atan_x_pl_y_per_z; - float azi, ele; + t_float tmp, tmp2, tmp3, tmp4; + t_float atorad = (t_float)(2.0 * 3.141592653589793 / 360.0) ; + t_float pi = (t_float)3.141592653589793; + t_float power; + t_float dist, atan_y_per_x, atan_x_pl_y_per_z; + t_float azi, ele; if(cvec[0]==0.0) atan_y_per_x = pi / 2; @@ -224,24 +225,24 @@ static void cart_to_angle(float cvec[3], float avec[3]) else atan_x_pl_y_per_z = pi/2.0; ele = atan_x_pl_y_per_z / atorad; - dist = sqrtf(cvec[0] * cvec[0] +cvec[1] * cvec[1] +cvec[2]*cvec[2]); + dist = sqrt(cvec[0] * cvec[0] +cvec[1] * cvec[1] +cvec[2]*cvec[2]); avec[0]=azi; avec[1]=ele; avec[2]=dist; } -static void vbap(float g[3], long ls[3], t_rvbap *x) +static void vbap(t_float g[3], long ls[3], t_rvbap *x) { /* calculates gain factors using loudspeaker setup and given direction */ - float power; + t_float power; int i,j,k, gains_modified; - float small_g; - float big_sm_g, gtmp[3]; + t_float small_g; + t_float big_sm_g, gtmp[3]; long winner_set=0; - float cartdir[3]; - float new_cartdir[3]; - float new_angle_dir[3]; + t_float cartdir[3]; + t_float new_cartdir[3]; + t_float new_angle_dir[3]; long dim = x->x_dimension; long neg_g_am, best_neg_g_am; @@ -334,11 +335,11 @@ static void vbap(float g[3], long ls[3], t_rvbap *x) } -static void cross_prod(float v1[3], float v2[3], - float v3[3]) +static void cross_prod(t_float v1[3], t_float v2[3], + t_float v3[3]) // vector cross product { - float length; + t_float length; v3[0] = (v1[1] * v2[2] ) - (v1[2] * v2[1]); v3[1] = (v1[2] * v2[0] ) - (v1[0] * v2[2]); v3[2] = (v1[0] * v2[1] ) - (v1[1] * v2[0]); @@ -349,20 +350,20 @@ static void cross_prod(float v1[3], float v2[3], v3[2] /= length; } -static void additive_vbap(float *final_gs, float cartdir[3], t_rvbap *x) +static void additive_vbap(t_float *final_gs, t_float cartdir[3], t_rvbap *x) // calculates gains to be added to previous gains, used in // multiple direction panning (source spreading) { - float power; + t_float power; int i,j,k, gains_modified; - float small_g; - float big_sm_g, gtmp[3]; + t_float small_g; + t_float big_sm_g, gtmp[3]; long winner_set; - float new_cartdir[3]; - float new_angle_dir[3]; + t_float new_cartdir[3]; + t_float new_angle_dir[3]; long dim = x->x_dimension; long neg_g_am, best_neg_g_am; - float g[3]; + t_float g[3]; long ls[3] = { 0, 0, 0 }; big_sm_g = -100000.0; @@ -423,13 +424,13 @@ static void additive_vbap(float *final_gs, float cartdir[3], t_rvbap *x) } -static void new_spread_dir(t_rvbap *x, float spreaddir[3], float vscartdir[3], float spread_base[3]) +static void new_spread_dir(t_rvbap *x, t_float spreaddir[3], t_float vscartdir[3], t_float spread_base[3]) // subroutine for spreading { - float beta,m_gamma; - float a,b; - float pi = 3.1415927; - float power; + t_float beta,m_gamma; + t_float a,b; + t_float pi = 3.141592653589793; + t_float power; m_gamma = acos(vscartdir[0] * spread_base[0] + vscartdir[1] * spread_base[1] + @@ -454,12 +455,12 @@ static void new_spread_dir(t_rvbap *x, float spreaddir[3], float vscartdir[3], f spreaddir[2] /= power; } -static void new_spread_base(t_rvbap *x, float spreaddir[3], float vscartdir[3]) +static void new_spread_base(t_rvbap *x, t_float spreaddir[3], t_float vscartdir[3]) // subroutine for spreading { - float d; - float pi = 3.1415927; - float power; + t_float d; + t_float pi = 3.141592653589793; + t_float power; d = cos(x->x_spread/180*pi); x->x_spread_base[0] = spreaddir[0] - d * vscartdir[0]; @@ -472,18 +473,18 @@ static void new_spread_base(t_rvbap *x, float spreaddir[3], float vscartdir[3]) x->x_spread_base[2] /= power; } -static void spread_it(t_rvbap *x, float *final_gs) +static void spread_it(t_rvbap *x, t_float *final_gs) // apply the sound signal to multiple panning directions // that causes some spreading. // See theory in paper V. Pulkki "Uniform spreading of amplitude panned // virtual sources" in WASPAA 99 { - float vscartdir[3]; - float spreaddir[16][3]; - float spreadbase[16][3]; + t_float vscartdir[3]; + t_float spreaddir[16][3]; + t_float spreadbase[16][3]; long i, spreaddirnum; - float power; + t_float power; if(x->x_dimension == 3){ spreaddirnum=16; angle_to_cart(x->x_azi,x->x_ele,vscartdir); @@ -547,18 +548,18 @@ static void spread_it(t_rvbap *x, float *final_gs) } -static void equal_reverb(t_rvbap *x, float *final_gs) +static void equal_reverb(t_rvbap *x, t_float *final_gs) // calculate constant reverb gains for equally distributed // reverb levels // this is achieved by calculating gains for a sound source // that is everywhere, i.e. present in all directions { - float vscartdir[3]; - float spreaddir[16][3]; - float spreadbase[16][3]; + t_float vscartdir[3]; + t_float spreaddir[16][3]; + t_float spreadbase[16][3]; long i, spreaddirnum; - float power; + t_float power; if(x->x_dimension == 3){ spreaddirnum=5; @@ -606,11 +607,11 @@ static void rvbap_bang(t_rvbap *x) // top level, vbap gains are calculated and outputted { t_atom at[MAX_LS_AMOUNT]; - float g[3]; + t_float g[3]; long ls[3]; long i; - float *final_gs, overdist, oversqrtdist; - final_gs = (float *) getbytes(x->x_ls_amount * sizeof(float)); + t_float *final_gs, overdist, oversqrtdist; + final_gs = (t_float *) getbytes(x->x_ls_amount * sizeof(t_float)); if(x->x_lsset_available ==1){ vbap(g, ls, x); for(i=0;i<x->x_ls_amount;i++) @@ -666,7 +667,7 @@ static void rvbap_bang(t_rvbap *x) } else post("rvbap: Configure loudspeakers first!"); - freebytes(final_gs, x->x_ls_amount * sizeof(float)); // bug fix added 9/00 + freebytes(final_gs, x->x_ls_amount * sizeof(t_float)); // bug fix added 9/00 } /*--------------------------------------------------------------------------*/ @@ -682,7 +683,7 @@ static void rvbap_matrix(t_rvbap *x, t_symbol *s, int ac, t_atom *av) long i; long deb=0; long azi = x->x_azi, ele = x->x_ele; // store original values - float g[3]; + t_float g[3]; long ls[3]; if(ac>0) @@ -824,7 +825,7 @@ static void rvbap_in4(t_rvbap *x, long n) /* x = the instance of // distance { if (n<1) n = 1; - x->x_dist = (float)n; /* store n in a global variable */ + x->x_dist = (t_float)n; /* store n in a global variable */ } @@ -858,7 +859,7 @@ static void rvbap_ft4(t_rvbap *x, double n) /* x = the instance of // distance { if (n<1.0) n = 1.0; - x->x_dist = (float)n; /* store n in a global variable */ + x->x_dist = (t_float)n; /* store n in a global variable */ } @@ -871,7 +872,7 @@ static void *rvbap_new(t_symbol *s, int ac, t_atom *av) #ifdef MAXMSP x = (t_rvbap *)newobject(rvbap_class); - floatin(x,4); /* takes the distance */ + t_floatin(x,4); /* takes the distance */ intin(x,3); intin(x,2); /* create a second (int) inlet... remember right-to-left ordering in Max */ intin(x,1); /* create a second (int) inlet... remember right-to-left ordering in Max */ @@ -14,25 +14,25 @@ See copyright in file with name LICENSE.txt */ #include "s_stuff.h" // Function prototypes -static void new_spread_dir(t_vbap *x, float spreaddir[3], float vscartdir[3], float spread_base[3]); -static void new_spread_base(t_vbap *x, float spreaddir[3], float vscartdir[3]); +static void new_spread_dir(t_vbap *x, t_float spreaddir[3], t_float vscartdir[3], t_float spread_base[3]); +static void new_spread_base(t_vbap *x, t_float spreaddir[3], t_float vscartdir[3]); static void *vbap_class; -static void vect_cross_prod(float v1[3], float v2[3],float v3[3]); -static void additive_vbap(float *final_gs, float cartdir[3], t_vbap *x); +static void vect_cross_prod(t_float v1[3], t_float v2[3],t_float v3[3]); +static void additive_vbap(t_float *final_gs, t_float cartdir[3], t_vbap *x); static void vbap_bang(t_vbap *x); static void vbap_matrix(t_vbap *x, Symbol *s, int ac, Atom *av); #ifndef PD /* Max */ -/* these are for getting data from a cold inlet on Max/MSP, in Pd you use floatinlet_new() in new() */ +/* these are for getting data from a cold inlet on Max/MSP, in Pd you use t_floatinlet_new() in new() */ void vbap_ft1(t_vbap *x, double n); void vbap_ft2(t_vbap *x, double n); void vbap_in3(t_vbap *x, long n); void vbap_ft4(t_vbap *x, double g); #endif -static void spread_it(t_vbap *x, float *final_gs); -static void *vbap_new(float azi, float ele, float spread); -static void vbap(float g[3], long ls[3], t_vbap *x); -static void angle_to_cart(float azi, float ele, float res[3]); -static void cart_to_angle(float cvec[3], float avec[3]); +static void spread_it(t_vbap *x, t_float *final_gs); +static void *vbap_new(t_float azi, t_float ele, t_float spread); +static void vbap(t_float g[3], long ls[3], t_vbap *x); +static void angle_to_cart(t_float azi, t_float ele, t_float res[3]); +static void cart_to_angle(t_float cvec[3], t_float avec[3]); /***************************************************** INCLUDE ALL define_loudspeakers functions directly into VBAP @@ -180,7 +180,7 @@ static void *vbap_new(t_float azi, t_float ele, t_float spread) } -static void angle_to_cart(float azi, float ele, float res[3]) +static void angle_to_cart(t_float azi, t_float ele, t_float res[3]) // converts angular coordinates to cartesian { res[0] = cos(azi * atorad) * cos( ele * atorad); @@ -188,13 +188,13 @@ static void angle_to_cart(float azi, float ele, float res[3]) res[2] = sin( ele * atorad); } -static void cart_to_angle(float cvec[3], float avec[3]) +static void cart_to_angle(t_float cvec[3], t_float avec[3]) // converts cartesian coordinates to angular { //float tmp, tmp2, tmp3, tmp4; //float power; - float dist, atan_y_per_x, atan_x_pl_y_per_z; - float azi, ele; + t_float dist, atan_y_per_x, atan_x_pl_y_per_z; + t_float azi, ele; if(cvec[0]==0.0) atan_y_per_x = M_PI / 2; @@ -223,17 +223,17 @@ static void cart_to_angle(float cvec[3], float avec[3]) } -static void vbap(float g[3], long ls[3], t_vbap *x) +static void vbap(t_float g[3], long ls[3], t_vbap *x) { /* calculates gain factors using loudspeaker setup and given direction */ - float power; + t_float power; int i,j,k, gains_modified; - float small_g; - float big_sm_g, gtmp[3]; + t_float small_g; + t_float big_sm_g, gtmp[3]; long winner_set = 0; - float cartdir[3]; - float new_cartdir[3]; - float new_angle_dir[3]; + t_float cartdir[3]; + t_float new_cartdir[3]; + t_float new_angle_dir[3]; long dim = x->x_dimension; long neg_g_am, best_neg_g_am; @@ -339,11 +339,11 @@ static void vbap(float g[3], long ls[3], t_vbap *x) } -static void vect_cross_prod(float v1[3], float v2[3], - float v3[3]) +static void vect_cross_prod(t_float v1[3], t_float v2[3], + t_float v3[3]) // vector cross product { - float length; + t_float length; v3[0] = (v1[1] * v2[2] ) - (v1[2] * v2[1]); v3[1] = (v1[2] * v2[0] ) - (v1[0] * v2[2]); v3[2] = (v1[0] * v2[1] ) - (v1[1] * v2[0]); @@ -354,20 +354,20 @@ static void vect_cross_prod(float v1[3], float v2[3], v3[2] /= length; } -static void additive_vbap(float *final_gs, float cartdir[3], t_vbap *x) +static void additive_vbap(t_float *final_gs, t_float cartdir[3], t_vbap *x) // calculates gains to be added to previous gains, used in // multiple direction panning (source spreading) { - float power; + t_float power; int i,j,k, gains_modified; - float small_g; - float big_sm_g, gtmp[3]; + t_float small_g; + t_float big_sm_g, gtmp[3]; long winner_set; //float new_cartdir[3]; //float new_angle_dir[3]; long dim = x->x_dimension; long neg_g_am, best_neg_g_am; - float g[3] = {0,0,0}; + t_float g[3] = {0,0,0}; long ls[3] = {0,0,0}; big_sm_g = -100000.0; @@ -421,12 +421,12 @@ static void additive_vbap(float *final_gs, float cartdir[3], t_vbap *x) } -static void new_spread_dir(t_vbap *x, float spreaddir[3], float vscartdir[3], float spread_base[3]) +static void new_spread_dir(t_vbap *x, t_float spreaddir[3], t_float vscartdir[3], t_float spread_base[3]) // subroutine for spreading { - float beta,gamma; - float a,b; - float power; + t_float beta,gamma; + t_float a,b; + t_float power; gamma = acos(vscartdir[0] * spread_base[0] + vscartdir[1] * spread_base[1] + @@ -451,11 +451,11 @@ static void new_spread_dir(t_vbap *x, float spreaddir[3], float vscartdir[3], fl spreaddir[2] /= power; } -static void new_spread_base(t_vbap *x, float spreaddir[3], float vscartdir[3]) +static void new_spread_base(t_vbap *x, t_float spreaddir[3], t_float vscartdir[3]) // subroutine for spreading { - float d; - float power; + t_float d; + t_float power; d = cos(x->x_spread/180*M_PI); x->x_spread_base[0] = spreaddir[0] - d * vscartdir[0]; @@ -468,18 +468,18 @@ static void new_spread_base(t_vbap *x, float spreaddir[3], float vscartdir[3]) x->x_spread_base[2] /= power; } -static void spread_it(t_vbap *x, float *final_gs) +static void spread_it(t_vbap *x, t_float *final_gs) // apply the sound signal to multiple panning directions // that causes some spreading. // See theory in paper V. Pulkki "Uniform spreading of amplitude panned // virtual sources" in WASPAA 99 { - float vscartdir[3]; - float spreaddir[16][3]; - float spreadbase[16][3]; + t_float vscartdir[3]; + t_float spreaddir[16][3]; + t_float spreadbase[16][3]; long i, spreaddirnum; - float power; + t_float power; if(x->x_dimension == 3){ spreaddirnum=16; angle_to_cart(x->x_azi,x->x_ele,vscartdir); @@ -547,10 +547,10 @@ static void vbap_bang(t_vbap *x) // top level, vbap gains are calculated and outputted { Atom at[MAX_LS_AMOUNT]; - float g[3]; + t_float g[3]; long ls[3]; long i; - float *final_gs = (float *) getbytes(x->x_ls_amount * sizeof(float)); + t_float *final_gs = (t_float *) getbytes(x->x_ls_amount * sizeof(t_float)); if(x->x_lsset_available ==1) { @@ -585,7 +585,7 @@ static void vbap_bang(t_vbap *x) else error("vbap: Configure loudspeakers first!"); - freebytes(final_gs, x->x_ls_amount * sizeof(float)); // bug fix added 9/00 + freebytes(final_gs, x->x_ls_amount * sizeof(t_float)); // bug fix added 9/00 } /*--------------------------------------------------------------------------*/ @@ -17,8 +17,8 @@ #define VBAP_VERSION "vbap - v1.0.3.2 - 20 Nov 2010 - (c) Ville Pulkki 1999-2006 (Pd port by HCS)" #define DFLS_VERSION "define_loudspeakers - v1.0.3.2 - 20 Nov 2010 - (c) Ville Pulkki 1999-2006" -static float rad2ang = 360.0 / ( 2.0f * M_PI ); -static float atorad = (2.0f * M_PI) / 360.0f ; +static t_float rad2ang = 360.0 / ( 2.0f * M_PI ); +static t_float atorad = (2.0f * M_PI) / 360.0f ; #ifdef VBAP_OBJECT // We are inside vbap object, so sending matrix from define_loudspeakers is a simple call to the vbap receiver... @@ -35,11 +35,11 @@ static float atorad = (2.0f * M_PI) / 360.0f ; /* A struct for a loudspeaker instance */ typedef struct { // distance value is 1.0 == unit vectors - float x; // cartesian coordinates - float y; - float z; - float azi; // polar coordinates - float ele; + t_float x; // cartesian coordinates + t_float y; + t_float z; + t_float azi; // polar coordinates + t_float ele; int channel_nbr; // which speaker channel number } t_ls; @@ -47,7 +47,7 @@ typedef struct typedef struct t_ls_set { int ls_nos[3]; // channel numbers - float inv_mx[9]; // inverse 3x3 or 2x2 matrix + t_float inv_mx[9]; // inverse 3x3 or 2x2 matrix struct t_ls_set *next; // next set (triplet or pair) } t_ls_set; @@ -55,15 +55,15 @@ typedef struct t_ls_set typedef struct vbap /* This defines the object as an entity made up of other things */ { t_object x_obj; - float x_azi; // panning direction azimuth - float x_ele; // panning direction elevation + t_float x_azi; // panning direction azimuth + t_float x_ele; // panning direction elevation void *x_outlet0; /* outlet creation - inlets are automatic */ void *x_outlet1; void *x_outlet2; void *x_outlet3; void *x_outlet4; - float x_set_inv_matx[MAX_LS_SETS][9]; // inverse matrice for each loudspeaker set - float x_set_matx[MAX_LS_SETS][9]; // matrice for each loudspeaker set + t_float x_set_inv_matx[MAX_LS_SETS][9]; // inverse matrice for each loudspeaker set + t_float x_set_matx[MAX_LS_SETS][9]; // matrice for each loudspeaker set long x_lsset[MAX_LS_SETS][3]; // channel numbers of loudspeakers in each LS set long x_lsset_available; // have loudspeaker sets been defined with define_loudspeakers long x_lsset_amount; // amount of loudspeaker sets @@ -75,7 +75,7 @@ typedef struct t_ls_set long x_spread; // speading amount of virtual source (0-100) double x_gain; // general gain control (0-2) # endif /* PD */ - float x_spread_base[3]; // used to create uniform spreading + t_float x_spread_base[3]; // used to create uniform spreading // define_loudspeaker data long x_ls_read; // 1 if loudspeaker directions have been read |