Пример #1
0
void define_loudspeakers(LS_DATA *ls_data, int ls_set_dim, int ls_num, int ls_dirs[MAX_FIELD_AM])
     /* Inits the loudspeaker data. Calls choose_ls_tuplets or _triplets
	according to current dimension. The inversion matrices are 
     stored in transposed form to ease calculation at run time.*/
{
  char *s;
  int dim;
  float tmp;
  struct ls_triplet_chain *ls_triplets = NULL;
  ls lss[MAX_LS_AMOUNT];
  ang_vec a_vector;
  cart_vec c_vector;
  int i=0,j;
  float azi, ele;

  dim=ls_set_dim;
  if (!((dim==2) || (dim == 3))){
    fprintf(stderr,"Error in loudspeaker dimension.\n");
    exit (-1);
  }

  j=0;
  for(i=0;i<ls_num;i++) {
    azi= (float) ls_dirs[j++];
    if(dim == 3) 
      ele = (float) ls_dirs[j++];
    else
      ele = 0.0;
    a_vector.azi = azi;
    a_vector.ele = ele;
    angle_to_cart2(&a_vector,&c_vector);
    lss[i].coords.x = c_vector.x;
    lss[i].coords.y = c_vector.y;
    lss[i].coords.z = c_vector.z;
    lss[i].angles.azi = a_vector.azi;
    lss[i].angles.ele = a_vector.ele;
    lss[i].angles.length = 1.0;
  }


  if(ls_num < dim) {
    fprintf(stderr,"Too few loudspeakers %d\n",ls_num);
    exit (-1);
  }

  if(dim == 3){
    choose_ls_triplets(lss, &ls_triplets,ls_num);
    calculate_3x3_matrixes(ls_triplets,lss,ls_num,ls_data);
  } else if (dim ==2) {
    choose_ls_tuplets(lss, &ls_triplets,ls_num,ls_data); 
  }
}
Пример #2
0
static void def_ls_bang(t_def_ls *x)						/* x = reference to this instance of the object */ 
{   // calculate and print out chosen loudspeaker sets and corresponding  matrices
	
	if(x->x_ls_read == 1)
	{
		if(x->x_def_ls_amount < x->x_def_ls_dimension)
		{
			error("define-loudspeakers: Too few loudspeakers!");
			return;
		} 
		else 
		{
			if(x->x_def_ls_dimension == 3)
			{
				if(x->x_triplets_specified==0) choose_ls_triplets(x);
				calculate_3x3_matrixes(x);
			} 
			else if(x->x_def_ls_dimension == 2)
			{
		  	choose_ls_tuplets(x);
			}
		  else 
			{
		  	error("define-loudspeakers: Error in loudspeaker direction data");
		  	error("dimension azimuth1 [elevation1] azimuth2 [elevation2]...");
		  	error("dimension == 2 for horizontal ls arrays");
		  	error("dimension == 3 for 3-D ls arrays (speakers also upward and/or downward ");
		  }
		}
	} 
	else
	{
		error("define-loudspeakers: Error in loudspeaker direction data");
		error("dimension azimuth1 [elevation1] azimuth2 [elevation2]...");
		error("dimension == 2 for horizontal ls arrays");
		error("dimension == 3 for 3-D ls arrays (speakers also upward and/or downward ");
	}
}