Example #1
0
static void *tab_lt_new(t_symbol *s, int argc, t_atom *argv)
{
    t_tab_lt *x = (t_tab_lt *)pd_new(tab_lt_class);
    t_symbol  *src1, *src2, *dst;

    if((argc >= 3) &&
            IS_A_SYMBOL(argv,0) &&
            IS_A_SYMBOL(argv,1) &&
            IS_A_SYMBOL(argv,2))
    {
        src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
        src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
        dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
    }
    else if((argc >= 2) &&
            IS_A_SYMBOL(argv,0) &&
            IS_A_SYMBOL(argv,1))
    {
        src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
        dst = src1;
        src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
    }
    else
    {
        post("tab_lt-ERROR: need 3 symbols arguments:");
        post("  source1_array_name + source2_array_name + destination_array_name");
        return(0);
    }

    x->x_sym_scr1 = src1;
    x->x_sym_scr2 = src2;
    x->x_sym_dst = dst;
    outlet_new(&x->x_obj, &s_bang);
    return(x);
}
Example #2
0
static void *iem_event_new(t_symbol *s, int argc, t_atom *argv)
{
  t_iem_event *x = (t_iem_event *)pd_new(iem_event_class);
  t_int w=32, h=32;
  
  x->x_gui.x_snd = gensym("empty");
  x->x_gui.x_rcv = gensym("empty");
  x->x_gui.x_lab = gensym("empty");
  x->x_gui.x_fsf.x_font_style = 0;
  if((argc >= 6)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
    &&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,3)
    &&(IS_A_SYMBOL(argv,4)||IS_A_FLOAT(argv,4))
    &&(IS_A_SYMBOL(argv,5)||IS_A_FLOAT(argv,5)))
  {
    w = (int)atom_getintarg(0, argc, argv);
    h = (int)atom_getintarg(1, argc, argv);
    iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(2, argc, argv));
    iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(3, argc, argv));
    iemgui_new_getnames(&x->x_gui, 4, argv);
  }
  else if((argc >= 2)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1))
  {
    w = (int)atom_getintarg(0, argc, argv);
    h = (int)atom_getintarg(1, argc, argv);
  }
  x->x_gui.x_draw = (t_iemfunptr)iem_event_draw;
  x->x_gui.x_fsf.x_snd_able = 1;
  x->x_gui.x_fsf.x_rcv_able = 1;
  x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
  if(!strcmp(x->x_gui.x_snd->s_name, "empty"))
    x->x_gui.x_fsf.x_snd_able = 0;
  if(!strcmp(x->x_gui.x_rcv->s_name, "empty"))
    x->x_gui.x_fsf.x_rcv_able = 0;
  if(x->x_gui.x_fsf.x_rcv_able)
    pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
  if(w < 4)
    w = 4;
  x->x_gui.x_w = w;
  if(h < 4)
    h = 4;
  x->x_gui.x_h = h;
  iemgui_verify_snd_ne_rcv(&x->x_gui);
  outlet_new(&x->x_gui.x_obj, &s_list);
  x->x_mouse_shft_alt = gensym("mouse_shft_alt");
  x->x_dragg_x_y = gensym("dragg_x_y");
  x->x_key = gensym("key");
  x->x_move_x_y = gensym("move_x_y");
  x->x_x = 0;
  x->x_y = 0;
  x->x_doit = 0;
  return (x);
}
static void iem_send_kernel_set_name(t_iem_send_kernel *x, t_symbol *s, int argc, t_atom *argv)
{
  if((argc > 0)&&((IS_A_SYMBOL(argv,0))||(IS_A_FLOAT(argv,0))))
  {
    if(IS_A_SYMBOL(argv,0))
      x->x_sym = atom_getsymbol(argv);
    else if(IS_A_FLOAT(argv,0))
    {
      char str[100];
      
      sprintf(str, "%g", atom_getfloat(argv));
      x->x_sym = gensym(str);
    }
  }
}
Example #4
0
void *listUnfold_new(t_symbol *s, int argc, t_atom *argv)
{
  t_listUnfold *x = (t_listUnfold *)pd_new(listUnfold_class);
  
  x->iterating = 0;
 
  x->mode = 0;
 
  if (argc && IS_A_SYMBOL(argv,0) ) {
	  t_symbol* type = atom_getsymbol(argv);
	  if (strcmp(type->s_name,"wait")==0 || strcmp(type->s_name,"manually")==0) {
		  x->mode = 1;
	}	
  }
 
  // Initialize memory
  x->memSize = 10;
  x->ac = 0;
  x->av = getbytes(x->memSize * sizeof(*(x->av)));

  x->outlet1 = outlet_new(&x->x_obj, &s_list);
  x->outlet2 = outlet_new(&x->x_obj, &s_float);


  return (void *)x;
}
Example #5
0
void *open_help_new(t_symbol *s, int argc, t_atom *argv)
{
  t_open_help *x = (t_open_help *)pd_new(open_help_class);
    
  x->dir = tof_get_dir(tof_get_canvas());
	
	
	
	x->help=NULL;
	if ( argc && IS_A_SYMBOL(argv,0)  ) {
		x->help = atom_getsymbol(argv);
		
	}
	
	
	
  //strcpy(tof_buf_temp_a,x->dir->s_name);
  //strcat(tof_buf_temp_a,"/");
  //x->dir = gensym(tof_buf_temp_a);
  
  //x->canvas = tof_get_canvas();
  
 
  

  return (void *)x;
}
static void *iem_send_kernel_new(void)
{
  t_iem_send_kernel *x = (t_iem_send_kernel *)pd_new(iem_send_kernel_class);
  t_glist *glist = (t_glist *)canvas_getcurrent();
  t_canvas *canvas=glist_getcanvas(glist);
  int ac=0;
  t_atom *av;
  
  canvas_setcurrent(canvas);
  canvas_getargs(&ac, &av);
  canvas_unsetcurrent(canvas);
  
  if(ac > 0)
  {
    if(IS_A_SYMBOL(av,0))
    {
      x->x_sym = atom_getsymbol(av);
    }
    else if(IS_A_FLOAT(av,0))
    {
      char str[100];
      
      sprintf(str, "%g", atom_getfloat(av));
      x->x_sym = gensym(str);
    }
    else
      x->x_sym = 0;
  }
  else
    x->x_sym = 0;
  return (x);
}
Example #7
0
static void list2send_list(t_list2send *x, t_symbol *s, int ac, t_atom *av)
{
  if((ac >= 2) && (IS_A_FLOAT(av,0)))
  {
    int identifier_index = (int)atom_getintarg(0, ac, av);
    
    if(identifier_index < x->x_max)
    {
      if(x->x_snd_able[identifier_index])
      {
        t_symbol *sender = x->x_send_entries[identifier_index];
        
        if(sender->s_thing)
        {
          if(ac == 2)
          {
            if(IS_A_FLOAT(av, 1))
              pd_float(sender->s_thing, atom_getfloatarg(1, ac, av));
            else if(IS_A_SYMBOL(av, 1))
              pd_symbol(sender->s_thing, atom_getsymbolarg(1, ac, av));
          }
          else
            pd_list(sender->s_thing, &s_list, ac-1, av+1);
        }
      }
    }
  }
}
Example #8
0
static void *iem_send_new(t_symbol *s, int ac, t_atom *av)
{
  t_iem_send *x = (t_iem_send *)pd_new(iem_send_class);
	t_iem_send_proxy *p = (t_iem_send_proxy *)pd_new(iem_send_proxy_class);

  x->x_proxy_inlet = p;
  p->p_owner = x;
  
  if(ac > 0)
  {
    if(IS_A_SYMBOL(av,0))
    {
      x->x_send_label_sym = atom_getsymbol(av);
    }
    else if(IS_A_FLOAT(av,0))
    {
      char str[32];
      
      sprintf(str, "%g", atom_getfloat(av));
      x->x_send_label_sym = gensym(str);
    }
    else
      x->x_send_label_sym = 0;
  }
  else
    x->x_send_label_sym = 0;
	inlet_new((t_object *)x, (t_pd *)p, 0, 0);
  return (x);
}
Example #9
0
static void mergefilename_anything(t_mergefilename *x, t_symbol *s, int ac, t_atom *av)
{
  char flt_buf[30];
  t_int i, length, accu_size=0;
  
  x->x_mem[0] = 0;
  length = strlen(s->s_name);
  if(length > (MAXPDSTRING - 2))
  {
    strncat(x->x_mem, s->s_name, MAXPDSTRING - 2);
    accu_size = MAXPDSTRING - 2;
    i = ac + 1;
  }
  else
  {
    strcat(x->x_mem, s->s_name);
    accu_size = length;
  }

  if(ac > 0)
  {
    for(i=0; i<ac; i++)
    {
      strcat(x->x_mem, x->x_sep);
      if(IS_A_SYMBOL(av, 0))
      {
        length = strlen(av->a_w.w_symbol->s_name);
        if((accu_size + length) > (MAXPDSTRING - 2))
        {
          strncat(x->x_mem, av->a_w.w_symbol->s_name, MAXPDSTRING - 2 - accu_size);
          accu_size = MAXPDSTRING - 2;
          i = ac + 1;
        }
        else
        {
          strcat(x->x_mem, av->a_w.w_symbol->s_name);
          accu_size += length;
        }
      }
      else if(IS_A_FLOAT(av, 0))
      {
        sprintf(flt_buf, "%g", av->a_w.w_float);
        length = strlen(flt_buf);
        if((accu_size + length) > (MAXPDSTRING - 2))
        {
          strncat(x->x_mem, flt_buf, MAXPDSTRING - 2 - accu_size);
          accu_size = MAXPDSTRING - 2;
          i = ac + 1;
        }
        else
        {
          strcat(x->x_mem, flt_buf);
          accu_size += length;
        }
      }
      av++;
    }
  }
  outlet_symbol(x->x_obj.ob_outlet, gensym(x->x_mem));
}
Example #10
0
static void list2send_from(t_list2send *x, t_symbol *s, int ac, t_atom *av)
{
  int n=x->x_max;
  
  if(ac >= 1)
  {
    int i, j, beg=(int)atom_getintarg(0, ac, av);
    
    if((beg + ac - 1) <= n)
    {
      for(i=ac-1,j=beg+ac-2; i>=1; i--,j--)/*change*/
      {
        if(x->x_snd_able[j])
        {
          t_symbol *sender = x->x_send_entries[j];
          
          if(sender->s_thing)
          {
            if(IS_A_FLOAT(av, i))
              pd_float(sender->s_thing, atom_getfloatarg(i, ac, av));
            else if(IS_A_SYMBOL(av, i))
              pd_symbol(sender->s_thing, atom_getsymbolarg(i, ac, av));
          }
        }
      }
    }
  }
}
Example #11
0
static void *NLMS_tilde_new(t_symbol *s, t_int argc, t_atom *argv)
{
    t_NLMS_tilde *x = (t_NLMS_tilde *)pd_new(NLMS_tilde_class);
    t_int i, n_order=39;
    t_symbol    *w_name;
    t_float beta=0.1f;
    t_float gammax=0.00001f;

    if((argc >= 4) &&
            IS_A_FLOAT(argv,0) &&   //IS_A_FLOAT/SYMBOL from iemlib.h
            IS_A_FLOAT(argv,1) &&
            IS_A_FLOAT(argv,2) &&
            IS_A_SYMBOL(argv,3))
    {
        n_order = (t_int)atom_getintarg(0, argc, argv);
        beta    = (t_float)atom_getfloatarg(1, argc, argv);
        gammax  = (t_float)atom_getfloatarg(2, argc, argv);
        w_name  = (t_symbol *)atom_getsymbolarg(3, argc, argv);

        if(beta < 0.0f)
            beta = 0.0f;
        if(beta > 2.0f)
            beta = 2.0f;

        if(gammax < 0.0f)
            gammax = 0.0f;
        if(gammax > 1.0f)
            gammax = 1.0f;

        if(n_order < 2)
            n_order = 2;
        if(n_order > 11111)
            n_order = 11111;

        inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
        outlet_new(&x->x_obj, &s_signal);
        outlet_new(&x->x_obj, &s_signal);

        x->x_msi = 0;
        x->x_n_order = n_order;
        x->x_update = 0;
        x->x_beta = beta;
        x->x_gamma = gammax;
        // 2 times in and one time desired_in memory allocation (history)
        x->x_in_hist = (t_float *)getbytes(2*x->x_n_order*sizeof(t_float));

        // table-symbols will be linked to their memory in future (dsp_routine)
        x->x_w_array_sym_name = gensym(w_name->s_name);
        x->x_w_array_mem_beg = (t_float *)0;

        return(x);
    }
    else
    {
        post("NLMS~-ERROR: need 3 float- + 1 symbol-arguments:");
        post("  order_of_filter + learnrate_beta + security_value + array_name_taps");
        return(0);
    }
}
Example #12
0
static void *iem_image_new(t_symbol *s, int argc, t_atom *argv)
{
    t_iem_image *x = (t_iem_image *)pd_new(iem_image_class);
    t_symbol *gifsym=(t_symbol *)0;
    x->x_gui.x_snd = gensym("empty");
    x->x_gui.x_rcv = gensym("empty");
    x->x_gui.x_lab = gensym("empty");
    x->x_gui.x_fsf.x_font_style = 0;
    if(argc >= 1)
    {
        if(IS_A_SYMBOL(argv,0))
            gifsym = atom_getsymbolarg(0, argc, argv);
        else if(IS_A_FLOAT(argv,0))
            gifsym = (t_symbol *)0;
    }
    else if(argc >= 5)
    {
        if(IS_A_SYMBOL(argv,0))
            gifsym = atom_getsymbolarg(0, argc, argv);
        else if(IS_A_FLOAT(argv,0))
            gifsym = (t_symbol *)0;
        iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(1, argc, argv));
        iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(2, argc, argv));
        iemgui_new_getnames(&x->x_gui, 3, argv);
    }

    x->x_gui.x_draw = (t_iemfunptr)iem_image_draw;
    x->x_gui.x_fsf.x_snd_able = 1;
    x->x_gui.x_fsf.x_rcv_able = 1;
    x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
    if(!strcmp(x->x_gui.x_snd->s_name, "empty"))
        x->x_gui.x_fsf.x_snd_able = 0;
    if(!strcmp(x->x_gui.x_rcv->s_name, "empty"))
        x->x_gui.x_fsf.x_rcv_able = 0;
    if(x->x_gui.x_fsf.x_rcv_able)
        pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
    x->x_gui.x_w = 100;
    x->x_gui.x_h = 60;
    x->x_gifsym = gifsym;
    x->x_have_image=0;
    x->x_gui.x_fsf.x_selected = 0;
    iemgui_verify_snd_ne_rcv(&x->x_gui);
    outlet_new(&x->x_gui.x_obj, &s_list);
    return(x);
}
Example #13
0
static void spec2_tab_conv_tilde_set(t_spec2_tab_conv_tilde *x, t_symbol *s, int argc, t_atom *argv)
{
  if((argc >= 2) && IS_A_SYMBOL(argv, 0) && IS_A_FLOAT(argv, 1))
  {
    x->x_sym_array = (t_symbol *)(atom_getsymbol(argv));
    x->x_winsize = (int)(atom_getint(argv+1));
    x->x_has_changed = 1;
  }
}
Example #14
0
t_symbol *iemgui_getfloatsym(t_atom *a)
{
    if (IS_A_SYMBOL(a,0)) return (atom_getsymbol(a));
    if (IS_A_FLOAT(a,0)) {
        char str[40];
        sprintf(str, "%d", (int)atom_getint(a));
        return gensym(str);
    }
    return s_empty;
}
Example #15
0
t_symbol *iemgui_new_dogetname(t_iemgui *iemgui, int indx, t_atom *argv)
{
    if (IS_A_SYMBOL(argv, indx))
        return (atom_getsymbolarg(indx, 100000, argv));
    else if (IS_A_FLOAT(argv, indx))
    {
        char str[80];
        sprintf(str, "%d", (int)atom_getintarg(indx, 100000, argv));
        return (gensym(str));
    }
    else return (gensym("empty"));
}
Example #16
0
static void dollarg_float(t_dollarg *x, t_floatarg f)
{
  int i = (int)f;
  
  if(!i)
  {
    outlet_float(x->x_outlet_ac, x->x_ac);
    if(x->x_ac)
      outlet_list(x->x_obj.ob_outlet, &s_list, x->x_ac, x->x_at);
  }
  else if(i > 0)
  {
    if(i <= x->x_ac)
    {
      outlet_float(x->x_outlet_ac, i);
      if(IS_A_FLOAT(x->x_at, i-1))
        outlet_float(x->x_obj.ob_outlet, atom_getfloatarg(i-1, x->x_ac, x->x_at));
      else if(IS_A_SYMBOL(x->x_at, i-1))
        outlet_symbol(x->x_obj.ob_outlet, atom_getsymbolarg(i-1, x->x_ac, x->x_at));
    }
    else
      outlet_float(x->x_outlet_ac, 0);
  }
  else
  {
    int j = x->x_ac + i;
    
    if(j >= 0)
    {
      outlet_float(x->x_outlet_ac, j+1);
      if(IS_A_FLOAT(x->x_at, j))
        outlet_float(x->x_obj.ob_outlet, atom_getfloatarg(j, x->x_ac, x->x_at));
      else if(IS_A_SYMBOL(x->x_at, j))
        outlet_symbol(x->x_obj.ob_outlet, atom_getsymbolarg(j, x->x_ac, x->x_at));
    }
    else
      outlet_float(x->x_outlet_ac, 0);
  }
}
Example #17
0
static void argument_bang(t_argument *x)
{
	
   if (x->has_value) {
		if ( IS_A_SYMBOL(&(x->x_a),0) ) {
			outlet_symbol(x->x_outlet,atom_getsymbol(&(x->x_a)));
		} else {
			outlet_float(x->x_outlet,atom_getfloat(&(x->x_a)));
		}
    }
   

}
Example #18
0
static void *tab_cross_corr_new(t_symbol *s, int argc, t_atom *argv)
{
  t_tab_cross_corr *x = (t_tab_cross_corr *)pd_new(tab_cross_corr_class);
  t_symbol  *src1, *src2, *dst;
  t_float dtime=0.0f, factor=1.0f;
  
  if((argc >= 5) && IS_A_FLOAT(argv,4))
    dtime = (t_float)atom_getfloatarg(4, argc, argv);
  if((argc >= 4) && IS_A_FLOAT(argv,3))
    factor = (t_float)atom_getfloatarg(3, argc, argv);
  if((argc >= 3) &&
    IS_A_SYMBOL(argv,0) &&
    IS_A_SYMBOL(argv,1) &&
    IS_A_SYMBOL(argv,2))
  {
    src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
    src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
    dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
  }
  else
  {
    post("tab_cross_corr-ERROR: need 3 symbol + 2 float arguments:");
    post("  source_reference_array_name + source_measure_array_name + destination_array_name + norm_factor + calculation-time-per-sample_ms");
    return(0);
  }
  
  if(dtime < 0.0f)
    dtime = 0.0f;
  
  x->x_delay = dtime;
  x->x_factor = factor;
  x->x_sym_scr1 = src1;
  x->x_sym_scr2 = src2;
  x->x_sym_dst = dst;
  outlet_new(&x->x_obj, &s_bang);
  x->x_clock = clock_new(x, (t_method)tab_cross_corr_tick);
  return(x);
}
Example #19
0
static void iem_i_route_list(t_iem_i_route *x, t_symbol *sel, int argc, t_atom *argv)
{
  t_outlet **out;
  int first, last, i;
  
  if(!argc)
    return;
  i = (int)atom_getintarg(0, argc, argv);
  first = x->x_first_element;
  last = x->x_last_element;
  out = x->x_out;
  if((i >= first)&&(i <= last))
  {
    out += i - first;
    if(argc >= 3)
    {
      if(IS_A_FLOAT(argv,1))
        outlet_list(*out, &s_list, argc-1, argv+1);
      else if(IS_A_SYMBOL(argv,1))
        outlet_anything(*out, atom_getsymbolarg(1, argc, argv), argc-2, argv+2);
    }
    else if(argc >= 2)
    {
      if(IS_A_FLOAT(argv,1))
        outlet_float(*out, (float)atom_getfloatarg(1, argc, argv));
      else if(IS_A_SYMBOL(argv,1))
        outlet_anything(*out, atom_getsymbolarg(1, argc, argv), 0, argv+2);
    }
    else
      outlet_bang(*out);
  }
  else
  {
    out += last - first + 1;
    outlet_list(*out, &s_list, argc, argv);
  }
}
Example #20
0
static void iem_send_proxy_set(t_iem_send_proxy *p, t_symbol *s, int ac, t_atom *av)
{
  t_iem_send *x = p->p_owner;

	if(ac > 0)
  {
    if(IS_A_SYMBOL(av,0))
      x->x_send_label_sym = atom_getsymbol(av);
    else if(IS_A_FLOAT(av,0))
    {
      char str[32];
      
      sprintf(str, "%g", atom_getfloat(av));
      x->x_send_label_sym = gensym(str);
    }
  }
}
Example #21
0
static void mergefilename_separator(t_mergefilename *x, t_symbol *s, int ac, t_atom *av)
{
  if(ac > 0)
  {
    if(IS_A_SYMBOL(av, 0))
    {
      char *name=av->a_w.w_symbol->s_name;

      if(strlen(name) == 1)
        x->x_sep[0] = name[0];
      else if(!strcmp(name, "backslash"))
        x->x_sep[0] = '\\';
      else if(!strcmp(name, "slash"))
        x->x_sep[0] = '/';
      else if(!strcmp(name, "blank"))
        x->x_sep[0] = ' ';
      else if(!strcmp(name, "space"))
        x->x_sep[0] = ' ';
      else if(!strcmp(name, "dollar"))
        x->x_sep[0] = '$';
      else if(!strcmp(name, "comma"))
        x->x_sep[0] = ',';
      else if(!strcmp(name, "semi"))
        x->x_sep[0] = ';';
      else if(!strcmp(name, "leftbrace"))
        x->x_sep[0] = '{';
      else if(!strcmp(name, "rightbrace"))
        x->x_sep[0] = '}';
      else
        x->x_sep[0] = 0;
    }
    else if(IS_A_FLOAT(av, 0))
    {
      t_int i=atom_getintarg(0, ac, av);
      
      x->x_sep[0] = (char)i + '0';
    }
  }
  else
    x->x_sep[0] = 0;
}
Example #22
0
static void *spec2_tab_conv_tilde_new(t_symbol *s, int argc, t_atom *argv)
{
  t_spec2_tab_conv_tilde *x = (t_spec2_tab_conv_tilde *)pd_new(spec2_tab_conv_tilde_class);
  
  if((argc >= 2) && IS_A_SYMBOL(argv,0) && IS_A_FLOAT(argv,1))
  {
    x->x_sym_array = (t_symbol *)(atom_getsymbol(argv));
    x->x_winsize = (int)(atom_getint(argv+1));
    x->x_spec = (t_float *)0;
    x->x_beg_array = (iemarray_t *)0;
    x->x_blocksize = 0;
    x->x_has_changed = 1;
    outlet_new(&x->x_obj, &s_signal);
    x->x_msi = 0.0f;
    return(x);
  }
  else
  {
    post("spec2_tab_conv~-ERROR: needs 2 args: <sym> convolution-array-name + <float> convolution-array-size !!!");
    return(0);
  }
}
Example #23
0
static void list2send_all(t_list2send *x, t_symbol *s, int ac, t_atom *av)
{
  int i, n=x->x_max;
  
  if(ac == n)
  {
    for(i=n-1; i>=0; i--)/*change*/
    {
      if(x->x_snd_able[i])
      {
        t_symbol *sender = x->x_send_entries[i];
        
        if(sender->s_thing)
        {
          if(IS_A_FLOAT(av, i))
            pd_float(sender->s_thing, atom_getfloatarg(i, ac, av));
          else if(IS_A_SYMBOL(av, i))
            pd_symbol(sender->s_thing, atom_getsymbolarg(i, ac, av));
        }
      }
    }
  }
}
Example #24
0
static void list2send_add(t_list2send *x, t_symbol *s, int ac, t_atom *av)
{
  if((ac > 1) && (IS_A_FLOAT(av, 0)))
  {
    int identifier_index = (int)atom_getintarg(0, ac, av);
    
    if(identifier_index < x->x_max)
    {
      if(IS_A_SYMBOL(av, 1))
      {
        x->x_send_entries[identifier_index] = atom_getsymbolarg(1, ac, av);
        x->x_snd_able[identifier_index] = 1;
      }
      else if(IS_A_FLOAT(av, 1))
      {
        char str[100];
        
        sprintf(str, "%g", atom_getfloatarg(1, ac, av));
        x->x_send_entries[identifier_index] = gensym(str);
        x->x_snd_able[identifier_index] = 1;
      }
    }
  }
}
Example #25
0
static void *iem_vu_new(t_symbol *s, int argc, t_atom *argv)
{
  t_iem_vu *x = (t_iem_vu *)pd_new(iem_vu_class);
  int bflcol[]={-66577, -1, -1};
  int w=IEM_GUI_DEFAULTSIZE;
  int ldx=-1, ldy=-8, f=0, fs=8, scale=1;
  int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, fthold=IEM_BNG_DEFAULTHOLDFLASHTIME;
  char str[144];
  
  iem_inttosymargs(&x->x_gui.x_isa, 0);
  iem_inttofstyle(&x->x_gui.x_fsf, 0);
  
  if((argc >= 11)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
    &&(IS_A_SYMBOL(argv,2)||IS_A_FLOAT(argv,2))
    &&(IS_A_SYMBOL(argv,3)||IS_A_FLOAT(argv,3))
    &&IS_A_FLOAT(argv,4)&&IS_A_FLOAT(argv,5)
    &&IS_A_FLOAT(argv,6)&&IS_A_FLOAT(argv,7)
    &&IS_A_FLOAT(argv,8)&&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10))
  {
    w = (int)atom_getintarg(0, argc, argv);
    iemgui_new_getnames(&x->x_gui, 1, argv);
    ldx = (int)atom_getintarg(4, argc, argv);
    ldy = (int)atom_getintarg(5, argc, argv);
    iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(6, argc, argv));
    fs = (int)atom_getintarg(7, argc, argv);
    bflcol[0] = (int)atom_getintarg(8, argc, argv);
    bflcol[2] = (int)atom_getintarg(9, argc, argv);
    scale = (int)atom_getintarg(10, argc, argv);
  }
  else iemgui_new_getnames(&x->x_gui, 1, 0);
  if((argc == 12)&&IS_A_FLOAT(argv,11))
    iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(11, argc, argv));
  x->x_gui.x_draw = (t_iemfunptr)iem_vu_draw;
  
  x->x_gui.x_fsf.x_snd_able = 0;
  x->x_gui.x_fsf.x_rcv_able = 1;
  x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
  if (!strcmp(x->x_gui.x_rcv->s_name, "empty"))
    x->x_gui.x_fsf.x_rcv_able = 0;
  if (x->x_gui.x_fsf.x_font_style == 1)
    strcpy(x->x_gui.x_font, "helvetica");
  else if(x->x_gui.x_fsf.x_font_style == 2)
    strcpy(x->x_gui.x_font, "times");
  else { x->x_gui.x_fsf.x_font_style = 0;
  strcpy(x->x_gui.x_font, "courier"); }
  if(x->x_gui.x_fsf.x_rcv_able)
    pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
  x->x_gui.x_ldx = ldx;
  x->x_gui.x_ldy = ldy;
  
  if(fs < 4)
    fs = 4;
  x->x_gui.x_fontsize = fs;
  //  x->x_gui.x_w = iem_vu_clip_width(w)-1;
  x->x_gui.x_w = iem_vu_clip_width(w+1);
  x->x_old_width = x->x_gui.x_w;
  x->x_gui.x_h = 120;
  
  iemgui_all_colfromload(&x->x_gui, bflcol);
  if(scale != 0)
    scale = 1;
  x->x_scale = scale;
  x->x_peak = 0;
  x->x_rms = 0;
  x->x_fp = -101.0;
  x->x_fr = -101.0;
  iemgui_verify_snd_ne_rcv(&x->x_gui);
  inlet_new(&x->x_gui.x_obj, &x->x_gui.x_obj.ob_pd, &s_float, gensym("ft1"));
  x->x_out_rms = outlet_new(&x->x_gui.x_obj, &s_float);
  x->x_out_peak = outlet_new(&x->x_gui.x_obj, &s_float);
  x->x_scale_w = 14;
  x->x_scale_h = 129;
  strcpy(x->x_scale_gif, my_iemgui_black_vscale_gif);
  x->x_gui.x_fsf.x_selected = 0;
  return (x);
}
Example #26
0
static void *iem_vu_new(t_symbol *s, int argc, t_atom *argv)
{
  t_iem_vu *x = (t_iem_vu *)pd_new(iem_vu_class);
  int bflcol[]={-66577, -1, -1};
  t_symbol *srl[3];
  int w=IEM_GUI_DEFAULTSIZE;
  int ldx=-1, ldy=-8, f=0, fs=8, scale=1;
  int iinit=0, ifstyle=0;
  int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, fthold=IEM_BNG_DEFAULTHOLDFLASHTIME;
  t_iem_init_symargs *init=(t_iem_init_symargs *)(&iinit);
  t_iem_fstyle_flags *fstyle=(t_iem_fstyle_flags *)(&ifstyle);
  char str[144];
  
  srl[0] = gensym("empty");
  srl[1] = gensym("empty");
  srl[2] = gensym("empty");
  
  if((argc >= 11)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
    &&(IS_A_SYMBOL(argv,2)||IS_A_FLOAT(argv,2))
    &&(IS_A_SYMBOL(argv,3)||IS_A_FLOAT(argv,3))
    &&IS_A_FLOAT(argv,4)&&IS_A_FLOAT(argv,5)
    &&IS_A_FLOAT(argv,6)&&IS_A_FLOAT(argv,7)
    &&IS_A_FLOAT(argv,8)&&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10))
  {
    w = (int)atom_getintarg(0, argc, argv);
    if(IS_A_SYMBOL(argv,2))
      srl[1] = atom_getsymbolarg(2, argc, argv);
    else if(IS_A_FLOAT(argv,2))
    {
      sprintf(str, "%d", (int)atom_getintarg(2, argc, argv));
      srl[1] = gensym(str);
    }
    if(IS_A_SYMBOL(argv,3))
      srl[2] = atom_getsymbolarg(3, argc, argv);
    else if(IS_A_FLOAT(argv,3))
    {
      sprintf(str, "%d", (int)atom_getintarg(3, argc, argv));
      srl[2] = gensym(str);
    }
    ldx = (int)atom_getintarg(4, argc, argv);
    ldy = (int)atom_getintarg(5, argc, argv);
    ifstyle = (int)atom_getintarg(6, argc, argv);
    fs = (int)atom_getintarg(7, argc, argv);
    bflcol[0] = (int)atom_getintarg(8, argc, argv);
    bflcol[2] = (int)atom_getintarg(9, argc, argv);
    scale = (int)atom_getintarg(10, argc, argv);
  }
  if((argc == 12)&&IS_A_FLOAT(argv,11))
    iinit = (int)atom_getintarg(11, argc, argv);
  x->x_gui.x_draw = (t_iemfunptr)iem_vu_draw;
  iinit &= IEM_INIT_ARGS_ALL;
  ifstyle &= IEM_FSTYLE_FLAGS_ALL;
  
  fstyle->x_snd_able = 0;
  fstyle->x_rcv_able = 1;
  x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
  x->x_gui.x_isa = *init;
  if(!strcmp(srl[1]->s_name, "empty")) fstyle->x_rcv_able = 0;
  x->x_gui.x_unique_num = 0;
  if(fstyle->x_font_style == 1)
    strcpy(x->x_gui.x_font, "helvetica");
  else if(fstyle->x_font_style == 2)
    strcpy(x->x_gui.x_font, "times");
  else
  { 
    fstyle->x_font_style = 0;
    strcpy(x->x_gui.x_font, "courier");
  }
  x->x_gui.x_fsf = *fstyle;
  iemgui_first_dollararg2sym(&x->x_gui, srl);
  if(x->x_gui.x_fsf.x_rcv_able)
    pd_bind(&x->x_gui.x_obj.ob_pd, srl[1]);
  x->x_gui.x_snd = srl[0];
  x->x_gui.x_rcv = srl[1];
  x->x_gui.x_lab = srl[2];
  x->x_gui.x_ldx = ldx;
  x->x_gui.x_ldy = ldy;
  
  if(fs < 4)
    fs = 4;
  x->x_gui.x_fontsize = fs;
  //  x->x_gui.x_w = iem_vu_clip_width(w)-1;
  x->x_gui.x_w = iem_vu_clip_width(w+1);
  x->x_old_width = x->x_gui.x_w;
  x->x_gui.x_h = 120;
  
  iemgui_all_colfromload(&x->x_gui, bflcol);
  if(scale != 0)
    scale = 1;
  x->x_scale = scale;
  x->x_peak = 0;
  x->x_rms = 0;
  x->x_fp = -101.0;
  x->x_fr = -101.0;
  iemgui_verify_snd_ne_rcv(&x->x_gui);
  inlet_new(&x->x_gui.x_obj, &x->x_gui.x_obj.ob_pd, &s_float, gensym("ft1"));
  x->x_out_rms = outlet_new(&x->x_gui.x_obj, &s_float);
  x->x_out_peak = outlet_new(&x->x_gui.x_obj, &s_float);
  x->x_scale_w = 14;
  x->x_scale_h = 129;
  strcpy(x->x_scale_gif, my_iemgui_black_vscale_gif);
  x->x_gui.x_fsf.x_selected = 0;
  return (x);
}
Example #27
0
static void *iem_event_new(t_symbol *s, int argc, t_atom *argv)
{
  t_iem_event *x = (t_iem_event *)pd_new(iem_event_class);
  t_int w=32, h=32;
  t_int iinit=0, ifstyle=0;
  t_iem_init_symargs *init=(t_iem_init_symargs *)(&iinit);
  t_iem_fstyle_flags *fstyle=(t_iem_fstyle_flags *)(&ifstyle);
  t_symbol *srl[3];
  char str[144];
  
  x->x_gui.x_snd = gensym("empty");
  x->x_gui.x_rcv = gensym("empty");
  x->x_gui.x_lab = gensym("empty");
  srl[0] = gensym("empty");
  srl[1] = gensym("empty");
  srl[2] = gensym("empty");
  x->x_gui.x_fsf.x_font_style = 0;
  if((argc >= 6)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
    &&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,3)
    &&(IS_A_SYMBOL(argv,4)||IS_A_FLOAT(argv,4))
    &&(IS_A_SYMBOL(argv,5)||IS_A_FLOAT(argv,5)))
  {
    w = (int)atom_getintarg(0, argc, argv);
    h = (int)atom_getintarg(1, argc, argv);
    iinit = (int)atom_getintarg(2, argc, argv);
    ifstyle = (int)atom_getintarg(3, argc, argv);
    if(IS_A_SYMBOL(argv,4))
      srl[0] = atom_getsymbolarg(4, argc, argv);
    else if(IS_A_FLOAT(argv,4))
    {
      sprintf(str, "%d", (int)atom_getintarg(4, argc, argv));
      srl[0] = gensym(str);
    }
    if(IS_A_SYMBOL(argv,5))
      srl[1] = atom_getsymbolarg(5, argc, argv);
    else if(IS_A_FLOAT(argv,5))
    {
      sprintf(str, "%d", (int)atom_getintarg(5, argc, argv));
      srl[1] = gensym(str);
    }
  }
  else if((argc >= 2)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1))
  {
    w = (int)atom_getintarg(0, argc, argv);
    h = (int)atom_getintarg(1, argc, argv);
  }
  iinit &= IEM_INIT_ARGS_ALL;
  ifstyle &= IEM_FSTYLE_FLAGS_ALL;
  
  x->x_gui.x_draw = (t_iemfunptr)iem_event_draw;
  x->x_gui.x_fsf.x_snd_able = 1;
  x->x_gui.x_fsf.x_rcv_able = 1;
  x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
  fstyle->x_snd_able = 1;
  fstyle->x_rcv_able = 1;
  if(!strcmp(srl[0]->s_name, "empty"))
    fstyle->x_snd_able = 0;
  if(!strcmp(srl[1]->s_name, "empty"))
    fstyle->x_rcv_able = 0;
  x->x_gui.x_unique_num = 0;
  x->x_gui.x_fsf = *fstyle;
  x->x_gui.x_isa = *init;
  iemgui_first_dollararg2sym(&x->x_gui, srl);
  if(x->x_gui.x_fsf.x_rcv_able)
    pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
  if(w < 4)
    w = 4;
  x->x_gui.x_w = w;
  if(h < 4)
    h = 4;
  x->x_gui.x_h = h;
  iemgui_verify_snd_ne_rcv(&x->x_gui);
  outlet_new(&x->x_gui.x_obj, &s_list);
  x->x_mouse_shft_alt = gensym("mouse_shft_alt");
  x->x_dragg_x_y = gensym("dragg_x_y");
  x->x_key = gensym("key");
  x->x_move_x_y = gensym("move_x_y");
  x->x_x = 0;
  x->x_y = 0;
  x->x_doit = 0;
  return (x);
}
static void *bin_ambi_reduced_decode_fft2_new(t_symbol *s, int argc, t_atom *argv)
{
  t_bin_ambi_reduced_decode_fft2 *x = (t_bin_ambi_reduced_decode_fft2 *)pd_new(bin_ambi_reduced_decode_fft2_class);
  char buf[400];
  int i, j, fftok, ok=0;
  int n_order=0, n_dim=0, n_real_ls=0, n_pht_ls=0, n_ambi=0, fftsize=0, prefix=0;
  t_symbol  *s_hrir=gensym("L_HRIR");
  t_symbol  *s_hrtf_re=gensym("HRTF_re");
  t_symbol  *s_hrtf_im=gensym("HRTF_im");
  t_symbol  *s_fade_out_hrir=gensym("HRIR_win");
  
  if((argc >= 10) &&
    IS_A_FLOAT(argv,0) &&
    IS_A_SYMBOL(argv,1) &&
    IS_A_SYMBOL(argv,2) &&
    IS_A_SYMBOL(argv,3) &&
    IS_A_SYMBOL(argv,4) &&
    IS_A_FLOAT(argv,5) &&
    IS_A_FLOAT(argv,6) &&
    IS_A_FLOAT(argv,7) &&
    IS_A_FLOAT(argv,8) &&
    IS_A_FLOAT(argv,9))
  {
    prefix  = (int)atom_getintarg(0, argc, argv);
    
    s_hrir                = (t_symbol *)atom_getsymbolarg(1, argc, argv);
    s_hrtf_re             = (t_symbol *)atom_getsymbolarg(2, argc, argv);
    s_hrtf_im             = (t_symbol *)atom_getsymbolarg(3, argc, argv);
    s_fade_out_hrir       = (t_symbol *)atom_getsymbolarg(4, argc, argv);
    
    n_order   = (int)atom_getintarg(5, argc, argv);
    n_dim     = (int)atom_getintarg(6, argc, argv);
    n_real_ls = (int)atom_getintarg(7, argc, argv);
    n_pht_ls    = (int)atom_getintarg(8, argc, argv);
    fftsize = (int)atom_getintarg(9, argc, argv);
    
    ok = 1;
  }
  else if((argc >= 10) &&
    IS_A_FLOAT(argv,0) &&
    IS_A_FLOAT(argv,1) &&
    IS_A_FLOAT(argv,2) &&
    IS_A_FLOAT(argv,3) &&
    IS_A_FLOAT(argv,4) &&
    IS_A_FLOAT(argv,5) &&
    IS_A_FLOAT(argv,6) &&
    IS_A_FLOAT(argv,7) &&
    IS_A_FLOAT(argv,8) &&
    IS_A_FLOAT(argv,9))
  {
    prefix  = (int)atom_getintarg(0, argc, argv);
    
    s_hrir                = gensym("L_HRIR");
    s_hrtf_re             = gensym("HRTF_re");
    s_hrtf_im             = gensym("HRTF_im");
    s_fade_out_hrir       = gensym("HRIR_win");
    
    n_order = (int)atom_getintarg(5, argc, argv);
    n_dim   = (int)atom_getintarg(6, argc, argv);
    n_real_ls = (int)atom_getintarg(7, argc, argv);
    n_pht_ls    = (int)atom_getintarg(8, argc, argv);
    fftsize = (int)atom_getintarg(9, argc, argv);
    
    ok = 1;
  }
  
  if(ok)
  {
    if(n_order < 1)
      n_order = 1;
    
    if(n_dim == 3)
    {
      if(n_order > 5)
        n_order = 5;
      n_ambi = (n_order + 1)*(n_order + 1);
    }
    else
    {
      if(n_order > 12)
        n_order = 12;
      n_dim = 2;
      n_ambi = 2 * n_order + 1;
    }
    
    if(n_real_ls < 1)
      n_real_ls = 1;
    if(n_pht_ls < 0)
      n_pht_ls = 0;
    
    if((n_real_ls+n_pht_ls) < n_ambi)
    {
      post("bin_ambi_reduced_decode_fft2-WARNING: Number of all Loudspeakers < Number of Ambisonic-Channels !!!!");
    }
    
    j = 2;
    fftok = 0;
    for(i=0; i<21; i++)
    {
      if(j == fftsize)
      {
        fftok = 1;
        i = 22;
      }
      j *= 2;
    }
    
    if(!fftok)
    {
      fftsize = 512;
      post("bin_ambi_reduced_decode_fft2-WARNING: fftsize not equal to 2 ^ n !!!");
      post("                                     fftsize set to %d", fftsize);
    }
    
    x->x_n_dim      = n_dim;
    x->x_n_ambi     = n_ambi;
    x->x_n_real_ls  = n_real_ls;
    x->x_n_pht_ls   = n_pht_ls;
    x->x_n_order    = n_order;
    x->x_fftsize    = fftsize;
    
    x->x_hrir_filename  = (t_symbol **)getbytes(x->x_n_real_ls * sizeof(t_symbol *));
    x->x_s_hrir         = (t_symbol **)getbytes(x->x_n_real_ls * sizeof(t_symbol *));
    x->x_s_hrtf_re      = (t_symbol **)getbytes(x->x_n_ambi * sizeof(t_symbol *));
    x->x_s_hrtf_im      = (t_symbol **)getbytes(x->x_n_ambi * sizeof(t_symbol *));
    
    j = x->x_n_real_ls;
    for(i=0; i<j; i++)
    {
      sprintf(buf, "%d_%d_%s", prefix, i+1, s_hrir->s_name);
      x->x_s_hrir[i] = gensym(buf);
    }
    
    for(i=0; i<n_ambi; i++)
    {
      sprintf(buf, "%d_%d_%s", prefix, i+1, s_hrtf_re->s_name);
      x->x_s_hrtf_re[i] = gensym(buf);
      
      sprintf(buf, "%d_%d_%s", prefix, i+1, s_hrtf_im->s_name);
      x->x_s_hrtf_im[i] = gensym(buf);
    }
    
    sprintf(buf, "%d_%s", prefix, s_fade_out_hrir->s_name);
    x->x_s_fade_out_hrir = gensym(buf);
    
    x->x_inv_work1  = (double *)getbytes(x->x_n_ambi * x->x_n_ambi * sizeof(double));
    x->x_inv_work2  = (double *)getbytes(2 * x->x_n_ambi * x->x_n_ambi * sizeof(double));
    x->x_inv_buf2   = (double *)getbytes(2 * x->x_n_ambi * sizeof(double));
    x->x_transp     = (double *)getbytes((x->x_n_real_ls+x->x_n_pht_ls) * x->x_n_ambi * sizeof(double));
    x->x_ls_encode  = (double *)getbytes((x->x_n_real_ls+x->x_n_pht_ls) * x->x_n_ambi * sizeof(double));
    x->x_prod2      = (double *)getbytes((x->x_n_real_ls+x->x_n_pht_ls) * x->x_n_ambi * sizeof(double));
    x->x_prod3      = (double *)getbytes(x->x_n_real_ls * x->x_n_ambi * sizeof(double));
    x->x_ambi_channel_weight = (double *)getbytes(x->x_n_ambi * sizeof(double));
    
    x->x_delta      = (int *)getbytes((x->x_n_real_ls+x->x_n_pht_ls) * sizeof(int));
    x->x_phi        = (int *)getbytes((x->x_n_real_ls+x->x_n_pht_ls) * sizeof(int));
    x->x_phi_sym    = (int *)getbytes(x->x_n_real_ls * sizeof(int));
    x->x_sym_flag   = (int *)getbytes(x->x_n_real_ls * sizeof(int));
    
    x->x_spec       = (BIN_AMBI_COMPLEX *)getbytes(x->x_fftsize * sizeof(BIN_AMBI_COMPLEX));
    x->x_sin_cos    = (BIN_AMBI_COMPLEX *)getbytes(x->x_fftsize * sizeof(BIN_AMBI_COMPLEX));
    
    x->x_beg_fade_out_hrir  = 0;
    x->x_beg_hrir           = (t_float *)getbytes(x->x_fftsize * x->x_n_real_ls * sizeof(t_float));
    x->x_beg_hrtf_re        = (iemarray_t **)getbytes(x->x_n_ambi * sizeof(iemarray_t *));
    x->x_beg_hrtf_im        = (iemarray_t **)getbytes(x->x_n_ambi * sizeof(iemarray_t *));
    
    x->x_sqrt3        = sqrt(3.0);
    x->x_sqrt5_2      = sqrt(5.0) / 2.0;
    x->x_sqrt6_4      = sqrt(6.0) / 4.0;
    x->x_sqrt10_4     = sqrt(10.0) / 4.0;
    x->x_sqrt15_2     = sqrt(15.0) / 2.0;
    x->x_sqrt35_8     = sqrt(35.0) / 8.0;
    x->x_sqrt70_4     = sqrt(70.0) / 4.0;
    x->x_sqrt126_16   = sqrt(126.0) / 16.0;
    x->x_sqrt315_8    = sqrt(315.0) / 8.0;
    x->x_sqrt105_4    = sqrt(105.0) / 4.0;
    x->x_pi_over_180  = 4.0 * atan(1.0) / 180.0;
    x->x_sing_range = 1.0e-10;
    x->x_seq_ok = 1;
    for(i=0; i<n_ambi; i++)
      x->x_ambi_channel_weight[i] = 1.0;
    
    bin_ambi_reduced_decode_fft2_init_cos(x);
    
    outlet_new(&x->x_obj, &s_list);
    x->x_out_sign_sum = outlet_new(&x->x_obj, &s_list);
    return(x);
  }
  else
  {
    post("bin_ambi_reduced_decode_fft2-ERROR: need 1 float + 4 symbols + 5 floats arguments:");
    post("  prefix(unique-number) + hrir_name + hrtf_re_name + hrtf_im_name + hrir_fade_out_name +");
    post("   + ambi_order + ambi_dimension + number_of_real_loudspeakers + ");
    post("   + number_of_phantom_loudspeakers + fftsize");
    return(0);
  }
}
Example #29
0
static void *n_CLNLMS_tilde_new(t_symbol *s, t_int argc, t_atom *argv)
{
  t_n_CLNLMS_tilde *x = (t_n_CLNLMS_tilde *)pd_new(n_CLNLMS_tilde_class);
  char buffer[400];
  int i;
  t_int n_order=39, n_io=1;
  t_symbol    *w_name;
  t_float beta=0.1f;
  t_float gammax=0.00001f;
  t_float kappa = 1.0f;
  t_float leakage = 0.99f;
  
  if((argc >= 7) &&
    IS_A_FLOAT(argv,0) &&   //IS_A_FLOAT/SYMBOL from iemlib.h
    IS_A_FLOAT(argv,1) &&
    IS_A_FLOAT(argv,2) &&
    IS_A_FLOAT(argv,3) &&
    IS_A_FLOAT(argv,4) &&
    IS_A_FLOAT(argv,5) &&
    IS_A_SYMBOL(argv,6))
  {
    n_io = (t_int)atom_getintarg(0, argc, argv);
    n_order = (t_int)atom_getintarg(1, argc, argv);
    beta    = (t_float)atom_getfloatarg(2, argc, argv);
    gammax  = (t_float)atom_getfloatarg(3, argc, argv);
    kappa   = (t_float)atom_getfloatarg(4, argc, argv);
    leakage   = (t_float)atom_getfloatarg(5, argc, argv);
    w_name  = (t_symbol *)atom_getsymbolarg(6, argc, argv);
    
    if(beta < 0.0f)
      beta = 0.0f;
    if(beta > 2.0f)
      beta = 2.0f;
    
    if(gammax < 0.0f)
      gammax = 0.0f;
    if(gammax > 1.0f)
      gammax = 1.0f;
    
    if(kappa < 0.0001f)
      kappa = 0.0001f;
    if(kappa > 10000.0f)
      kappa = 10000.0f;
    
    if(leakage < 0.0001f)
      leakage = 0.0001f;
    if(leakage > 1.0f)
      leakage = 1.0f;
      
    if(n_order < 2)
      n_order = 2;
    if(n_order > 11111)
      n_order = 11111;
    
    if(n_io < 1)
      n_io = 1;
    if(n_io > 60)
      n_io = 60;
    
    for(i=0; i<n_io; i++)
      inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
    for(i=0; i<=n_io; i++)
      outlet_new(&x->x_obj, &s_signal);
    
    x->x_out_compressing_bang = outlet_new(&x->x_obj, &s_bang);
    
    x->x_msi = 0;
    x->x_n_io = n_io;
    x->x_n_order = n_order;
    x->x_update = 0;
    x->x_beta = beta;
    x->x_gamma = gammax;
    x->x_kappa = kappa;
    x->x_leakage = leakage;
    x->x_my_kern = (t_n_CLNLMS_tilde_kern *)getbytes(x->x_n_io*sizeof(t_n_CLNLMS_tilde_kern));
    for(i=0; i<n_io; i++)
    {
      sprintf(buffer, "%d_%s", i+1, w_name->s_name);
      x->x_my_kern[i].x_w_array_sym_name = gensym(buffer);
      x->x_my_kern[i].x_w_array_mem_beg = (t_float *)0;
      x->x_my_kern[i].x_in_hist = (t_float *)getbytes(2*x->x_n_order*sizeof(t_float));
    }
    x->x_clock = clock_new(x, (t_method)n_CLNLMS_tilde_tick);
    
    return(x);
  }
  else
  {
    post("n_CLNLMSC~-ERROR: need 6 float- + 1 symbol-arguments:");
    post("  number_of_filters + order_of_filters + learnrate_beta + security_value_gamma + threshold_kappa + leakage_factor_lambda + array_name_taps");
    return(0);
  }
}
Example #30
0
static void *iem_image_new(t_symbol *s, int argc, t_atom *argv)
{
    t_iem_image *x = (t_iem_image *)pd_new(iem_image_class);
    t_symbol *gifsym=(t_symbol *)0;
    t_int iinit=0, ifstyle=0;
    t_iem_init_symargs *init=(t_iem_init_symargs *)(&iinit);
    t_iem_fstyle_flags *fstyle=(t_iem_fstyle_flags *)(&ifstyle);
    t_symbol *srl[3];
    char str[144];

    x->x_gui.x_snd = gensym("empty");
    x->x_gui.x_rcv = gensym("empty");
    x->x_gui.x_lab = gensym("empty");
    srl[0] = gensym("empty");
    srl[1] = gensym("empty");
    srl[2] = gensym("empty");
    x->x_gui.x_fsf.x_font_style = 0;
    if(argc >= 1)
    {
        if(IS_A_SYMBOL(argv,0))
            gifsym = atom_getsymbolarg(0, argc, argv);
        else if(IS_A_FLOAT(argv,0))
            gifsym = (t_symbol *)0;
    }
    else if(argc >= 5)
    {
        if(IS_A_SYMBOL(argv,0))
            gifsym = atom_getsymbolarg(0, argc, argv);
        else if(IS_A_FLOAT(argv,0))
            gifsym = (t_symbol *)0;
        iinit = (int)atom_getintarg(1, argc, argv);
        ifstyle = (int)atom_getintarg(2, argc, argv);
        if(IS_A_SYMBOL(argv, 3))
            srl[0] = atom_getsymbolarg(3, argc, argv);
        else if(IS_A_FLOAT(argv,3))
        {
            sprintf(str, "%d", (int)atom_getintarg(3, argc, argv));
            srl[0] = gensym(str);
        }
        if(IS_A_SYMBOL(argv,4))
            srl[1] = atom_getsymbolarg(4, argc, argv);
        else if(IS_A_FLOAT(argv,4))
        {
            sprintf(str, "%d", (int)atom_getintarg(4, argc, argv));
            srl[1] = gensym(str);
        }
    }

    iinit &= IEM_INIT_ARGS_ALL;
    ifstyle &= IEM_FSTYLE_FLAGS_ALL;
    x->x_gui.x_draw = (t_iemfunptr)iem_image_draw;
    x->x_gui.x_fsf.x_snd_able = 1;
    x->x_gui.x_fsf.x_rcv_able = 1;
    x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
    fstyle->x_snd_able = 1;
    fstyle->x_rcv_able = 1;
    if(!strcmp(srl[0]->s_name, "empty"))
        fstyle->x_snd_able = 0;
    if(!strcmp(srl[1]->s_name, "empty"))
        fstyle->x_rcv_able = 0;
    x->x_gui.x_unique_num = 0;
    x->x_gui.x_fsf = *fstyle;
    x->x_gui.x_isa = *init;
    iemgui_first_dollararg2sym(&x->x_gui, sr);
    if(x->x_gui.x_fsf.x_rcv_able)
        pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
    x->x_gui.x_w = 100;
    x->x_gui.x_h = 60;
    x->x_gifsym = gifsym;
    x->x_gui.x_fsf.x_selected = 0;
    iemgui_verify_snd_ne_rcv(&x->x_gui);
    outlet_new(&x->x_gui.x_obj, &s_list);
    return(x);
}