Example #1
0
/*--------------------------------------------------------------------
 * new SIZE
 *--------------------------------------------------------------------*/
static void *weightmap_new(t_floatarg f, t_floatarg max)
{
  t_weightmap *x;
  int i;

  x = (t_weightmap *)pd_new(weightmap_class);

  // create float (index) outlet
  outlet_new(&x->x_obj, &s_float);
  // create list (dump) outlet
  x->x_dumpoutlet = outlet_new(&x->x_obj, &s_list);

  // set number of elements
  x->x_nvalues = f;
  if ( x->x_nvalues < 1 ) x->x_nvalues = 1;

  // set maximum expected input probability
  x->x_wmax = max;
  if (!x->x_wmax) x->x_wmax = DEFAULT_WEIGHT_MAX;

  // allocate weight-vector
  x->x_weights = (t_float *)getbytes(x->x_nvalues*sizeof(t_float));
  if (!x->x_weights) {
    pd_error(x,"weightmap : failed to allocate weight vector");
    return NULL;
  }

  // initialize weights
  for (i = 0; i < x->x_nvalues; i++) {
    *(x->x_weights+i) = DEFAULT_WEIGHT_VALUE;
  }
  // initialize sum
  x->x_wsum = DEFAULT_WEIGHT_VALUE * x->x_nvalues;

#ifdef WEIGHTMAP_DEBUG
  post("weightmap_debug : create : nvalues=%d , wmax=%f", x->x_nvalues, x->x_wmax);
#endif

  return (void *)x;
}
Example #2
0
/*
 * Q.2 - Création d'un nouvel objet scs
 */
void            *scs_tilde_new(int argc, t_atom * argv)
{
	int i  = 0;
	t_scs_tilde *m = (t_scs_tilde *)pd_new(scs_tilde_class);
	m->bypass = 0;
	m->autonorm = 1;
	m->shapeWidth = 1;

	// Si argument present
	switch (argc) {
		// Bypass en argument
		case 2 :
			m->bypass = atom_getint(argv + (1 * sizeof(t_atom)));
		case 1 :
			m->autonorm = atom_getint(argv);
		default :
			break;
	}

	m->x_in2 = inlet_new(&m->x_obj, &m->x_obj.ob_pd,
              &s_signal, &s_signal);
	floatinlet_new(&m->x_obj, &m->shapeWidth);
	m->messages = inlet_new(&m->x_obj,
			  &m->x_obj.ob_pd,
			  gensym("list"),
			  gensym("messages"));


  m->x_out = outlet_new(&m->x_obj, &s_signal);
  m->window = malloc(SIZE * sizeof * m->window);
  m->bitshuffle = malloc(SIZE * 2 * sizeof * m->bitshuffle);
  m->weighting = malloc(SIZE * 2 * sizeof * m->weighting);

  for (i = 0; i<SIZE; i++) {
    m->window[i] = (float) (0.54-0.46*(cos (TWOPI * i/SIZE)));
  }

  init_rdft(SIZE, m->bitshuffle, m->weighting);
  return (void *)m;
}
Example #3
0
static void *fofsynth_new(t_symbol* s,t_float a,t_float b,t_float c,t_float d)
{
     int maxgrains = MAXGRAINS;
     t_fofsynth *x = (t_fofsynth *)pd_new(fofsynth_class);

     x->debug = 0;
     x->x_arrayname = s;

     if (s == &s_)
	  x->x_arrayname = NULL;

     /* setup the grain queue */
     
     x->grainbase = getbytes(sizeof(t_grain)*maxgrains);
     x->maxgrains = maxgrains;
     grain_makecyclic(x->grainbase,maxgrains);
     x->grainstart = x->grainbase;
     x->grainend = x->grainbase;    
     x->numgrains = 0;

     /* some of them could be signals too */

     floatinlet_new(&x->x_obj, &x->formfreq);
     floatinlet_new(&x->x_obj, &x->risedur);
     floatinlet_new(&x->x_obj, &x->falldur);

     x->fundph = 0.0; 
     x->fundfreq = 200.0;
     x->formfreq = 600.0; 
     x->risedur = 5.0; 
     x->falldur = 140.0; 

     if (a) x->fundfreq = a;
     if (b) x->formfreq = b; 
     if (c) x->risedur = c; 
     if (d) x->falldur = d; 

     outlet_new(&x->x_obj, &s_signal);
     return (x);
}
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 #5
0
static void *toggle_mess_new(t_symbol *s, int ac, t_atom *av)
{
  t_toggle_mess *x = (t_toggle_mess *)pd_new(toggle_mess_class);
  int i;

  if(!ac)
  {
    post("toggle_mess-ERROR: must have at least one argument!");
    x->x_at = (t_atom *)0;
    return(0);
  }
  x->x_ac = ac;
  x->x_at = (t_atom *)getbytes(ac * sizeof(t_atom));
  for(i=0; i<ac; i++)
    x->x_at[i] = *av++;
  x->x_index = 0;
  x->x_set = gensym("set");
  outlet_new(&x->x_obj, &s_list);
  x->x_out_mid_sym = outlet_new(&x->x_obj, &s_list);
  x->x_out_rght_flt = outlet_new(&x->x_obj, &s_float);
  return(x);
}
void *residency_buffer_new(t_symbol *msg, short argc, t_atom *argv)
{
	t_residency_buffer *x = (t_residency_buffer *)pd_new(residency_buffer_class);
	t_fftease *fft;

	inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal"));
    inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal"));
	outlet_new(&x->x_obj, gensym("signal"));
    outlet_new(&x->x_obj, gensym("signal"));
    x->size_outlet = outlet_new(&x->x_obj, gensym("float"));
	x->fft = (t_fftease *) calloc(1,sizeof(t_fftease));
	fft = x->fft;
	fft->initialized = 0;
	fft->N = FFTEASE_DEFAULT_FFTSIZE;
	fft->overlap = FFTEASE_DEFAULT_OVERLAP;
	fft->winfac = FFTEASE_DEFAULT_WINFAC;
    if(argc > 0){ x->buffername = atom_getsymbolarg(0, argc, argv); }
    else { post("%s: Must specify array name", OBJECT_NAME); return NULL; }
    if(argc > 1){ fft->N = (int) atom_getfloatarg(1, argc, argv); }
    if(argc > 2){ fft->overlap = (int) atom_getfloatarg(2, argc, argv); }
	return x;
}
Example #7
0
OpPtr OpNew(SymbolPtr msg, AtomCount argc, AtomPtr argv)
{
    OpPtr	self;
	TTValue	v;
	TTErr	err;
	
    self = OpPtr(pd_new(sOpClass));
    if (self) {
 		self->outlet = outlet_new(SELF, gensym("audio.connect"));
		
		v.setSize(2);
		v.set(0, TT("operator"));
		v.set(1, TTUInt32(1));
		err = TTObjectInstantiate(TT("audio.object"), (TTObjectPtr*)&self->audioGraphObject, v);

		if (!self->audioGraphObject->getUnitGenerator()) {
			error("op≈: cannot load Jamoma DSP object");
			return NULL;
		}
	}
	return self;
}
Example #8
0
static void *cd4516_new(t_symbol *s, int argc, t_atom *argv)
{
    t_cd4516           *x;

    x = (t_cd4516 *)pd_new(cd4516_class);
    if (x == NULL) return (x);
    x->x_Q1Out = outlet_new((t_object *)x, &s_float);
    x->x_Q2Out = outlet_new((t_object *)x, &s_float);
    x->x_Q3Out = outlet_new((t_object *)x, &s_float);
    x->x_Q4Out = outlet_new((t_object *)x, &s_float);
    x->x_CarryOut = outlet_new((t_object *)x, &s_float);

    x->x_UpDownIn = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("updown"));
    x->x_ResetIn = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("reset"));
    x->x_PresetEnableIn = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("presetenable"));
    x->x_CarryIn = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("carry"));
    x->x_P1In = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("P1"));
    x->x_P2In = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("P2"));
    x->x_P3In = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("P3"));
    x->x_P4In = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("P4"));
    return (x);
}
Example #9
0
/* The class might have been created by another dll...
   This is public, because apart from the "_patchboard" class above,
   it is called for the "_raftentry" class too.  LATER rethink. */
t_class *patchvalue_classnew(t_symbol *cname, size_t size)
{
    t_class *cls;
    t_symbol *bindsym;
    char buf[MAXPDSTRING];
    sprintf(buf, "#%s", cname->s_name);
    bindsym = gensym(buf);
    if (bindsym->s_thing)
    {
	t_pd *pd = bindsym->s_thing;
	char *name = class_getname(*pd);
	if (strcmp(name, cname->s_name))
	{
	    /* FIXME handle this properly... */
	    loudbug_bug("patchvalue_classnew");
	}
	else return (*pd);
    }
    cls = class_new(cname, 0, 0, size, CLASS_PD | CLASS_NOINLET, 0);
    pd_bind(pd_new(cls), bindsym);  /* never unbound */
    return (cls);
}
Example #10
0
static void *cd4076_new(t_symbol *s, int argc, t_atom *argv)
{
    t_cd4076           *x;

    x = (t_cd4076 *)pd_new(cd4076_class);
    if (x == NULL) return (x);
    x->x_output_A = outlet_new((t_object *)x, &s_float);
    x->x_output_B = outlet_new((t_object *)x, &s_float);
    x->x_output_C = outlet_new((t_object *)x, &s_float);
    x->x_output_D = outlet_new((t_object *)x, &s_float);

    x->x_clear = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("clear"));
    x->x_input_disable_1 = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("inputdisable1"));
    x->x_input_disable_2 = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("inputdisable2"));
    x->x_output_disable_1 = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("outputdisable1"));
    x->x_output_disable_2 = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("outputdisable2"));
    x->x_input_A = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("inputA"));
    x->x_input_B = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("inputB"));
    x->x_input_C = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("inputC"));
    x->x_input_D = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("inputD"));
    return (x);
}
Example #11
0
static void *cd40193_new(t_symbol *s, int argc, t_atom *argv)
{
    t_cd40193           *x;

    x = (t_cd40193 *)pd_new(cd40193_class);
    if (x == NULL) return (x);
    x->x_QAOut = outlet_new((t_object *)x, &s_float);
    x->x_QBOut = outlet_new((t_object *)x, &s_float);
    x->x_QCOut = outlet_new((t_object *)x, &s_float);
    x->x_QDOut = outlet_new((t_object *)x, &s_float);
    x->x_CarryOut = outlet_new((t_object *)x, &s_float);
    x->x_BorrowOut = outlet_new((t_object *)x, &s_float);

    x->x_CountDownIn = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("countdown"));
    x->x_ClearIn = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("clear"));
    x->x_LoadIn = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("load"));
    x->x_DataAIn = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("dataA"));
    x->x_DataBIn = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("dataB"));
    x->x_DataCIn = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("dataC"));
    x->x_DataDIn = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("dataD"));
    return (x);
}
Example #12
0
static void *bangbang_new(t_floatarg val)
{
    t_bangbang *x;
    int i, nouts = (int)val;
    t_outlet **outs;
    if (nouts < BANGBANG_MINOUTS)
	nouts = BANGBANG_DEFOUTS;
    if (nouts > BANGBANG_C74MAXOUTS)
	fittermax_rangewarning(bangbang_class, BANGBANG_C74MAXOUTS, "outlets");
    if (nouts > BANGBANG_DEFOUTS)
    {
	if (!(outs = (t_outlet **)getbytes(nouts * sizeof(*outs))))
	    return (0);
    }
    else outs = 0;
    x = (t_bangbang *)pd_new(bangbang_class);
    x->x_nouts = nouts;
    x->x_outs = (outs ? outs : x->x_outbuf);
    for (i = 0; i < nouts; i++)
	x->x_outs[i] = outlet_new((t_object *)x, &s_bang);
    return (x);
}
Example #13
0
void *presidency_new(t_symbol *s, int argc, t_atom *argv)
{
#if MSP
  t_presidency *x = (t_presidency *)newobject(presidency_class);
  dsp_setup((t_pxobject *)x,4);
  outlet_new((t_pxobject *)x, "signal");
  outlet_new((t_pxobject *)x, "signal");
#endif

#if PD
  t_presidency *x = (t_presidency *)pd_new(presidency_class);
  inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal"));
  inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal"));
  inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal"));
  outlet_new(&x->x_obj, gensym("signal"));
  outlet_new(&x->x_obj, gensym("signal"));
#endif

  x->duration = atom_getfloatarg(0,argc,argv)/1000.0;
  x->lo_freq = atom_getfloatarg(1,argc,argv);
  x->hi_freq = atom_getfloatarg(2,argc,argv);
  x->overlap = atom_getfloatarg(3,argc,argv);
  x->winfac = atom_getfloatarg(4,argc,argv);

  x->D = sys_getblksize();
  x->R = sys_getsr();
  x->vector_size = x->D;

  x->topfreq = 3000.; // default top freq
  if(!x->lo_freq){
	x->lo_freq = 0;
  }
  if(!x->hi_freq)
	x->hi_freq = 4000.0;
	
  presidency_init(x,0);

  return (x);
}
Example #14
0
static void *average_new(t_floatarg f)
{
	int i;

    t_average *x = (t_average *)pd_new(average_class);
	x->x_inindex = inlet_new(&x->x_ob, &x->x_ob.ob_pd, gensym("float"), gensym("index"));
	x->x_outfloat = outlet_new(&x->x_ob, gensym("float"));
	x->x_outtendency = outlet_new(&x->x_ob, gensym("float"));

		/* zeroe out the array */
	for(i = 0; i < MAX_ARG; i++)x->x_input[i] = 0.0;
	x->x_index = (t_int)f;
	if(x->x_index > MAX_ARG)
	{
		x->x_index = MAX_ARG;
		post("average: set number of items to %d", x->x_index);
	}
	x->x_inpointer = 0;
	x->x_average = 0;
	x->x_mode = 0;
    return (void *)x;
}
Example #15
0
static void*freeframe_loader_new(t_symbol*s, int argc, t_atom*argv) {
  if(!s){
    ::verbose(2, "freeframe_loader: no name given");
    return 0;
  }

  ::verbose(2, "freeframe_loader: %s",s->s_name);
  try{	    	    	    	    	    	    	    	\
    Obj_header *obj = new (pd_new(pix_freeframe_class),(void *)NULL) Obj_header;
    char*realname=s->s_name+offset_pix_; /* strip of the leading 'pix_' */
    CPPExtern::m_holder = &obj->pd_obj;
    CPPExtern::m_holdname=s->s_name;
    obj->data = new pix_freeframe(gensym(realname));
    CPPExtern::m_holder = NULL;
    CPPExtern::m_holdname=NULL;
    return(obj);
  } catch (GemException&e) {
    ::verbose(2, "freeframe_loader: failed! (%s)", e.what());
    return 0;
  }
  return 0;
}
Example #16
0
File: date.c Project: Tzero2/pd
static void *date_new(t_symbol *s, int argc, t_atom *argv)
{
  t_date *x = (t_date *)pd_new(date_class);
  char buf[5];
  ZEXY_USEVAR(s);
 
  x->GMT=0;
  if (argc) {
    atom_string(argv, buf, 5);
    if (buf[0]=='G' && buf[1]=='M' && buf[2]=='T')
      x->GMT = 1;
  }
  
  x->x_outlet1 = outlet_new(&x->x_obj, &s_float);
  x->x_outlet2 = outlet_new(&x->x_obj, &s_float);
  x->x_outlet3 = outlet_new(&x->x_obj, &s_float);
  x->x_outlet4 = outlet_new(&x->x_obj, &s_float);
  x->x_outlet5 = outlet_new(&x->x_obj, &s_float);
  x->x_outlet6 = outlet_new(&x->x_obj, &s_float);
  
  return (x);
}
Example #17
0
void *morph_tilde_new(t_symbol *s, int argc, t_atom *argv){

float sr;
float morpha, morphfr; 
int i; 
t_morph_tilde *x = (t_morph_tilde *) pd_new(morph_tilde_class);
sr = sys_getsr();

switch (argc) {
case 1:
morpha = (atom_getfloat(&argv[0]));
morphfr = 0.f;
break;
case 2:
morpha = (atom_getfloat(&argv[0]));
morphfr = (atom_getfloat(&argv[1]));
break;
default:
morpha = morphfr = 0.f;
}

morpha = morpha < 1 ? (morpha > 0 ? morpha : 0.f)
						: 1.f; 
morphfr = morphfr < 1 ? (morphfr > 0 ? morphfr : 0.f)
						: 1.f; 
inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("frequency factor"));
inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("amplitude factor"));

x->window = new HammingTable(1024, 0.5);
x->inobj1 = new SndObj(0, DEF_VECSIZE, sr);
x->inobj2 = new SndObj(0, DEF_VECSIZE, sr);
x->spec1 = new PVA(x->window, x->inobj1, .5f, DEF_FFTSIZE, DEF_VECSIZE, sr);
x->spec2 = new PVA(x->window, x->inobj2, .5f, DEF_FFTSIZE, DEF_VECSIZE, sr);
x->morph = new PVMorph(morphfr, morpha, x->spec1, x->spec2, 0,0,DEF_FFTSIZE, sr);
x->synth = new PVS(x->window, x->morph, DEF_FFTSIZE, DEF_VECSIZE, sr);
outlet_new(&x->x_obj, &s_signal);
return (void *) x;
}
Example #18
0
static void *route_new(t_symbol *s, int argc, t_atom *argv)
{
    int n, flt = 0, sym = 0;
    t_routeelement *e;
    t_route *x = (t_route *)pd_new(route_class);
    t_atom a;
    if (argc == 0)
    {
        argc = 1;
        SETFLOAT(&a, 0);
        argv = &a;
    }
	x->x_type = argv[0].a_type;
    x->x_nelement = argc;
    x->x_vec = (t_routeelement *)getbytes(argc * sizeof(*x->x_vec));
    for (n = 0, e = x->x_vec; n < argc; n++, e++)
    {
        e->e_outlet = outlet_new(&x->x_obj, &s_list);
        if (argv[n].a_type == A_FLOAT) {
            e->e_w.w_float = atom_getfloatarg(n, argc, argv);
			flt = 1;
		} else {
			e->e_w.w_symbol = atom_getsymbolarg(n, argc, argv);
			sym = 1;
		}
    }
    if (argc == 1)
    {
		route_proxy_init(&x->x_pxy, x);
		inlet_new(&x->x_obj, &x->x_pxy.l_pd, 0, 0);
        /*if (argv->a_type == A_FLOAT)
            floatinlet_new(&x->x_obj, &x->x_vec->e_w.w_float);
		else
			symbolinlet_new(&x->x_obj, &x->x_vec->e_w.w_symbol);*/
    }
	x->x_mixed = flt * sym;
    x->x_rejectout = outlet_new(&x->x_obj, &s_list);
    return (x);
}
Example #19
0
void *mlogistic_new(t_symbol *s, int argc, t_atom *argv) {
	mlogistic_struct *mlogistic = (mlogistic_struct *) pd_new(mlogistic_class);
	if (mlogistic != NULL) {
		outlet_new(&mlogistic -> x_obj, &s_float);
		mlogistic -> search_outlet = outlet_new(&mlogistic -> x_obj, &s_list);
		mlogistic -> vars_outlet = outlet_new(&mlogistic -> x_obj, &s_list);
		mlogistic -> params_outlet = outlet_new(&mlogistic -> x_obj, &s_list);
		if (argc == M_param_count + M_var_count) {
			mlogistic -> vars_init[M_x] = mlogistic -> vars[M_x] = (double) atom_getfloatarg(0, argc, argv);
			mlogistic -> c = (double) atom_getfloatarg(1, argc, argv);
		} else {
			if (argc != 0 && argc != M_param_count + M_var_count) {
				post("Incorrect number of arguments for mlogistic fractal. Expecting 2 arguments.");
			}
			mlogistic -> vars_init[M_x] = 0.1;
			mlogistic -> c = 4;
		}
		constrain(mlogistic, NULL, 0, NULL);
		lyap(mlogistic, -1000000.0, 1000000.0, M_failure_limit);
	}
	return (void *)mlogistic;
}
Example #20
0
static void *early_reflections_3d_new(t_floatarg fn_src)
{
  int i, n;
  t_early_reflections_3d *x = (t_early_reflections_3d *)pd_new(early_reflections_3d_class);
  
  n = (int)fn_src;
  if(n < 1)
    n = 1;
  if(n > 30)
    n = 30;
  x->x_n_src = n;
  x->x_room_x = 12.0f;
  x->x_room_y = 8.0f;
  x->x_room_z = 4.0f;
  x->x_head_x = 0.0f;
  x->x_head_y = 0.0f;
  x->x_head_z = 1.7f;
  for(i=0; i<n; i++)
  {
    x->x_src_x[i] = 3.0f;
    x->x_src_y[i] = 0.5f;
    x->x_src_z[i] = 2.5f;
  }
  x->x_r_ambi = 1.4f;
  x->x_speed = 340.0f;
  
  x->x_s_del0 = gensym("del0");
  x->x_s_del1 = gensym("del1");
  x->x_s_del2 = gensym("del2");
  x->x_s_damp = gensym("damp");
  x->x_s_index_delta_phi = gensym("index_delta_phi");
  x->x_s_bundle = gensym("bundle");
  x->x_direct_out = outlet_new(&x->x_obj, &s_list);
  x->x_early_out = outlet_new(&x->x_obj, &s_list);
  x->x_rev_out = outlet_new(&x->x_obj, &s_list);
  x->x_180_over_pi  = (t_float)(180.0 / (4.0 * atan(1.0)));
  x->x_bundle = 0;
  return (x);
}
Example #21
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 #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 *mtx_resize_new(t_symbol *s, int argc, t_atom *argv)
{
    t_matrix *x = (t_matrix *)pd_new(mtx_resize_class);
    int c=0, r=0;

    if(argc) {
        if(argc-1) {
            r=atom_getfloat(argv);
            c=atom_getfloat(argv+1);
        } else r=c=atom_getfloat(argv);
        if(c<0)c=0;
        if(r<0)r=0;
    }
    inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym(""));
    outlet_new(&x->x_obj, 0);
    x->current_row = r;
    x->current_col = c;
    x->row = x->col= 0;
    x->atombuffer  = 0;

    return (x);
}
Example #24
0
static t_object *dummy_newobject(t_symbol *s, t_dummy_slot **slotp)
{
    t_object *x;
    t_dummy_slot *sl;
    int fnd;
    for (fnd = 0; fnd < dummy_nclasses; fnd++)
	/* LATER compare symbols, rather than strings */
	if (dummy_classes[fnd]  /* empty slot: abstraction replacement */
	    && !strcmp(class_getname(dummy_classes[fnd]), s->s_name))
	    break;
    x = (t_object *)pd_new(dummy_classes[fnd]);
    sl = &dummy_slots[fnd];
    if (fnd == dummy_nclasses)
	loudbug_bug("dummy_newobject");  /* create a "_dummy" in this case */
    else if (!sl->s_warned)
    {
	loud_warning((t_pd *)x, 0, "dummy substitution");
	sl->s_warned = 1;
    }
    if (slotp) *slotp = sl;
    return (x);
}
Example #25
0
static void *canvasdollarzero_new(t_floatarg f)
{
  t_canvasdollarzero *x = (t_canvasdollarzero *)pd_new(canvasdollarzero_class);

  t_glist *glist=(t_glist *)canvas_getcurrent();
  t_canvas *canvas=(t_canvas*)glist_getcanvas(glist);
  int depth=(int)f;

  if(depth<0)depth=0;
  while(depth && canvas) {
    canvas=canvas->gl_owner;
    depth--;
  }

  x->s_dollzero=0;
  if(canvas) {
    x->s_dollzero = canvas_realizedollar(canvas, gensym("$0"));
  }

  outlet_new(&x->x_obj, &s_symbol);
  return (x);
}
Example #26
0
static void *forpp_new(t_floatarg beg, t_floatarg end, t_floatarg delay)
{
  t_forpp *x = (t_forpp *)pd_new(forpp_class);
  
  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_float);
  x->x_out_end = outlet_new(&x->x_obj, &s_bang);
  x->x_clock = clock_new(x, (t_method)forpp_tick);
  x->x_clock2 = clock_new(x, (t_method)forpp_tick2);
  x->x_beg = (int)beg;
  x->x_end = (int)end;
  if(x->x_end < x->x_beg)
    x->x_incr = -1;
  else
    x->x_incr = 1;
  if(delay < 0.0)
    delay = 0.0;
  x->x_delay = delay;
  x->x_cur = x->x_beg;
  return(x);
}
Example #27
0
void gfxstub_new(t_pd *owner, void *key, const char *cmd)
{
    char buf[4*MAXPDSTRING];
    char namebuf[80];
    char sprintfbuf[MAXPDSTRING];
    char *afterpercent;
    t_int afterpercentlen;
    t_gfxstub *x;
    t_symbol *s;
        /* if any exists with matching key, burn it. */
    for (x = gfxstub_list; x; x = x->x_next)
        if (x->x_key == key)
            gfxstub_deleteforkey(key);
    if (strlen(cmd) + 50 > 4*MAXPDSTRING)
    {
        bug("audio dialog too long");
        bug("%s", cmd);
        return;
    }
    x = (t_gfxstub *)pd_new(gfxstub_class);
    sprintf(namebuf, ".gfxstub%lx", (t_int)x);

    s = gensym(namebuf);
    pd_bind(&x->x_pd, s);
    x->x_owner = owner;
    x->x_sym = s;
    x->x_key = key;
    x->x_next = gfxstub_list;
    gfxstub_list = x;
    /* only replace first %s so sprintf() doesn't crash */
    afterpercent = strchr(cmd, '%') + 2;
    afterpercentlen = afterpercent - cmd;
    strncpy(sprintfbuf, cmd, afterpercentlen);
    sprintfbuf[afterpercentlen] = '\0';
    sprintf(buf, sprintfbuf, s->s_name);
    strncat(buf, afterpercent, (4*MAXPDSTRING) - afterpercentlen);
    sys_gui(buf);
}
Example #28
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 #29
0
static void *zeroCrossing_tilde_new(t_symbol *s, int argc, t_atom *argv)
{
    t_zeroCrossing_tilde *x = (t_zeroCrossing_tilde *)pd_new(zeroCrossing_tilde_class);
	int i;
	
	x->x_crossings = outlet_new(&x->x_obj, &s_float);
	s=s;
	
	x->signal_R = (t_sample *)getbytes(0);

	if(argc > 0)
	{
		x->window = atom_getfloat(argv);
		
		if(x->window < 64)
		{
			error("minimum window size is 64 samples.");
			x->window = 64;
		};
	}
	else
		x->window = 1024;	
	
	
	x->sr = 44100.0;
	x->n = 64.0;
	x->overlap = 1;
	x->last_dsp_time = clock_getlogicaltime();

	x->signal_R = (t_sample *)t_resizebytes(x->signal_R, 0, (x->window+x->n) * sizeof(t_sample));

 	for(i=0; i<(x->window+x->n); i++)
		x->signal_R[i] = 0.0;
		
    post("zeroCrossing~: window size: %i", (int)x->window);
    
    return (x);
}
Example #30
0
static void *oggread_new(t_floatarg fdographics)
{
    t_oggread *x = NULL;
    
    x = (t_oggread *)pd_new(oggread_class);
    outlet_new(&x->x_obj, gensym("signal"));
    outlet_new(&x->x_obj, gensym("signal"));
    x->x_out_position = outlet_new(&x->x_obj, gensym("float"));
    
    
    x->x_out_end      = outlet_new(&x->x_obj, gensym("bang"));
	x->x_clock = clock_new(x, (t_method)oggread_tick);
    
    x->x_fd = -1;
	x->x_eos = 1;
    x->x_stream = 0;
	x->x_position = 0;
    x->x_samplerate = sys_getsr();
    
    x->x_outbuffersize = OUTPUT_BUFFER_SIZE;
    x->x_outbuffer = (t_float*) getbytes(OUTPUT_BUFFER_SIZE*sizeof(t_float));
    
    if(!x->x_outbuffer)
    {
		post( "oggread~: could not allocate buffer" );
		return NULL;
    }
    memset(x->x_outbuffer, 0x0, OUTPUT_BUFFER_SIZE);
    
    x->x_outreadposition = 0;
    x->x_outwriteposition = 0;
    x->x_outunread = 0;
	x->x_decoded = 0;
    
    post(oggread_version);
    
    return (x);
}