Example #1
0
static void *iem_i_route_new(t_symbol *s, int argc, t_atom *argv)
{
  int n, i;
  t_outlet **out;
  t_iem_i_route *x = (t_iem_i_route *)pd_new(iem_i_route_class);
  
  if((argc >= 2)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1))
  {
    x->x_first_element = (int)atom_getintarg(0, argc, argv);
    x->x_last_element = (int)atom_getintarg(1, argc, argv);
    if((argc >= 3)&&IS_A_FLOAT(argv,2))
    {
      i = (int)atom_getintarg(2, argc, argv);
      x->x_first_element += i;
      x->x_last_element += i;
    }
    x->x_out = (t_outlet **)getbytes((x->x_last_element-x->x_first_element+2) * sizeof(t_outlet *));
    n = x->x_last_element - x->x_first_element + 2;
    for(i=0, out=x->x_out; i<n; i++, out++)
      *out = outlet_new(&x->x_obj, &s_list);
    return (x);
  }
  else
  {
    post("iem_i_route-ERROR: needs 3 floats!!");
    return(0);
  }
}
Example #2
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 #3
0
static void t3_line_tilde_list(t_t3_line_tilde *x, t_symbol *s, int ac, t_atom *av)
{
  if((ac >= 2)&&IS_A_FLOAT(av,0)&&IS_A_FLOAT(av,1))
  {
    int t3_bang_samps, ticks;
    double dtime;
    
    x->x_inlet_val = (double)atom_getfloatarg(1, ac, av);
    t3_bang_samps = (int)((t_float)atom_getfloatarg(0, ac, av)*x->x_ms2samps);
    if(t3_bang_samps < 0)
      t3_bang_samps = 0;
    ticks = t3_bang_samps / x->x_n;
    x->x_t3_bang_samps = t3_bang_samps - x->x_n * ticks;
    if((ac >= 3)&&IS_A_FLOAT(av,2))
    {
      dtime = (double)atom_getfloatarg(2, ac, av);
      if(dtime < 0.0)
        dtime = 0.0;
      x->x_inlet_time = dtime;
    }
    if(ticks < 1)
      t3_line_tilde_tick(x);
    else
      clock_delay(x->x_clock, (double)ticks * x->x_ticks2ms);
  }
}
Example #4
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 #5
0
static void t3_metro_list(t_t3_metro *x, t_symbol *s, int ac, t_atom *av)
{
  if((ac == 2)&&IS_A_FLOAT(av,0)&&IS_A_FLOAT(av,1))
  {
    t3_metro_ft1(x, atom_getfloatarg(1, ac, av));
    t3_metro_float(x, atom_getfloatarg(0, ac, av));
  }
}
Example #6
0
static void tab_lt_list(t_tab_lt *x, t_symbol *s, int argc, t_atom *argv)
{
    int beg_src1, beg_src2, beg_dst;
    int i, n;
    int ok_src1, ok_src2, ok_dst;
    iemarray_t *vec_src1, *vec_src2, *vec_dst;

    if((argc >= 4) &&
            IS_A_FLOAT(argv,0) &&
            IS_A_FLOAT(argv,1) &&
            IS_A_FLOAT(argv,2) &&
            IS_A_FLOAT(argv,3))
    {
        beg_src1 = (int)atom_getintarg(0, argc, argv);
        beg_src2 = (int)atom_getintarg(1, argc, argv);
        beg_dst = (int)atom_getintarg(2, argc, argv);
        n = (int)atom_getintarg(3, argc, argv);
        if(beg_src1 < 0)
            beg_src1 = 0;
        if(beg_src2 < 0)
            beg_src2 = 0;
        if(beg_dst < 0)
            beg_dst = 0;
        if(n < 0)
            n = 0;

        ok_src1 = iem_tab_check_arrays(gensym("tab_lt"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
        ok_src2 = iem_tab_check_arrays(gensym("tab_lt"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, beg_src2+n);
        ok_dst = iem_tab_check_arrays(gensym("tab_lt"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);

        if(ok_src1 && ok_src2 && ok_dst)
        {
            vec_src1 = x->x_beg_mem_src1 + beg_src1;
            vec_src2 = x->x_beg_mem_src2 + beg_src2;
            vec_dst = x->x_beg_mem_dst + beg_dst;
            if(n)
            {
                t_garray *a;

                for(i=0; i<n; i++)
                {
                    if(iemarray_getfloat(vec_src1, i) < iemarray_getfloat(vec_src2, i))
                        iemarray_setfloat(vec_dst, i, 1.0f);
                    else
                        iemarray_setfloat(vec_dst, i, 0.0f);
                }
                outlet_bang(x->x_obj.ob_outlet);
                a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
                garray_redraw(a);
            }
        }
    }
    else
    {
        post("tab_lt-ERROR: list need 4 float arguments:");
        post("  source1_offset + source2_offset + destination_offset + number_of_samples_to_compare");
    }
}
Example #7
0
static void hdspm_mixer_get_matrix_element(t_hdspm_mixer *x, t_symbol *s, int argc, t_atom *argv)
{
  int col;
  int help_col, src_index, n=x->x_n_src;
  
  if((argc >= 2)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1))
  {
    src_index = (int)atom_getintarg(0, argc, argv) - 1;
  }
}
Example #8
0
static void biquad_freq_resp_list(t_biquad_freq_resp *x, t_symbol *s, int argc, t_atom *argv)
{
  if((argc == 5)&&IS_A_FLOAT(argv,4)&&IS_A_FLOAT(argv,3)&&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,1)&&IS_A_FLOAT(argv,0))
  {
    x->b1 = (float)atom_getfloatarg(0, argc, argv);
    x->b2 = (float)atom_getfloatarg(1, argc, argv);
    x->a0 = (float)atom_getfloatarg(2, argc, argv);
    x->a1 = (float)atom_getfloatarg(3, argc, argv);
    x->a2 = (float)atom_getfloatarg(4, argc, argv);
  }
}
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);
    }
  }
}
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 #11
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 #12
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 #13
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 #14
0
static void cart2del_damp_3d_room_dim(t_cart2del_damp_3d *x, t_symbol *s, int argc, t_atom *argv)
{
  if((argc >= 3)&&IS_A_FLOAT(argv, 0)&&IS_A_FLOAT(argv, 1)&&IS_A_FLOAT(argv, 2))
  {
    x->x_room_x = atom_getfloat(argv++);
    x->x_room_y = atom_getfloat(argv++);
    x->x_room_z = atom_getfloat(argv);
    if(x->x_room_x < 0.5f)
      x->x_room_x = 0.5f;
    if(x->x_room_y < 0.5f)
      x->x_room_y = 0.5f;
    if(x->x_room_z < 0.5f)
      x->x_room_z = 0.5f;
    clock_delay(x->x_clock, 0.0f);
  }
}
Example #15
0
static void *prepend_ascii_new(t_symbol *s, int ac, t_atom *av)
{
  if((ac <= 0) || (!IS_A_FLOAT(av,0)))
  {
    post("ERROR: prepend_ascii need a float between 1 and 255 as 1. arg. !!!");
    return(0);
  }
  else
  {
    t_prepend_ascii *x = (t_prepend_ascii *)pd_new(prepend_ascii_class);
    char str[2];
    int i;
    
    x->x_size = 10 + ac;
    x->x_at = (t_atom *)getbytes(x->x_size * sizeof(t_atom));
    str[0] = (char)((int)(atom_getfloatarg(0,ac,av))&0xff);
    str[1] = 0;
    x->x_sym = gensym(str);
    x->x_ac = ac - 1;
    for(i=1; i<ac; i++)
      x->x_at[i-1] = av[i];
    outlet_new(&x->x_obj, &s_list);
    return (x);
  }
}
Example #16
0
static void *hfadl_scale_new(t_symbol *s, int argc, t_atom *argv)
{
  t_hfadl_scale *x = (t_hfadl_scale *)pd_new(hfadl_scale_class);
  
  if((argc >= 1)&&IS_A_FLOAT(argv,0))
  {
    int j, i = (int)atom_getintarg(0, argc, argv);
    
    if(i >= 0)
    {
      j = iemgui_modulo_color(i);
      x->x_gui.x_lcol = my_iemgui_color_hex[j];
    }
    else
    {
      j = -1 - i;
      x->x_gui.x_lcol = ((j & 0x3f000) << 6)|((j & 0xfc0) << 4)|((j & 0x3f) << 2);
    }
  }
  else
    x->x_gui.x_lcol = 0;
  x->x_gui.x_draw = (t_iemfunptr)hfadl_scale_draw;
  x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
  x->x_gui.x_w = 126;
  x->x_gui.x_h = 21;
  strcpy(x->x_gif, my_iemgui_black_hlscale_gif);
  my_iemgui_change_scale_col(x->x_gif, x->x_gui.x_lcol);
  x->x_gui.x_fsf.x_selected = 0;
  return(x);
}
Example #17
0
void listUnfold_anything(t_listUnfold *x, t_symbol* s, int ac, t_atom* av)
{
	
	
	
	if ( x->mode == 0) {
		
		// Output all
		
		int i =0;
		int offset =0;
		x->iterating = 1;
		 
		if ( s != &s_list && s != &s_float && s != &s_symbol ) {
			outlet_float(x->outlet2,0);
			outlet_symbol(x->outlet1,s);
			offset=1;
		}
				
		for ( ; i < ac && x->iterating; i++ ) {
			outlet_float(x->outlet2,i+offset);
			if ( IS_A_FLOAT(av,0) ) {
				outlet_float(x->outlet1,atom_getfloat(av));
			} else {
				outlet_symbol(x->outlet1,atom_getsymbol(av));
			}
			av++;
		}
  } else {
	  
	  x->iterating = 0;
	  
	    // Copy and wait for bangs to output
	  
	  
	     int do_selector = ( s != &s_list && s != &s_float && s != &s_symbol );
		 x->ac = ac + do_selector; //One more for the selector
		 
		// Resize memory if required and add 3 atoms just in case
		if(x->ac > x->memSize) {	
				x->av = resizebytes(x->av, x->memSize * sizeof(*(x->av)), 
					(3 + x->ac) * sizeof(*(x->av)));
				x->memSize = 3 + x->ac;
		}
		t_atom* dst = x->av; 
		
		// Copy selector
		if ( do_selector ) {
			SETSYMBOL(dst, s);
			dst++;
		}
		// Copy atoms
		while(ac--) *dst++ = *av++;
		
	  
  }
	
}
Example #18
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 #19
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 #20
0
static void iem_vu_set(t_iem_vu *x, t_symbol *s, int ac, t_atom *av)
{
  t_float rms=-100.0f, peak=-100.0f;
  int i;
  
  if( (ac >= 2) && IS_A_FLOAT(av,0) && IS_A_FLOAT(av,1) )
  {
    rms = (t_float)atom_getfloatarg(0, ac, av);
    peak = (t_float)atom_getfloatarg(1, ac, av);
  }
  else if( (ac == 1) && IS_A_FLOAT(av,0) )
  {
    rms = (t_float)atom_getfloatarg(0, ac, av);
    peak = rms;
  }
  if(rms <= IEM_VU_MINDB)
    x->x_rms = 0;
  else if(rms >= IEM_VU_MAXDB)
    x->x_rms = IEM_VU_STEPS;
  else
  {
    int ii = (int)(2.0*(rms + IEM_VU_OFFSET));
    x->x_rms = iem_vu_db2i[ii];
  }
  i = (int)(100.0*rms + 10000.5);
  rms = 0.01*(t_float)(i - 10000);
  x->x_fr = rms;
  
  if(peak <= IEM_VU_MINDB)
    x->x_peak = 0;
  else if(peak >= IEM_VU_MAXDB)
    x->x_peak = IEM_VU_STEPS;
  else
  {
    int ii = (int)(2.0*(peak + IEM_VU_OFFSET));
    x->x_peak = iem_vu_db2i[ii];
  }
  i = (int)(100.0*peak + 10000.5);
  peak = 0.01*(t_float)(i - 10000);
  x->x_fp = peak;
  
  iem_vu_update_rms(x, x->x_gui.x_glist);
  iem_vu_update_peak(x, x->x_gui.x_glist);
}
Example #21
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 #22
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);
}
Example #23
0
static void toggle_mess_bang(t_toggle_mess *x)
{
  int i = x->x_index;

  outlet_float(x->x_out_rght_flt, (t_float)i);
  if(IS_A_FLOAT(x->x_at, i))
    outlet_float(x->x_out_mid_sym, atom_getfloat(&x->x_at[i]));
  else
    outlet_anything(x->x_out_mid_sym, atom_getsymbol(&x->x_at[i]), 0, x->x_at);
  outlet_anything(x->x_obj.ob_outlet, x->x_set, 1, &x->x_at[i]);
}
Example #24
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 #25
0
//static void *argument_new(t_floatarg level)
static void *argument_new(t_symbol *s, int argc, t_atom *argv)
{
    t_argument *x = (t_argument *)pd_new(argument_class);
    
  
    t_canvas *canvas=tof_get_canvas();
    
    x->x_outlet =  outlet_new(&x->x_ob, &s_list);
    //x->x_a = (t_atom *)getbytes(sizeof(t_atom));
  
   x->has_value = 0;
   int i = 0;
  
   // Check argument i and default value
    if ( argc >= 1 && IS_A_FLOAT(argv,0) ) {
    	i = atom_getfloat(argv);
	}
	
	 // Get the canvas' arguments
   int ac;
   t_atom *av;
   tof_get_canvas_arguments(canvas,&ac, &av);
 

   // Check arguments 
   
   if ( i == 0) { //Is the argument index 0?
	 // Get the dollar zero
	  SETSYMBOL(&(x->x_a),tof_get_dollar(canvas,gensym("$0")));
	   x->has_value = 1;
   } else {
	   //if ( ac  >= i  ) {
			if ( argc > 1 ) { //Is there a default argument?
			   //Are the parent and default arguments the same type?
			   if ( ac  >= i && (av+(i-1))->a_type == (argv+1)->a_type) {
				   x->x_a = av[i-1]; //Use the parent value
			   } else {
				   x->x_a = argv[1]; //Use the default value
				}
				x->has_value = 1;
			} else { //No default argument, so no type check
			   if ( ac  >= i ) {  //Are there enough parent arguments?
					x->x_a = av[i-1]; //Use the parent value
					x->has_value = 1;
				}
			}
	        
	   //}
	}

    return (void *)x;
}
Example #26
0
static void *lp1_t_tilde_new(t_symbol *s, int argc, t_atom *argv)
{
  t_lp1_t_tilde *x = (t_lp1_t_tilde *)pd_new(lp1_t_tilde_class);
  int i;
  t_float time_const=0.0f, interpol=0.0f;
  
  inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1"));
  inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft2"));
  outlet_new(&x->x_obj, &s_signal);
  x->x_msi = 0;
  x->counter_t = 1;
  x->delta_t = 0.0f;
  x->interpol_time = 0.0f;
  x->yn1 = 0.0f;
  x->sr = -1.0f / 44.1f;
  if((argc >= 1)&&IS_A_FLOAT(argv,0))
    time_const = (t_float)atom_getfloatarg(0, argc, argv);
  if((argc >= 2)&&IS_A_FLOAT(argv,1))
    interpol = (t_float)atom_getfloatarg(1, argc, argv);
  if(time_const < 0.0f)
    time_const = 0.0f;
  x->cur_t = time_const;
  if(time_const == 0.0f)
    x->c1 = 0.0f;
  else
    x->c1 = exp((x->sr)/time_const);
  x->c0 = 1.0f - x->c1;
  if(interpol < 0.0f)
    interpol = 0.0f;
  x->interpol_time = interpol;
  x->ticks_per_interpol_time = 0.5f;
  i = (int)((x->ticks_per_interpol_time)*(x->interpol_time));
  if(i <= 0)
    i = 1;
  x->ticks = i;
  x->rcp_ticks = 1.0f / (t_float)i;
  x->end_t = x->cur_t;
  return (x);
}
Example #27
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 #28
0
static void iem_event_size(t_iem_event *x, t_symbol *s, int ac, t_atom *av)
{
  int h, w;
  
  if((ac >= 2)&&IS_A_FLOAT(av, 0) && IS_A_FLOAT(av, 1))
  {
    w = (int)atom_getintarg(0, ac, av);
    if(w < 4)
      w = 4;
    x->x_gui.x_w = w;
    if(ac > 1)
    {
      h = (int)atom_getintarg(1, ac, av);
      if(h < 4)
        h = 4;
      x->x_gui.x_h = h;
    }
    (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
    (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW);
    canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
  }
}
Example #29
0
static void *modulo_counter_new(t_symbol *s, int ac, t_atom *av)
{
  t_modulo_counter *x = (t_modulo_counter *)pd_new(modulo_counter_class);
  int max = 1, cur = 0;
  
  if((ac > 0) && IS_A_FLOAT(av, 0))
    max = atom_getintarg(0, ac, av);
  if((ac > 1) && IS_A_FLOAT(av, 1))
    cur = atom_getintarg(1, ac, av);
  if(max < 1)
    x->x_max = 1;
  else
    x->x_max = max;
  if(cur < 0)
    cur = 0;
  if(cur >= x->x_max)
    cur = x->x_max - 1;
  x->x_cur = cur;
  outlet_new(&x->x_obj, &s_float);
  inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1"));
  return (x);
}
Example #30
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);
}