Example #1
0
t_mouse *mouse_new(void)
{
	t_mouse *mouse  = (t_mouse *)malloc(sizeof(t_mouse));

	mouse->button_left=button_released;
	mouse->button_right=button_released;
	mouse->button_middle=button_released;
	mouse->wheel=wheel_idle;

	mouse->x=0;
	mouse->y=0;
	mouse->delta_x=0;
	mouse->delta_y=0;
	mouse->last_x=0;
	mouse->last_y=0;
	mouse->dx=0;
	mouse->dy=0;
	mouse->is_moving=0;
	mouse->button_left_is_ready=1;
	mouse->sign_x=0;
	mouse->sign_y=0;
	mouse->clic_clock=clock_new();
	mouse->release_clock=clock_new();
	mouse->dbclic=0;
	mouse->lgclic=0;

	return mouse;
}
Example #2
0
 PIMPL(GemWindow*gc) : parent(gc),
                       mycontext(0),
                       infoOut(0), rejectOut(0),
                       dispatchClock(0),
                       dispatchTime(10.),
                       qClock(0)
 {
   qClock=clock_new(this, reinterpret_cast<t_method>(qCallBack));
   dispatchClock=clock_new(this, reinterpret_cast<t_method>(dispatchCallBack));
 }
void *simpleNeuron_new(t_symbol *s, long argc, t_atom *argv)
{
	t_simpleNeuron *x = NULL;
    long i;

	// object instantiation
	if (x = (t_simpleNeuron *)object_alloc(simpleNeuron_class)) {
        object_post((t_object *)x, "a new %s object was instantiated: 0x%X", s->s_name, x);
        object_post((t_object *)x, "it has %ld arguments", argc);
		x = (t_simpleNeuron *)object_alloc(simpleNeuron_class);
		x->m_outlet1 = bangout((t_simpleNeuron *)x);
		x->m_clock1 = clock_new((t_simpleNeuron *)x, (method)delayedReset);
		x->m_clock2 = clock_new((t_simpleNeuron *)x, (method)leak);
		x->m_clock3 = clock_new((t_simpleNeuron *)x, (method)delayedBang);
        
        for (i = 0; i < argc; i++) {
            if ((argv + i)->a_type == A_LONG) {
                object_post((t_object *)x, "arg %ld: long (%ld)", i, atom_getlong(argv+i));
            } else if ((argv + i)->a_type == A_FLOAT) {
                object_post((t_object *)x, "arg %ld: float (%f)", i, atom_getfloat(argv+i));
            } else if ((argv + i)->a_type == A_SYM) {
                object_post((t_object *)x, "arg %ld: symbol (%s)", i, atom_getsym(argv+i)->s_name);
            } else {
                object_error((t_object *)x, "forbidden argument");
            }
        }
	}
	
	// default settings
	
	x->d_V = 0;
	x->d_Vth = 5;
	x->d_C = 1;
	x->d_R = 100;
	
	// Fitzhugh
	x->d_W = 0;
	x->d_Wth = 1.5;
	x->d_Wr  = 1.3;
	x->d_a = -0.7;  // http://www.scholarpedia.org/article/FitzHugh-Nagumo_model
	x->d_b = 0.8;
	x->d_tao = 12.5;
	x->d_stepSize = 0.3; // this needs to be
	x->l_bangFlag = 0;
	
	x->l_mode = 0;
	x->l_ref = 0;
	
	x->d_absRef = 100;
	x->d_leakPer = 100;
	x->d_bangD = 10;
	
	return (x);
}
/* \param qu determines whether timed messages should be queued (low priority - only when supported by the system).
*/
flext::Timer::Timer(bool qu):
    queued(qu),
    clss(NULL),userdata(NULL),
    period(0)
{
#if FLEXT_SYS == FLEXT_SYS_PD
    clk = (t_clock *)clock_new(this,(t_method)callback);
#elif FLEXT_SYS == FLEXT_SYS_MAX
    clk = (t_clock *)clock_new(this,(t_method)callback);
    if(queued) qelem = (t_qelem *)qelem_new(this,(method)queuefun);
#else
    #error Not implemented
#endif
}
Example #5
0
void *hoa_space_new(t_symbol *s, int argc, t_atom *argv)
{
    t_hoa_space *x = NULL;
    t_binbuf *d;
	long flags;
    
    if (!(d = binbuf_via_atoms(argc, argv)))
		return NULL;
    
    x = (t_hoa_space *)eobj_new(hoa_space_class);
    x->f_viewer                 = new AmbisonicViewer(1);
    x->f_recomposer             = new AmbisonicRecomposer(1, 4);
    
    x->f_out                    = listout(x);
    x->f_number_of_microphones  = 4;
    x->f_new_number             = 4;
    x->f_defer                  = clock_new(x, (t_method)hoa_space_do_channels_set);

    flags = 0
    | EBOX_GROWLINK
    ;
    ebox_new((t_ebox *)x, flags);
    
    
    ebox_attrprocess_viabinbuf(x, d);
    ebox_ready((t_ebox *)x);
    return (x);
}
Example #6
0
void *breakpoints_new(t_symbol *s, int argc, t_atom *argv)
{
    t_binbuf* d = binbuf_via_atoms(argc,argv);
	t_breakpoints *x = (t_breakpoints *)eobj_new(breakpoints_class);
    if(x && d)
    {
        x->f_outline_mode = 0;
        long flags = 0
        | EBOX_GROWINDI
        ;
        ebox_new((t_ebox *)x, flags);
        
        x->f_out_float = (t_outlet *)floatout(x);
        x->f_out_list = (t_outlet *)listout(x);
        x->f_out_function = (t_outlet *)listout(x);
        
        x->f_number_of_points = 0;
        x->f_point_hover    = -1;
        x->f_point_selected = -1;
        x->f_output_inc     = -1;
        x->f_output_nextprev = 0;
        x->f_point_last_created = -1;
        x->f_mouse.x = -666666;
        x->f_mouse.y = -666666;
        
        x->f_clock = clock_new(x, (t_method)breakpoints_inc);
        
        ebox_attrprocess_viabinbuf(x, d);
        breakpoints_init(x, d);
        ebox_ready((t_ebox *)x);
    }
    
    return (x);
}
Example #7
0
void *phasorshot_new(t_symbol *s,int argc,t_atom* argv)
{
    t_phasorshot *x = (t_phasorshot *)pd_new(phasorshot_class);
    
    x->x_f = 0;
    if (argc) x->x_f = atom_getfloat(argv++),argc--;
    
    inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1"));
    
    x->x_phase = 0;
    x->x_conv = 0;
   
    outlet_new(&x->x_obj, gensym("signal"));
    
    inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("loop"));
    x->loop = 0;
    
    if (argc) x->loop = atom_getfloat(argv++),argc--;
     
     x->state = 0;
    
    x->x_outlet1 = outlet_new(&x->x_obj, &s_bang);
    x->x_outlet2 = outlet_new(&x->x_obj, &s_bang);
    
    x->x_clock = clock_new(x, (t_method)phasorshot_tick);

    
    return (x);
}
Example #8
0
static void *env_tilde_new(t_floatarg fnpoints, t_floatarg fperiod)
{
    int npoints = fnpoints;
    int period = fperiod;
    t_sigenv *x;
    t_sample *buf;
    int i;

    if (npoints < 1) npoints = 1024;
    if (period < 1) period = npoints/2;
    if (period < npoints / MAXOVERLAP + 1)
        period = npoints / MAXOVERLAP + 1;
    if (!(buf = getbytes(sizeof(t_sample) * (npoints + INITVSTAKEN))))
    {
        error("env: couldn't allocate buffer");
        return (0);
    }
    x = (t_sigenv *)pd_new(env_tilde_class);
    x->x_buf = buf;
    x->x_npoints = npoints;
    x->x_phase = 0;
    x->x_period = period;
    for (i = 0; i < MAXOVERLAP; i++) x->x_sumbuf[i] = 0;
    for (i = 0; i < npoints; i++)
        buf[i] = (1. - cos((2 * 3.14159 * i) / npoints))/npoints;
    for (; i < npoints+INITVSTAKEN; i++) buf[i] = 0;
    x->x_clock = clock_new(x, (t_method)env_tilde_tick);
    x->x_outlet = outlet_new(&x->x_obj, gensym("float"));
    x->x_f = 0;
    x->x_allocforvs = INITVSTAKEN;
    return (x);
}
Example #9
0
static void *pvu_tilde_new(t_floatarg metro_time, t_floatarg release_time, t_floatarg threshold)
{
  t_pvu_tilde *x;
  t_float t;
  
  x = (t_pvu_tilde *)pd_new(pvu_tilde_class);
  if(metro_time <= 0.0f)
    metro_time = 300.0f;
  if(metro_time <= 5.0f)
    metro_time = 5.0f;
  if(release_time <= 0.0f)
    release_time = 300.0f;
  if(release_time <= 5.0f)
    release_time = 5.0f;
  if(threshold == 0.0f)
    threshold = -0.01f;
  x->x_threshold_over = threshold;
  x->x_overflow_counter = 0;
  x->x_metro_time = metro_time;
  x->x_release_time = release_time;
  x->x_c1 = exp(-metro_time/release_time);
  x->x_cur_peak = 0.0f;
  x->x_old_peak = 0.0f;
  x->x_clock = clock_new(x, (t_method)pvu_tilde_tick);
  x->x_outlet_meter = outlet_new(&x->x_obj, &s_float);/* left */
  x->x_outlet_over = outlet_new(&x->x_obj, &s_float); /* right */
  x->x_started = 1;
  x->x_float_sig_in = 0.0f;
  return(x);
}
Example #10
0
void *meter_new(t_symbol *s, int argc, t_atom *argv)
{
	t_meter *x =  NULL;
	t_binbuf* d;
    long flags;
	if (!(d = binbuf_via_atoms(argc,argv)))
		return NULL;
    
	x = (t_meter *)eobj_new(meter_class);
    
    flags = 0
    | EBOX_GROWINDI
    | EBOX_IGNORELOCKCLICK
    ;
    
	ebox_new((t_ebox *)x, flags);
    eobj_dspsetup((t_ebox *)x, 1, 0);
    
    x->f_direction      = 0;
    x->f_peaks_outlet   = floatout(x);
    x->f_peak_value     = -90.;
    x->f_clock          = clock_new(x,(t_method)meter_tick);
	x->f_startclock     = 0;
    x->f_over_led_preserved = 0;
    ebox_attrprocess_viabinbuf(x, d);
	ebox_ready((t_ebox *)x);
    
	return (x);
}
void *hoa_scope_3D_new(t_symbol *s, int argc, t_atom *argv)
{
	t_hoa_scope_3D *x =  NULL;
	t_binbuf *d;
	long flags;
	
	if (!(d = binbuf_via_atoms(argc, argv)))
		return NULL;

	x = (t_hoa_scope_3D *)eobj_new(hoa_scope_3D_class);
    
    x->f_order      = 1;
	x->f_startclock = 0;
	x->f_scope      = new Hoa3D::Scope(x->f_order, NUMBEROFCIRCLEPOINTS_UI2 * 0.5, NUMBEROFCIRCLEPOINTS_UI2);
    x->f_order      = x->f_scope->getDecompositionOrder();
    x->f_signals    = new t_float[x->f_scope->getNumberOfHarmonics() * SYS_MAXBLKSIZE];
    x->f_index      = 0;
    
    eobj_dspsetup(x, x->f_scope->getNumberOfHarmonics(), 0);
    
	flags = 0
    | EBOX_IGNORELOCKCLICK
    | EBOX_GROWLINK
    ;
	ebox_new((t_ebox *)x, flags);
    
    x->f_clock = clock_new(x,(t_method)hoa_scope_3D_tick);
	x->f_startclock = 0;
    
    ebox_attrprocess_viabinbuf(x, d);
	ebox_ready((t_ebox *)x);
	
	return (x);
}
Example #12
0
static void *bang_tilde_new(t_symbol *s)
{
    t_bang *x = (t_bang *)pd_new(bang_tilde_class);
    x->x_clock = clock_new(x, (t_method)bang_tilde_tick);
    outlet_new(&x->x_obj, &s_bang);
    return (x);
}
Example #13
0
void GemMan :: createContext(char* disp)
{
  // can we only have one context?

  t_atom*a=GemSettings::get("window.singlecontext"); // find a better name!
  if(a) {
    int i=atom_getint(a);
    if(1==i)
      s_singleContext = 1;
      /*
      m_width = 640;
      m_height = 480;
      */
  }

  s_windowClock = clock_new(NULL, reinterpret_cast<t_method>(GemMan::dispatchWinmessCallback));
  if (!m_windowContext && !createConstWindow(disp))
    {
      error("GEM: A serious error occured creating const Context");
      error("GEM: Continue at your own risk!");
      m_windowContext = 0;
    } else 
    m_windowContext = 1;
  setResizeCallback(GemMan::resizeCallback, NULL);
}
Example #14
0
static void *abl_link_tilde_new(t_symbol *s, int argc, t_atom *argv) {
    t_abl_link_tilde *x = (t_abl_link_tilde *)pd_new(abl_link_tilde_class);
    x->clock = clock_new(x, (t_method)abl_link_tilde_tick);
    x->step_out = outlet_new(&x->obj, &s_float);
    x->phase_out = outlet_new(&x->obj, &s_float);
    x->beat_out = outlet_new(&x->obj, &s_float);
    x->steps_per_beat = 1;
    x->prev_beat_time = 0;
    x->quantum = ABLLinkGetQuantum(libpdLinkRef);
    x->tempo = 0;
    switch (argc) {
        default:
            post("abl_link~: Unexpected number of creation args: %d", argc);
        case 4:
            if (ABLLinkIsConnected(libpdLinkRef)) {
                post("abl_link~: Ignoring tempo parameter because Link is connected.");
            } else {
                x->tempo = atom_getfloat(argv + 3);
            }
        case 3:
            x->quantum = atom_getfloat(argv + 2);
        case 2:
            x->prev_beat_time = atom_getfloat(argv + 1);
        case 1:
            x->steps_per_beat = atom_getfloat(argv);
        case 0:
            break;
    }
    return x;
}
Example #15
0
static void *rawin_new(t_symbol *spipe, t_symbol *type)
{
    t_rawin *x;

    pdp_post("%s %s", spipe->s_name, type->s_name);

    /* allocate & init */
    x = (t_rawin *)pd_new(rawin_class);
    x->x_outlet = outlet_new(&x->x_obj, &s_anything);
    x->x_sync_outlet = outlet_new(&x->x_obj, &s_anything);
    x->x_clock = clock_new(x, (t_method)rawin_tick);
    x->x_queue = pdp_list_new(0);
    x->x_active = 0;
    x->x_giveup = 0;
    x->x_mode = 0;
    x->x_type = pdp_gensym("image/YCrCb/320x240"); //default
    x->x_pipe = gensym("/tmp/pdpraw"); // default
    pthread_attr_init(&x->x_attr);
    pthread_mutex_init(&x->x_mut, NULL);
    clock_delay(x->x_clock, PERIOD);

    /* args */
    rawin_type(x, type);
    if (spipe->s_name[0]) x->x_pipe = spipe; 

    return (void *)x;

}
Example #16
0
void *LJ_IOIn_new(t_symbol *s, int argc, t_atom *argv)
{
	t_LJ_IOIn *x;	
	x = (t_LJ_IOIn *)pd_new(LJ_IOIn_class);
	int i;
	
	// outlets
	x->nb_ports = argc;
	for (i = 0; (i < argc) && (i < 4); i++) {
		x->io[i] = outlet_new(&x->p_ob, &s_float);
		x->ports[i] = atom_getfloat(argv+i);
	}

	x->err = outlet_new(&x->p_ob, &s_bang);

	// a clock to update outputs 
  	x->x_clock = clock_new(x, (t_method) LJ_IOIn_update);

	// setting up thread and semaphores
	sem_init (&x->busy, 0, 1);
	sem_init (&x->go, 0, 0);
	sem_init (&x->acquired, 0, 1);

	LJ_IOIn_thread_start(x);

	return x; 
}
Example #17
0
static void *cart2del_damp_3d_new(t_symbol *s, int argc, t_atom *argv)
{
  t_cart2del_damp_3d *x = (t_cart2del_damp_3d *)pd_new(cart2del_damp_3d_class);
  
  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;
  x->x_src_x = 3.0f;
  x->x_src_y = 0.5f;
  x->x_src_z = 2.5f;
  x->x_r_ambi = 1.4f;
  x->x_speed = 340.0f;
  x->x_s_direct = gensym("direct");
  x->x_s_early1 = gensym("early1");
  x->x_s_early2 = gensym("early2");
  x->x_s_del = gensym("del");
  x->x_s_damp = gensym("damp");
  x->x_s_index_theta_phi = gensym("index_theta_phi");
  outlet_new(&x->x_obj, &s_list);
  x->x_clock = clock_new(x, (t_method)cart2del_damp_3d_doit);
  x->x_180_over_pi  = (t_float)(180.0 / (4.0 * atan(1.0)));
  return (x);
}
void *hoa_meter_new(t_symbol *s, int argc, t_atom *argv)
{
	t_hoa_meter *x =  NULL;
	t_binbuf *d;
	long flags;
	
	if (!(d = binbuf_via_atoms(argc, argv)))
		return NULL;
    
	x = (t_hoa_meter *)eobj_new(hoa_meter_class);
    
    x->f_ramp = 0;
    x->f_meter  = new Hoa2D::Meter(4);
    x->f_vector = new Hoa2D::Vector(4);
    x->f_signals = new t_float[MAX_SPEAKER * SYS_MAXBLKSIZE];
    x->f_over_leds = new int[MAX_CHANNELS];
    
    x->f_clock = clock_new(x,(t_method)hoa_meter_tick);
	x->f_startclock = 0;
    eobj_dspsetup((t_ebox *)x, x->f_meter->getNumberOfChannels(), 0);
    
    flags = 0
    | EBOX_GROWLINK
    | EBOX_IGNORELOCKCLICK
    ;
	ebox_new((t_ebox *)x, flags);
    
    hoa_meter_deprecated(x, s, argc, argv);
	ebox_attrprocess_viabinbuf(x, d);
    
	ebox_ready((t_ebox *)x);
	return (x);
}
Example #19
0
File: xeq.c Project: pure-data/xeq
static void xeq_newbase(t_xeq *x, t_binbuf *bb, t_method tickmethod)
{
    xeq_window_bind(x);
    x->x_tempo = 1;
    x->x_canvas = canvas_getcurrent();
    x->x_whenclockset = 0;
    x->x_clockdelay = 0;
    x->x_clock = tickmethod ? clock_new(x, tickmethod) : 0;
    xeq_noteons_clear(x);
    x->x_ttp = 0;
    x->x_transpo = 0;
    x->x_autoit.i_owner = x;
    x->x_stepit.i_owner = x;
    x->x_walkit.i_owner = x;
    xeq_setbinbuf(x, bb);
    xeqit_sethooks(&x->x_autoit, xeqithook_autodelay, xeqithook_applypp,
		   xeqithook_playmessage, xeqithook_playfinish,
		   xeqithook_loopover);
    xeqit_sethooks(&x->x_stepit, xeqithook_stepdelay, xeqithook_applypp,
		   xeqithook_playmessage, xeqithook_stepfinish, 0);
    xeqit_sethooks(&x->x_walkit, 0, 0, 0, 0, 0);
    xeqit_rewind(&x->x_autoit);
    xeqit_rewind(&x->x_stepit);
    xeqit_rewind(&x->x_walkit);
}
Example #20
0
static void *udpclient_new(void)
{
  int i;

  t_udpclient *x = (t_udpclient *)pd_new(udpclient_class);
  x->x_msgout = outlet_new(&x->x_obj, 0);	/* received data */
  x->x_addrout = outlet_new(&x->x_obj, gensym("list"));
  x->x_connectout = outlet_new(&x->x_obj, gensym("float"));	/* connection state */
  x->x_statusout = outlet_new(&x->x_obj, 0);/* last outlet for everything else */

  x->x_fd = -1;
  x->x_addr = 0L;
  x->x_port = 0;

  x->x_sender=NULL;
  x->x_receiver=NULL;

  x->x_clock = clock_new(x, (t_method)udpclient_tick);

  x->x_floatlist=iemnet__floatlist_create(1024);

  /* prepare child thread */
  if(pthread_attr_init(&x->x_threadattr) < 0)
    verbose(1, "[%s] warning: could not prepare child thread", objName);
  if(pthread_attr_setdetachstate(&x->x_threadattr, PTHREAD_CREATE_DETACHED) < 0)
    verbose(1, "[%s] warning: could not prepare child thread", objName);
    

  return (x);
}
Example #21
0
void *number_tilde_new(t_symbol *s, int argc, t_atom *argv)
{
	t_number_tilde *x =  NULL;
	t_binbuf* d;
    long flags;

	if (!(d = binbuf_via_atoms(argc,argv)))
		return NULL;

	x = (t_number_tilde *)eobj_new(number_tilde_class);

    flags = 0
    | EBOX_GROWINDI
    | EBOX_IGNORELOCKCLICK
    ;

	ebox_new((t_ebox *)x, flags);

	eobj_dspsetup((t_ebox *)x, 1, 1);

    x->f_peaks_outlet   = floatout(x);
    x->f_peak_value     = 0.;
    x->f_clock          = clock_new(x,(t_method)number_tilde_tick);
	x->f_startclock     = 0;

	ebox_attrprocess_viabinbuf(x, d);
	ebox_ready((t_ebox *)x);

	return (x);
}
Example #22
0
File: rvu~.c Project: IcaroL2ORK/pd
static void *rvu_tilde_new(t_floatarg metro_time, t_floatarg release_time)
{
  t_rvu_tilde *x=(t_rvu_tilde *)pd_new(rvu_tilde_class);
  
  if(metro_time <= 0.0f)
    metro_time = 300.0f;
  if(metro_time <= 5.0f)
    metro_time = 5.0f;
  if(release_time <= 0.0f)
    release_time = 300.0f;
  if(release_time <= 5.0f)
    release_time = 5.0f;
  x->x_metro_time = metro_time;
  x->x_release_time = release_time;
  x->x_c1 = exp(-2.0f*x->x_metro_time/x->x_release_time);
  x->x_sum_rms = 0.0f;
  x->x_old_rms = 0.0f;
  x->x_sr = 44.1f;
  x->x_rcp = 1.0f/(x->x_sr*x->x_metro_time);
  x->x_clock_metro = clock_new(x, (t_method)rvu_tilde_tick_metro);
  x->x_started = 1;
  outlet_new(&x->x_obj, &s_float);
  x->x_msi = 0.0f;
  return(x);
}
Example #23
0
static void *scope_new(t_symbol *s, int argc, t_atom *argv)
{
    t_scope *x =  NULL;
    t_binbuf* d;
    long flags;
    if (!(d = binbuf_via_atoms(argc,argv)))
        return NULL;

    x = (t_scope *)eobj_new(cscope_class);
    if(x)
    {
        flags = 0
                | EBOX_GROWINDI
                | EBOX_IGNORELOCKCLICK
                ;

        ebox_new((t_ebox *)x, flags);
        eobj_dspsetup((t_ebox *)x, 2, 0);

        x->f_buffer_x = (t_sample *)calloc(80192, sizeof(t_sample));
        x->f_buffer_y = (t_sample *)calloc(80192, sizeof(t_sample));

        x->f_mode     = 0;
        x->f_index    = 0;

        x->f_clock          = clock_new(x,(t_method)scope_tick);
        x->f_startclock     = 0;

        ebox_attrprocess_viabinbuf(x, d);
        ebox_ready((t_ebox *)x);
    }
    return (x);
}
//----------------------------------------------------------------------------------------------------------------
// object creation
void *udmx_new(t_symbol *s, long argc, t_atom *argv)	{
    

    t_atom *ap;
    t_int16 n;
    n = 0;
    
 
    // n = int argument typed into object box (A_DEFLONG) -- defaults to 0 if no args are typed
    
    t_udmx *x = (t_udmx *)object_alloc(udmx_class);
    intin(x,1);					// create a second int inlet (leftmost inlet is automatic - all objects have one inlet by default)
    x->m_clock = clock_new(x,(method)udmx_tick); 	// make new clock for polling and attach tick function to it
    x->m_qelem = qelem_new((t_object *)x, (method)find_device);
    
    x->msgOutlet = outlet_new(x,0L);	//create right outlet
    x->statusOutlet = outlet_new(x,0L);	//create an outlet for connected flag
    
    x->correct_adressing = 1;
    
    if (argc) {
        ap = argv;
        switch (atom_gettype(ap)) {
            case A_LONG:
                n = atom_getlong(ap);
                break;
            default:
                break;
        }
        ap = &argv[argc-1];
        
        switch (atom_gettype(ap)) {
            case A_LONG:
                if (atom_getlong(ap) == 0 ) {
                    x->correct_adressing = 0;
                }
                break;
            default:
                break;
        }
     }
    if(x->correct_adressing) {n = n - 1;}
    if (n < 0) n = 0;
    if (n > 511) n = 511;

    x->channel = n;
    x->debug_flag = 0;
    x->channel_changed_min = 512;
    x->channel_changed_max = -1;
    x->clock_running = 0;
    x->dev_handle = NULL;
    x->speedlim = SPEED_LIMIT;
    x->usb_devices_seen = -1;

    
    clock_fdelay(x->m_clock,100);
    usb_init();
    
    return(x);					// return a reference to the object instance
}
Example #25
0
// Create
void *out_new(t_symbol *s, long argc, t_atom *argv)
{
	long 		attrstart = attr_args_offset(argc, argv);		// support normal arguments
	t_out 		*x = (t_out *)object_alloc(out_class);
	short 		i;

	if(x){
		x->dumpout = outlet_new(x, NULL);
		object_obex_store((void *)x, jps_dumpout, (object *)x->dumpout);		// setup the dumpout

		x->numOutputs =  1;
		x->attr_preview = 0;
		x->preview_object = NULL;
		x->attr_bypass = 0;
		x->attr_mute = 0;
		x->attr_mix = 100;										// Assume 100%, so that processed signal is passed through if @has_mix is false
		if(attrstart > 0){
			int argument = atom_getlong(argv);
			x->numOutputs = TTClip(argument, 1, MAX_NUM_CHANNELS);
		}
#ifdef JCOM_OUT_TILDE
		if(x->numOutputs > 0)
			dsp_setup((t_pxobject *)x, x->numOutputs);		// Create Object and Inlets
		else
			dsp_setup((t_pxobject *)x, 1);					// Create Object and Inlets
			
		x->common.ob.z_misc = Z_NO_INPLACE | Z_PUT_LAST;	// Z_PUT_LAST so that thispoly~ gets it's message properly?  		
		for(i=0; i < (x->numOutputs); i++)
			outlet_new((t_pxobject *)x, "signal");			// Create a signal Outlet   		

		x->clock = clock_new(x, (method)update_meters);
		x->clock_is_set = 0;
		TTObjectInstantiate(kTTSym_audiosignal, &x->audioIn, x->numOutputs);
		TTObjectInstantiate(kTTSym_audiosignal, &x->audioOut, x->numOutputs);
		TTObjectInstantiate(kTTSym_audiosignal, &x->audioTemp, x->numOutputs);
		TTObjectInstantiate(kTTSym_audiosignal, &x->zeroSignal, x->numOutputs);
		
		TTObjectInstantiate(TT("crossfade"), &x->xfade, x->numOutputs);
		x->xfade->setAttributeValue(TT("position"), 1.0);
		TTObjectInstantiate(TT("gain"), &x->gain, x->numOutputs);
		TTObjectInstantiate(TT("ramp"), &x->ramp_gain, x->numOutputs);
		TTObjectInstantiate(TT("ramp"), &x->ramp_xfade, x->numOutputs);

//		out_alloc(x, sys_getblksize());						// allocates the vectors for the audio signals
		x->gain->setAttributeValue(TT("linearGain"), 1.0);
#else
		for(i=x->numOutputs-1; i >= 1; i--)
			x->inlet[i] = proxy_new(x, i, 0L);
		for(i=x->numOutputs-1; i >= 0; i--)
			x->outlet[i] = outlet_new(x, 0L);
#endif		
		jcom_core_subscriber_new_common(&x->common, jps__jcom_out__, jps_subscribe_out);
		jcom_core_subscriber_setcustomsubscribe_method(&x->common, &out_subscribe);
		
		attr_args_process(x, argc, argv);					// handle attribute args				
		jcom_core_subscriber_subscribe((t_jcom_core_subscriber_common*)x);
	}
	return (x);												// Return the pointer
}
Example #26
0
void *hoa_space_new(t_symbol *s, int argc, t_atom *argv)
{
    t_hoa_space *x = NULL;
    t_dictionary *d;
	long flags;
    long defc;
    t_atom *defv;
    x = (t_hoa_space *)object_alloc(hoa_space_class);
    if (x)
    {
        if (!(d = object_dictionaryarg(argc,argv)))
            return NULL;
        flags = 0
            | JBOX_DRAWFIRSTIN
            | JBOX_DRAWINLAST
            | JBOX_TRANSPARENT
            | JBOX_GROWY
            | JBOX_DRAWBACKGROUND
        ;
        
        jbox_new((t_jbox *)x, 1, argc, argv);
        
        x->j_box.b_firstin = (t_object *)x;
        
        
        
        x->f_viewer                 = new AmbisonicViewer(1);
        x->f_recomposer             = new AmbisonicRecomposer(1, 4);
        x->f_out                    = listout(x);
        x->f_number_of_microphones  = 4;
        x->f_new_number             = 4;
        
        x->f_defer             = clock_new(x, (t_method)hoa_space_do_channels_set);
        
        attr_dictionary_process(x, d);
        
        binbuf_copy_atoms(d, gensym("@channels"), &defc, &defv);
        if(defc && defv)
        {
            x->f_new_number = Tools::clip(long(atom_getlong(defv)), (long)3, (long)MAX_CHANNELS);
            hoa_space_do_channels_set(x);
            defc = 0;
            free(defv);
            defv = NULL;
        }
        binbuf_copy_atoms(d, gensym("@coeffs"), &defc, &defv);
        if(defc && defv)
        {
            hoa_space_coefficients_set(x, NULL, defc, defv);
            defc = 0;
            free(defv);
            defv = NULL;
        }
        
        jbox_ready((t_jbox *)x);
    }
    return (x);
}
Example #27
0
void *hoa_meter_new(t_symbol *s, long argc, t_atom *argv)
{
	t_hoa_meter *x    = NULL;
 	t_dictionary *d = NULL;
	long flags;
    
	if (!(d = object_dictionaryarg(argc,argv)))
		return NULL;
    
	x = (t_hoa_meter *)object_alloc(hoa_meter_class);
	flags = 0
    | JBOX_DRAWFIRSTIN
    | JBOX_NODRAWBOX
    | JBOX_DRAWINLAST
    | JBOX_TRANSPARENT
    | JBOX_GROWY
    | JBOX_DRAWBACKGROUND
    ;
    
	jbox_new((t_jbox *)x, flags, argc, argv);
    x->j_box.j_box.z_box.b_firstin = (t_object *)x;
    
    dictionary_getlong(d, gensym("loudspeakers"), (t_atom_long *)&x->f_number_of_loudspeakers);
    x->f_meter      = new Hoa3D::Meter(x->f_number_of_loudspeakers, 100, 199);
    x->f_number_of_loudspeakers      = x->f_meter->getNumberOfLoudspeakers();
    x->f_signals    = new double[x->f_meter->getNumberOfLoudspeakers() * SYS_MAXBLKSIZE];
    x->f_clock      = clock_new((void *)x, (method)hoa_meter_tick);
    x->f_startclock = 0;
    x->f_number_of_leds = 13;
    x->f_leds_coordinates = new double***[100];

    double azimuth, elevation, radius;
    for(int i = 0; i < 100; i++)
    {
        elevation = (double)i / 100. * CICM_PI - CICM_PI2;
        x->f_leds_coordinates[i] = new double**[199];
        for(int j = 0; j < 199; j++)
        {
            azimuth = (double)j / 199. * CICM_2PI;
            x->f_leds_coordinates[i][j] = new double*[x->f_number_of_leds];
            for(int k = 0; k < x->f_number_of_leds; k++)
            {
                radius = (k + 1) / (double)x->f_number_of_leds;
                x->f_leds_coordinates[i][j][k] = new double[3];
                x->f_leds_coordinates[i][j][k][0] = Hoa3D::abscissa(radius, azimuth, elevation);
                x->f_leds_coordinates[i][j][k][1] = Hoa3D::ordinate(radius, azimuth, elevation);
                x->f_leds_coordinates[i][j][k][2] = Hoa3D::height(radius, azimuth, elevation);
            }
        }
    }
    
    dsp_setupjbox((t_pxjbox *)x, x->f_meter->getNumberOfLoudspeakers());
	jucebox_new((t_jucebox *) x);
    
	attr_dictionary_process(x,d);
	jbox_ready((t_jbox *)x);
	return x;
}
Example #28
0
static void pipe_list(t_pipe *x, t_symbol *s, int ac, t_atom *av)
{
    t_hang *h = (t_hang *)
                getbytes(sizeof(*h) + (x->x_n - 1) * sizeof(*h->h_vec));
    t_gpointer *gp, *gp2;
    t_pipeout *p;
    int i, n = x->x_n;
    t_atom *ap;
    t_word *w;
    h->h_gp = (t_gpointer *)getbytes(x->x_nptr * sizeof(t_gpointer));
    if (ac > n)
    {
        if (av[n].a_type == A_FLOAT)
            x->x_deltime = av[n].a_w.w_float;
        else pd_error(x, "pipe: symbol or pointer in time inlet");
        ac = n;
    }
    for (i = 0, gp = x->x_gp, p = x->x_vec, ap = av; i < ac;
            i++, p++, ap++)
    {
        switch (p->p_atom.a_type)
        {
        case A_FLOAT:
            p->p_atom.a_w.w_float = atom_getfloat(ap);
            break;
        case A_SYMBOL:
            p->p_atom.a_w.w_symbol = atom_getsymbol(ap);
            break;
        case A_POINTER:
            gpointer_unset(gp);
            if (ap->a_type != A_POINTER)
                pd_error(x, "pipe: bad pointer");
            else
            {
                *gp = *(ap->a_w.w_gpointer);
                if (gp->gp_stub) gp->gp_stub->gs_refcount++;
            }
            gp++;
        }
    }
    for (i = 0, gp = x->x_gp, gp2 = h->h_gp, p = x->x_vec, w = h->h_vec;
            i < n; i++, p++, w++)
    {
        if (p->p_atom.a_type == A_POINTER)
        {
            if (gp->gp_stub) gp->gp_stub->gs_refcount++;
            w->w_gpointer = gp2;
            *gp2++ = *gp++;
        }
        else *w = p->p_atom.a_w;
    }
    h->h_next = x->x_hang;
    x->x_hang = h;
    h->h_owner = x;
    h->h_clock = clock_new(h, (t_method)hang_tick);
    clock_delay(h->h_clock, (x->x_deltime >= 0 ? x->x_deltime : 0));
}
Example #29
0
static void *tabwrite_tilde_new(t_symbol *s)
{
    t_tabwrite_tilde *x = (t_tabwrite_tilde *)pd_new(tabwrite_tilde_class);
    x->x_clock = clock_new(x, (t_method)tabwrite_tilde_tick);
    x->x_phase = 0x7fffffff;
    x->x_arrayname = s;
    x->x_f = 0;
    return (x);
}
static void *delay_new(t_floatarg f)
{
    t_delay *x = (t_delay *)pd_new(delay_class);
    delay_ft1(x, f);
    x->x_clock = clock_new(x, (t_method)delay_tick);
    outlet_new(&x->x_obj, gensym("bang"));
    inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1"));
    return (x);
}