Esempio n. 1
0
void *connect_new(t_symbol *s, long argc, t_atom *argv)
{
	t_connect *x = NULL;

	x = (t_connect *)object_alloc((t_class *)connect_class);
	if (x)
	{	
		x->f_harmonics = 4;
		x->f_output = 4;
		if(atom_gettype(argv) == A_LONG)
			x->f_harmonics	= atom_getlong(argv) * 2 +1;
		if(atom_gettype(argv+1) == A_LONG)
			x->f_output	= atom_getlong(argv+1);
		else 
			x->f_output = x->f_harmonics;
		
		// colors setup
		x->f_colorPositiv.red = x->f_colorPositiv.alpha = 1.;
		x->f_colorPositiv.green = x->f_colorPositiv.blue = 0.;
		x->f_colorNegativ.blue = x->f_colorNegativ.alpha = 1.;
		x->f_colorNegativ.green = x->f_colorNegativ.red = 0.;
		x->f_colorPlane.red = x->f_colorPlane.green = x->f_colorPlane.blue = x->f_colorPlane.alpha = 1.;
		
		//object_obex_lookup(x, gensym("#P"), &x->f_patcher); // passé dans la fonction connect_attach
		defer_low(x, (method)connect_attach, NULL, 0, NULL);
		
		//attr_args_process(x, argc, argv);
		x->f_nbSelected = 0;
	}
	
	return x;
}	
Esempio n. 2
0
void *f0ext_new(t_symbol *s, long argc, t_atom *argv) {
	t_f0ext *x= (t_f0ext *)object_alloc(f0ext_class);
	if(x) {
        x->valLeft= 0.0;
        x->valOut= 0.0;
        x->valMiddle= 120.0;
        x->valRight= 20.0;
        t_atom *ap;
        ap= argv;
        ap++;
        if(argc>2) {post("warning: f0.beats_to_frames %d extra argument(s)", argc-2);}
        switch(MIN(argc, 2)) {
            case 2:
                if(atom_gettype(ap)==A_FLOAT) {
                    x->valRight= (double)atom_getfloat(ap);
                } else if(atom_gettype(ap)==A_LONG) {
                    x->valRight= (double)atom_getlong(ap);
                }
            case 1:
                ap--;
                if(atom_gettype(ap)==A_FLOAT) {
                    x->valMiddle= (double)atom_getfloat(ap);
                } else if(atom_gettype(ap)==A_LONG) {
                    x->valMiddle= (double)atom_getlong(ap);
                }
        }
        floatin(x, 2);
        floatin(x, 1);
        x->out= floatout(x);
    }
	return (x);
}
Esempio n. 3
0
	void send(long inlet, t_symbol *s, long ac, t_atom *av) {
		if(ac==1)
		{
			//post("inlet %ld int %ld", inlet, ac);
			unsigned char value = atom_getlong(av);
			//post("value is %ld", value);
			message.push_back(value);
			if(is_valid_message(&message))
			{
				if(midiout && midiout->isPortOpen()) {
					midiout->sendMessage( &message );
				}
				message.clear();
			}

		}
		else
		{
			message.clear();
			for (int i=0; i<ac; i++) {
				unsigned char value = atom_getlong(av+i);
				message.push_back(value);
			}
			
			if(midiout && midiout->isPortOpen()) {
				midiout->sendMessage( &message );
				
			}
			message.clear();
		}
    }
Esempio n. 4
0
File: lorenz.c Progetto: mzed/lorenz
void *lorenz_new(t_symbol *s, long argc, t_atom *argv)
{
    t_lorenz *x;
    x = (t_lorenz *)object_alloc(lorenz_class);
    x->l_xyz[0]= x->l_xyz[1] = x->l_xyz[2] = 0.6;
    x->l_h = 0.01;
    if (argc) {
        for (int i = 0; i < argc; ++i) {
            if (i < 3) {
                if ((argv+i)->a_type == A_FLOAT) {
                    x->l_xyz[i] = (double)atom_getfloat(argv+i);
                } else if ((argv+i)->a_type == A_LONG) {
                    x->l_xyz[i] = (double)atom_getlong(argv+i);
                }
            }
        }
        if (argc > 3){
            if (argv[3].a_type == A_FLOAT) {
                x->l_h = atom_getfloat(argv+3);
            } else if (argv[3].a_type == A_LONG) {
                x->l_h = (float)atom_getlong(argv+3);
            }
        }
    }
    
    floatin(x,3);
	floatin(x,2);
	floatin(x,1);
	
	x->l_out2 = floatout(x);
	x->l_out1 = floatout(x);
	x->l_out0 = floatout(x);
	
    return (x);
}
t_pd_err vectors_set(t_hoa_meter *x, void *attr, long argc, t_atom *argv)
{
    if(argc && argv)
    {
        if(atom_gettype(argv) == A_SYM)
        {
            if(atom_getsym(argv) == hoa_sym_energy)
                x->f_vector_type = hoa_sym_energy;
            else if(atom_getsym(argv) == hoa_sym_velocity)
                x->f_vector_type = hoa_sym_velocity;
            else if(atom_getsym(argv) == hoa_sym_both)
                x->f_vector_type = hoa_sym_both;
            else
                x->f_vector_type = hoa_sym_none;
        }
        else if(atom_gettype(argv) == A_FLOAT)
        {
            if(atom_getlong(argv) == 1)
                x->f_vector_type = hoa_sym_energy;
            else if(atom_getlong(argv) == 2)
                x->f_vector_type = hoa_sym_velocity;
            else if(atom_getlong(argv) == 3)
                x->f_vector_type = hoa_sym_both;
            else
                x->f_vector_type = hoa_sym_none;
        }
        ebox_invalidate_layer((t_ebox *)x, hoa_sym_vector_layer);
    }
    return 0;
}
Esempio n. 6
0
t_max_err coefficients_set(t_space *x, void *attr, long ac, t_atom *av)
{
    if (ac >= 1 && atom_getfloat(av) == 666.)
    {
        for (int i = 0; i < x->f_number_of_microphones; i++)
		{
                x->f_microphonesValues[i] = 0.;
        }
        
    }
    else if (ac && av)
    {
        if(atom_gettype(av) == A_FLOAT)
        {
            if(x->f_mode == 0)
            {
                for (int i = 0; i < ac && i < MAX_MICS; i++)
                {
                    if(atom_gettype(av+i) == A_FLOAT)
                        x->f_microphonesValues[i] = Tools::clip((double)atom_getfloat(av + i), 0., 1.);
                }
                
            }
            else if(x->f_mode == 2)
            {
                double max = 1.;
                double min = 0.;
                for (int i = 0; i < ac && i < MAX_MICS; i++)
                {
                    if(atom_getfloat(av + i) > max)
                        max = atom_getfloat(av + i);
                    if(atom_getfloat(av + i) < min)
                        min = atom_getfloat(av + i);
                }
                for (int i = 0; i < ac && i < MAX_MICS; i++)
                {
                    if(atom_gettype(av+i) == A_FLOAT)
                        x->f_microphonesValues[i] = atom_getfloat(av + i) - (max - 1.) - min;
                }
            }
            else
            {
                for (int i = 0; i < ac && i < MAX_MICS; i++)
                {   
                    x->f_microphonesValues[i] = atom_getfloat(av + i);
                }
            }
            
        }
        else if (atom_gettype(av) == A_LONG && ac >= 2)
        {
            if(atom_gettype(av+1) == A_FLOAT && atom_getlong(av) < x->f_number_of_microphones)
                x->f_microphonesValues[atom_getlong(av)] = Tools::clip((double)atom_getfloat(av+1), 0., 1.);
        }
    }
   
    if (x->f_number_of_microphones_initialized ==  true)
        space_compute(x);
    return 0;
}
Esempio n. 7
0
void *HoaStereo_new(t_symbol *s, long argc, t_atom *argv)
{
	t_HoaStereo *x = NULL;
	int order = 4;
	double anAngle1 = 60.;
	if (x = (t_HoaStereo *)object_alloc((t_class*)HoaStereo_class)) 
	{
		if(atom_gettype(argv) == A_LONG)
			order	= atom_getlong(argv);
		
		if(atom_gettype(argv+1) == A_LONG)
			anAngle1	= atom_getlong(argv+1);
		else if(atom_gettype(argv+1) == A_FLOAT)
			anAngle1	= atom_getfloat(argv+1);
		
		x->f_AmbisonicStereo	= new AmbisonicStereo(order, anAngle1, sys_getblksize());
		
		dsp_setup((t_pxobject *)x, x->f_AmbisonicStereo->getNumberOfInputs());
		for (int i = 0; i < x->f_AmbisonicStereo->getNumberOfOutputs(); i++) 
			outlet_new(x, "signal");
		
		x->f_ob.z_misc = Z_NO_INPLACE;
	}
	return (x);
}
Esempio n. 8
0
void hoa_map_3D_tilde_list(t_hoa_map_3D_tilde *x, t_symbol* s, long argc, t_atom* argv)
{
    if(argc > 2 && argv && atom_gettype(argv) == A_LONG && atom_gettype(argv+1) == A_SYM)
    {
        int index = atom_getlong(argv);
        if(index < 1 || index > x->f_map->getNumberOfSources())
            return;
        
        if(argc > 4 && (atom_getsym(argv+1) == hoa_sym_polar || atom_getsym(argv+1) == hoa_sym_pol))
        {
            x->f_lines->setRadius(index-1, atom_getfloat(argv+2));
            x->f_lines->setAzimuth(index-1, atom_getfloat(argv+3));
            x->f_lines->setElevation(index-1, atom_getfloat(argv+4));
        }
        else if(argc > 4 && (atom_getsym(argv+1) == hoa_sym_cartesian || atom_getsym(argv+1) == hoa_sym_car))
        {
            x->f_lines->setRadius(index-1, radius(atom_getfloat(argv+2), atom_getfloat(argv+3), atom_getfloat(argv+4)));
            x->f_lines->setAzimuth(index-1, azimuth(atom_getfloat(argv+2), atom_getfloat(argv+3), atom_getfloat(argv+4)));
            x->f_lines->setElevation(index-1, elevation(atom_getfloat(argv+2), atom_getfloat(argv+3), atom_getfloat(argv+4)));
        }
        else if(argc > 2 && atom_getsym(argv+1) == hoa_sym_mute)
        {
            x->f_map->setMute(index-1, atom_getlong(argv+2));
        }
    }
}
Esempio n. 9
0
void *HoaSevenDotOne_new(t_symbol *s, long argc, t_atom *argv)
{
	t_HoaSevenDotOne *x = NULL;
	int order = 4;
	double anAngle1 = 30.;
	double anAngle2 = 110.;
	if (x = (t_HoaSevenDotOne *)object_alloc((t_class*)HoaSevenDotOne_class)) 
	{
		if(atom_gettype(argv) == A_LONG)
			order	= atom_getlong(argv);
		if(atom_gettype(argv+1) == A_LONG)
			anAngle1	= atom_getlong(argv+1);
		else if(atom_gettype(argv+1) == A_FLOAT)
			anAngle1	= atom_getfloat(argv+1);
		if(atom_gettype(argv+2) == A_LONG)
			anAngle2	= atom_getlong(argv+2);
		else if(atom_gettype(argv+2) == A_FLOAT)
			anAngle2	= atom_getfloat(argv+2);

		x->f_AmbisonicSixDotOne	= new AmbisonicSixDotOne(order, anAngle1, anAngle2, sys_getblksize());
		
		dsp_setup((t_pxobject *)x, x->f_AmbisonicSixDotOne->getNumberOfInputs());
		for (int i = 0; i < x->f_AmbisonicSixDotOne->getNumberOfOutputs(); i++) 
			outlet_new(x, "signal");
		
	
	}
	return (x);
}
Esempio n. 10
0
void CLASSMETHOD(ClipMode)(IMPORT_T, t_symbol *s, long argc, t_atom *argv)
{
  if (argc != 3) {
    post("Clip Led messages must have 3 parts: column - row - mode");
    return;
  }

  int row, column;
  CLIP_LED cl = CL_INVALID;

  if (atom_gettype(argv) == A_LONG) {
    column = (int)atom_getlong(argv);
  }
  else {
    post("First argument is not an integer.");
    return;
  }

  if (atom_gettype(argv + 1) == A_LONG) {
    row = (int)atom_getlong(argv + 1);
  }
  else {
    post("Second argument is not an integer.");
    return;
  }

  if (row < 1 || row > CLIPROWS || column < 1 || column > CLIPCOLUMNS) {
    post("Element is not in range.");
    return;
  }

  // set array offset
  row--; column--;

  if (atom_gettype(argv + 2) == A_LONG) {
    int mode = (int)atom_getlong(argv + 2);
    switch (mode) {
      case 0: T->memory.setClipMode(column, row, CM_OFF); break;
      case 1: T->memory.setClipMode(column, row, CM_SINGLE_ORANGE_GREEN); break;
      case 2: T->memory.setClipMode(column, row, CM_SINGLE_ORANGE_RED); break;
      case 3: T->memory.setClipMode(column, row, CM_TOGGLE_ORANGE_GREEN); break;
      case 4: T->memory.setClipMode(column, row, CM_TOGGLE_ORANGE_RED); break;
      case 5: T->memory.setClipMode(column, row, CM_CUSTOM); break;
      default: {
        post("Third argument is not a valid integer");
        return;
      }
    }

  }
  else {
    post("Third argument is not an integer");
    return;
  }

  // send led color to apc
  {
    CLASSMETHOD(SendNoteOn)(T, column + 1, row + 53, (int)T->memory.getClipLed(column, row));
  }
}
Esempio n. 11
0
t_max_err number_of_microphones_set(t_space *x, t_object *attr, long argc, t_atom *argv)
{
    if(atom_gettype(argv) == A_LONG)
	{
		if(atom_getlong(argv) != x->f_number_of_microphones)
		{
			delete x->f_viewer;
            delete x->f_recomposer;
            
            x->f_number_of_microphones = Tools::clip(atom_getlong(argv), (long)3, (long)MAX_MICS);
            if(x->f_number_of_microphones % 2 == 0)
                x->f_order              = (x->f_number_of_microphones - 2) / 2;
            else
                 x->f_order             = (x->f_number_of_microphones - 1) / 2;
            x->f_number_of_harmonics    = x->f_order * 2 + 1;
            
			x->f_viewer         = new AmbisonicViewer(x->f_order);
            x->f_recomposer		= new ambisonicRecomposer(x->f_order, x->f_number_of_microphones);
            

            jbox_invalidate_layer((t_object*)x, NULL, gensym("background_layer"));
            space_compute(x);
		}
	}
	return 0;
}
Esempio n. 12
0
void *hoa_map_new(t_symbol *s, long argc, t_atom *argv)
{
	t_hoa_map *x = NULL;
	int	order = 1;
    int numberOfSources = 1;
    x = (t_hoa_map *)object_alloc(hoa_map_class);
	if (x)
	{		
		if(atom_gettype(argv) == A_LONG)
			order = atom_getlong(argv);
        if(argc > 1 && atom_gettype(argv+1) == A_LONG)
            numberOfSources = atom_getlong(argv+1);

		x->f_map = new Hoa3D::Map(order, numberOfSources);
		if(x->f_map->getNumberOfSources() == 1)
            dsp_setup((t_pxobject *)x, 4);
        else
            dsp_setup((t_pxobject *)x, x->f_map->getNumberOfSources());
		
		for (int i = 0; i < x->f_map->getNumberOfHarmonics(); i++)
			outlet_new(x, "signal");
        
        if(x->f_map->getNumberOfSources() == 1)
            x->f_sig_ins    =  new double[4 * SYS_MAXBLKSIZE];
        else
            x->f_sig_ins    =  new double[x->f_map->getNumberOfSources() * SYS_MAXBLKSIZE];
        x->f_sig_outs   =  new double[x->f_map->getNumberOfHarmonics() * SYS_MAXBLKSIZE];
	}
    
	return (x);
}
Esempio n. 13
0
void tralala_mouseHitZone(t_tll *x)
{
    long argc, k = TLL_SELECTED;
    t_atom *argv = NULL;
    long position = TLL_X_TO_POSITION(x->cursor.x);
    long pitch = TLL_Y_TO_PITCH(x->cursor.y);
    
    TLL_DATA_LOCK
    
    if (!(dictionary_getatoms(x->current, TLL_SYM_ZONE, &argc, &argv))) {
        if (position < atom_getlong(argv + 1)) { 
            k = TLL_SELECTED_START;
        } else if (position > atom_getlong(argv + 2)) { 
            k = TLL_SELECTED_END;
        } else if (pitch < atom_getlong(argv + 3)) { 
            k = TLL_SELECTED_DOWN;
        } else if (pitch > atom_getlong(argv + 4)) { 
            k = TLL_SELECTED_UP;
        } 
    }
    
    dictionary_appendlong(x->status, TLL_SYM_ZONE, k);
    
    TLL_DATA_UNLOCK
}
Esempio n. 14
0
void *HoaRecomposer_new(t_symbol *s, long argc, t_atom *argv)
{
	t_HoaRecomposer *x = NULL;
    t_dictionary *d;
	int order = 4, inputs = 10;
    x = (t_HoaRecomposer *)object_alloc((t_class*)HoaRecomposer_class);
	if (x)
	{
		if(atom_gettype(argv) == A_LONG)
			order	= atom_getlong(argv);
		if(atom_gettype(argv+1) == A_LONG)
			inputs	= atom_getlong(argv+1);
        
        /* Base Attributes */
        
		x->f_ambiRecomposer	= new AmbisonicRecomposer(order, inputs, Hoa_Fixe, sys_getblksize(), sys_getsr());
        x->f_ambiRecomposer->setRampInMs(20.);
        
        x->f_ramp_time = x->f_ambiRecomposer->getRampInMs();
        x->f_mode = gensym("fixe");
        
		dsp_setup((t_pxobject *)x, x->f_ambiRecomposer->getNumberOfInputs());
		for (int i = 0; i < x->f_ambiRecomposer->getNumberOfOutputs(); i++)
			outlet_new(x, "signal");
        
		x->f_ob.z_misc = Z_NO_INPLACE;
        
        attr_args_process(x, argc, argv);
        d = (t_dictionary *)gensym("#D")->s_thing;
        if (d) attr_dictionary_process(x, d);
        object_attr_setdisabled((t_object *)x, gensym("ramp"), (x->f_mode == gensym("fixe")) ? 1 : 0);
	}
	return (x);
}
void *hoa_projector_new(t_symbol *s, long argc, t_atom *argv)
{
	// @arg 0 @name ambisonic-order @optional 0 @type int @digest The ambisonic order of decomposition
	// @description First argument is the ambisonic order of decomposition.
	
	// @arg 1 @name number-of-channels @optional 0 @type int @digest The number of channels
	// @description Second argument sets the number of channels.
	
	t_hoa_projector *x = NULL;
	int	order = 1;
    int numberOfLoudspeakers = 4;
    x = (t_hoa_projector *)object_alloc(hoa_projector_class);
	if (x)
	{		
		if(atom_gettype(argv) == A_LONG)
			order = atom_getlong(argv);
		if(order < 1)
            order = 1;
        if(atom_gettype(argv+1) == A_LONG)
			numberOfLoudspeakers = atom_getlong(argv+1);
        if(numberOfLoudspeakers < order * 2 + 1)
            numberOfLoudspeakers = order * 2 + 1;
		
		x->f_projector = new Hoa2D::Projector(order, numberOfLoudspeakers);
		
		dsp_setup((t_pxobject *)x, x->f_projector->getNumberOfHarmonics());
		for (int i = 0; i < x->f_projector->getNumberOfChannels(); i++)
			outlet_new(x, "signal");
        
		x->f_ins = new double[x->f_projector->getNumberOfHarmonics() * SYS_MAXBLKSIZE];
        x->f_outs = new double[x->f_projector->getNumberOfChannels() * SYS_MAXBLKSIZE];
	}

	return (x);
}
Esempio n. 16
0
t_max_err number_of_microphones_set(t_space *x, t_object *attr, long argc, t_atom *argv)
{
    if(atom_gettype(argv) == A_LONG)
	{
		if(atom_getlong(argv) != x->f_number_of_microphones || x->f_number_of_microphones_initialized == false)
		{
			delete x->f_viewer;
            delete x->f_recomposer;
            
            x->f_number_of_microphones = atom_getlong(argv);

            x->f_number_of_microphones = Tools::clip_min(x->f_number_of_microphones, (long)3);
            if(x->f_number_of_microphones % 2 == 0)
                x->f_order              = (x->f_number_of_microphones - 2) / 2;
            else
                 x->f_order             = (x->f_number_of_microphones - 1) / 2;
            x->f_number_of_harmonics    = x->f_order * 2 + 1;
            			
			x->f_viewer         = new AmbisonicViewer(x->f_order);
            x->f_recomposer		= new ambisonicRecomposer(x->f_order, x->f_number_of_microphones);
            
            if(x->f_number_of_microphones_initialized == false)
                x->f_number_of_microphones_initialized = true;
            jbox_invalidate_layer((t_object*)x, NULL, gensym("background_layer"));
            object_method(x, gensym("coeffs"), 0, NULL);
		}
	}
	return 0;
}
Esempio n. 17
0
void minimum_compare(t_big_atom *min, t_atom *newone, long *i, long *minIndex)
{
	double a, b;

	if (min->a_type ==A_NOTHING) {
		min->a_type = atom_gettype(newone);
		if (atom_gettype(newone) == A_LONG)
			min->w_long = atom_getlong(newone);
		else if (atom_gettype(newone) == A_FLOAT)
			min->w_float = atom_getfloat(newone);
		else {
			min->a_type = A_LONG;
			min->w_long = 0L;
		}
		return;
	}
	if (min->a_type ==A_FLOAT)
		a = min->w_float;
	else
		a = (double)min->w_long;
	if (atom_gettype(newone) == A_FLOAT)
		b = atom_getfloat(newone);
	else
		b = (double)atom_getlong(newone);

	if (a <= b) {
		min->a_type = A_FLOAT;
		min->w_float = a;
	} else {
		*minIndex = *i;
		min->a_type = A_FLOAT;
		min->w_float = b;
	}
}
void *hoa_projector_new(t_symbol *s, long argc, t_atom *argv)
{
	// @arg 0 @name ambisonic-order @optional 0 @type int @digest The ambisonic order of decomposition
	// @description First argument is the ambisonic order of decomposition.
	
	// @arg 1 @name number-of-channels @optional 0 @type int @digest The number of channels
	// @description Second argument sets the number of channels.
    
	t_hoa_projector *x = NULL;
    x = (t_hoa_projector *)object_alloc(hoa_projector_class);
	if (x)
	{
        ulong order = 1;
        ulong numberOfPlanewaves = 4;
        
		if(argc && atom_gettype(argv) == A_LONG)
			order = max<long>(atom_getlong(argv), 1);
        
        if(argc > 1 && atom_gettype(argv+1) == A_LONG)
			numberOfPlanewaves = max<long>(atom_getlong(argv+1), order * 2 + 1);
		
		x->f_projector = new Projector<Hoa2d, t_sample>(order, numberOfPlanewaves);
		
		dsp_setup((t_pxobject *)x, x->f_projector->getNumberOfHarmonics());
		for (int i = 0; i < x->f_projector->getNumberOfPlanewaves(); i++)
			outlet_new(x, "signal");
        
        x->f_ins = new t_sample[x->f_projector->getNumberOfHarmonics() * HOA_MAXBLKSIZE];
        x->f_outs = new t_sample[x->f_projector->getNumberOfPlanewaves() * HOA_MAXBLKSIZE];
	}

	return (x);
}
Esempio n. 19
0
//----------------------------------------------------------------------------------------------------------------
// 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
}
Esempio n. 20
0
void HoaTool_list(t_HoaTool *x, t_symbol *s, long argc, t_atom *argv)
{
    if(atom_getsym(argv+1) == gensym("car") || atom_getsym(argv+1) == gensym("cartesian"))
        x->f_AmbisonicPolyEase->setCartesianCoordinates(atom_getlong(argv), atom_getfloat(argv+2), atom_getfloat(argv+3));
    else if(atom_getsym(argv+1) == gensym("pol") || atom_getsym(argv+1) == gensym("polar"))
        x->f_AmbisonicPolyEase->setPolarCoordinates(atom_getlong(argv), atom_getfloat(argv+2), atom_getfloat(argv+3));
    else if (atom_getsym(argv+1) == gensym("mute"))
        x->f_AmbisonicPolyEase->setMuted(atom_getlong(argv), atom_getlong(argv+2));
}
Esempio n. 21
0
void *hoa_map_3D_tilde_new(t_symbol *s, long argc, t_atom *argv)
{
    t_hoa_map_3D_tilde *x = NULL;
    t_binbuf *d;
    int	order = 1;
    int numberOfSources = 1;
    
    if (!(d = binbuf_via_atoms(argc,argv)))
		return NULL;
    
    x = (t_hoa_map_3D_tilde *)eobj_new(hoa_map_3D_tilde_class);
    
	if (x)
	{
		if(atom_gettype(argv) == A_LONG)
			order = clip_min(atom_getlong(argv), 0);
        if(argc > 1 && atom_gettype(argv+1) == A_LONG)
            numberOfSources = clip_minmax(atom_getlong(argv+1), 1, 255);
        if(argc > 2 && atom_gettype(argv+2) == A_SYM)
        {
            if(atom_getsym(argv+2) == gensym("car") || atom_getsym(argv+2) == gensym("cartesian"))
                x->f_mode = 1;
            else
                x->f_mode = 0;
        }
        else
            x->f_mode = 0;
        
        x->f_ramp       = 100;
		x->f_map        = new Hoa3D::Map(order, numberOfSources);
		x->f_lines      = new MapPolarLines3D(x->f_map->getNumberOfSources());
        x->f_lines->setRamp(0.1 * sys_getsr());
        for (int i = 0; i < x->f_map->getNumberOfSources(); i++)
        {
            x->f_lines->setRadiusDirect(i, 1);
            x->f_lines->setAzimuthDirect(i, 0.);
            x->f_lines->setElevationDirect(i, 0.);
        }
        
		if(x->f_map->getNumberOfSources() == 1)
            eobj_dspsetup(x, 4, x->f_map->getNumberOfHarmonics());
        else
            eobj_dspsetup(x, x->f_map->getNumberOfSources(), x->f_map->getNumberOfHarmonics());
        
        if(x->f_map->getNumberOfSources() == 1)
            x->f_sig_ins    = new t_float[4 * SYS_MAXBLKSIZE];
        else
            x->f_sig_ins    = new t_float[x->f_map->getNumberOfSources() * SYS_MAXBLKSIZE];
		
        x->f_sig_outs       = new t_float[x->f_map->getNumberOfHarmonics() * SYS_MAXBLKSIZE];
        x->f_lines_vector   = new float[x->f_map->getNumberOfSources() * 3];
        
        ebox_attrprocess_viabinbuf(x, d);
	}
    
	return (x);
}
Esempio n. 22
0
ObjectPtr wrappedClass_new(SymbolPtr name, AtomCount argc, AtomPtr argv)
{	
	WrappedClass*		wrappedMaxClass = NULL;
    WrappedInstancePtr	self = NULL;
	TTValue				v;
	TTErr				err = kTTErrNone;
	TTUInt8				numInputs = 1;
	TTUInt8				numOutputs = 1;
 	long				attrstart = attr_args_offset(argc, argv);		// support normal arguments
	
	// Find the WrappedClass
	hashtab_lookup(wrappedMaxClasses, name, (ObjectPtr*)&wrappedMaxClass);
	
	// If the WrappedClass has a validity check defined, then call the validity check function.
	// If it returns an error, then we won't instantiate the object.
	if (wrappedMaxClass) {
		if (wrappedMaxClass->validityCheck)
			err = wrappedMaxClass->validityCheck(wrappedMaxClass->validityCheckArgument);
		else
			err = kTTErrNone;
	}
	else
		err = kTTErrGeneric;
	
	if (!err)
		self = (WrappedInstancePtr)object_alloc(wrappedMaxClass->maxClass);
    if (self){

		if (wrappedMaxClass->options && !wrappedMaxClass->options->lookup(TT("argumentDefinesNumInlets"), v)) {
			long argumentOffsetToDefineTheNumberOfInlets = v;
			if ((attrstart-argumentOffsetToDefineTheNumberOfInlets > 0) && argv+argumentOffsetToDefineTheNumberOfInlets)
				numInputs = atom_getlong(argv+argumentOffsetToDefineTheNumberOfInlets);
		}
		for (TTUInt16 i=numInputs-1; i>0; i--)
			self->inlets[i-1] = proxy_new(self, i, NULL);
		
    	object_obex_store((void*)self, _sym_dumpout, (object*)outlet_new(self, NULL));	// dumpout
		if (wrappedMaxClass->options && !wrappedMaxClass->options->lookup(TT("argumentDefinesNumOutlets"), v)) {
			long argumentOffsetToDefineTheNumberOfOutlets = v;
			if ((attrstart-argumentOffsetToDefineTheNumberOfOutlets > 0) && argv+argumentOffsetToDefineTheNumberOfOutlets)
				numOutputs = atom_getlong(argv+argumentOffsetToDefineTheNumberOfOutlets);
		}
		for (TTInt16 i=numOutputs-1; i>=0; i--)
			self->audioGraphOutlets[i] = outlet_new(self, "audio.connect");

		self->wrappedClassDefinition = wrappedMaxClass;
		v.setSize(3);
		v.set(0, wrappedMaxClass->ttClassName);
		v.set(1, numInputs);
		v.set(2, numOutputs);
		err = TTObjectInstantiate(TT("audio.object"), (TTObjectPtr*)&self->audioGraphObject, v);
				
		attr_args_process(self, argc, argv);
	}
	return ObjectPtr(self);
}
Esempio n. 23
0
void CLASSMETHOD(ClipLed)(IMPORT_T, t_symbol *s, long argc, t_atom *argv)
{
  if (argc != 3) {
    post("Clip Led messages must have 3 integers: column - row - mode");
    return;
  }

  int row, column;
  CLIP_LED cl = CL_INVALID;

  if (atom_gettype(argv) == A_LONG) {
    column = (int)atom_getlong(argv);
  }
  else {
    post("First argument is not an integer.");
    return;
  }

  if (atom_gettype(argv + 1) == A_LONG) {
    row = (int)atom_getlong(argv + 1);
  }
  else {
    post("Second argument is not an integer.");
    return;
  }

  if (row < 1 || row > CLIPROWS || column < 1 || column > CLIPCOLUMNS) {
    post("Element is not in range.");
    return;
  }

  // set array offset
  row--; column--;

  if (atom_gettype(argv + 2) == A_SYM) {
    std::string s; 
    s = atom_getsym(argv + 2)->s_name;
    if (s == "green") T->memory.setClipLed(column, row, CL_GREEN);
    else if (s == "orange") T->memory.setClipLed(column, row, CL_ORANGE);
    else if (s == "red") T->memory.setClipLed(column, row, CL_RED);
    else {
      post("Third argument is not a valid symbol");
      return;
    }
  }
  else {
    post("Third argument is not a symbol");
    return;
  }

  // send led color to apc
  {
    CLASSMETHOD(SendNoteOn)(T, column + 1, row + 53, (int)T->memory.getClipLed(column, row));
  }
}
Esempio n. 24
0
/****************************************************************
*  Constructor
*/
void *strstr_new(t_symbol *sym, long argc, t_atom *argv)
{
  t_strstr *x = NULL;

  x = (t_strstr *)object_alloc(strstr_class);

  if (x == NULL) {
    error("strstr:  Allocation failed.");
    return NULL;
  }

  // Set inlets, outlets, and proxy
  x->inl_proxy_ind = 0;
  x->inl_proxy = proxy_new((t_object *)x, 1, &x->inl_proxy_ind);
  x->outl_int = intout((t_object *)x);

  // Set the left string buffer
  x->i_dstr1 = dstr_new();

  // First argument:  right string buffer
  x->i_dstr2 = dstr_new();
  if ((argc >= 1) && (attr_args_offset((short)argc, argv) >= 1)) {
    x->i_dstr2 = str_cat_atom(x, x->i_dstr2, argv);
  }

  // Test the string buffers
  if (DSTR_IS_NULL(x->i_dstr1) || DSTR_IS_NULL(x->i_dstr2)) {
    object_error((t_object *)x, "Allocation error.");
    strstr_free(x);
    return NULL;
  }

  // Second argument:  mode
  long mode = 0;
  if ((argc >= 2) && (attr_args_offset((short)argc, argv) >= 2)) {
    if ((atom_gettype(argv + 1) == A_LONG) && (atom_getlong(argv + 1) >= 0) && (atom_getlong(argv + 1) <= 1)) {
      mode = (long)atom_getlong(argv + 1);
    } else {
      object_error((t_object *)x, "Arg 2:  Mode:  0 or 1 expected");
    }
  }
  object_attr_setlong(x, gensym("mode"), mode);

  // Set the float precision
  object_attr_setlong(x, gensym("fprecision"), 6);

  // Set the remaining variables
  x->o_pos = -1;

  // Process the attributes
  attr_args_process(x, (short)argc, argv);

  return x;
}
Esempio n. 25
0
void dynamicdsp_loadpatch(t_dynamicdsp *x, t_symbol *s, long argc, t_atom *argv)
{
    t_symbol *patch_name = NULL;
    t_atom_long index = -1;
	t_atom_long thread_request = -1;
	
	// Get requested patch index if there is one
	
	if (argc && atom_gettype(argv) == A_LONG)
	{
		index = atom_getlong(argv) - 1;
		if (index < 0)
		{
			object_error((t_object *) x, "patch index out of range");
			return;
		}
		argc--; argv++;
	}
	
	// Get thread request if there is one
	
	if (argc && atom_gettype(argv) == A_LONG)
	{
		thread_request = atom_getlong(argv) - 1;
		argc--; argv++;
	}
	
	// If there is a patch name then try to load the patch
	
	if (argc && atom_gettype(argv) == A_SYM)			
	{
		patch_name = atom_getsym(argv);
		argc--; argv++;
        
        index = x->slots->load(index, patch_name, argc, argv, x->last_vec_size, x->last_samp_rate);
        
        // FIX - threading...
        // FIX - review
        
        if (thread_request && index >= 0)
        {
            if (thread_request > 0)
                x->slots->requestThread(index, thread_request);
            else
                x->slots->requestThread(index, index);
            
            x->update_thread_map = 1;
        }
	} 
	else 
		object_error((t_object *) x, "no patch specified");
}
Esempio n. 26
0
void tralala_paintStrncatNote(char *dst, long argc, t_atom *argv)
{
    char a[5];
    char temp[32];
    long p = atom_getlong(argv + 1);
    long v = atom_getlong(argv + 3);
    long d = atom_getlong(argv + 4);
    long c = atom_getlong(argv + 5);
    
    tralala_paintPitchAsString(a, atom_getlong(argv + 2), 5);
    snprintf_zero(temp, 32, "%ld %s %ld %ld %ld\n", p, a, v, d, c);
    strncat_zero(dst, temp, TLL_STRING_SIZE);
}
Esempio n. 27
0
void ovalidate_anything(t_ovalidate *x, t_symbol *msg, int argc, t_atom *argv)
{
	if(msg == gensym("xosc-msgsize-bug")){
		// DON'T DO SHIT LIKE THIS---THIS ISN'T THE WILD F*****G WEST
		long len = atom_getlong(argv + 1);
		char *ptr = (char *)atom_getlong(argv + 2);
		char *size = ptr + OSC_HEADER_SIZE;
		*((int32_t *)size) = hton32(100);
		ovalidate_fullPacket(x, atom_getsym(argv), argc - 1, argv + 1);
	}else{
		object_error((t_object *)x, "doesn't understand message %s", msg->s_name);
	}
}
Esempio n. 28
0
void hoa_optim_deprecated(t_hoa_optim* x, t_symbol *s, long ac, t_atom* av)
{
    t_atom* argv;
    long argc;
    if(s && s == gensym("mode") && ac && av)
    {
        if(atom_gettype(av) == A_SYM)
        {
            if(atom_getsym(av) == gensym("maxRe"))
                x->f_optim->setMode(Hoa2D::Optim::MaxRe);
            else if(atom_getsym(av) == gensym("basic"))
                x->f_optim->setMode(Hoa2D::Optim::Basic);
            else
                x->f_optim->setMode(Hoa2D::Optim::InPhase);
        }
        else
        {
            if(atom_getlong(av) == 1)
                x->f_optim->setMode(Hoa2D::Optim::MaxRe);
            else if(atom_getlong(av) == 0)
                x->f_optim->setMode(Hoa2D::Optim::Basic);
            else
                x->f_optim->setMode(Hoa2D::Optim::InPhase);
        }
        object_error(x, "%s attribute @mode is deprecated, please use it as an argument.", eobj_getclassname(x)->s_name);
    }
    atoms_get_attribute(ac, av, gensym("@mode"), &argc, &argv);
    if(argc && argv)
    {
        if(atom_gettype(argv) == A_SYM)
        {
            if(atom_getsym(argv) == gensym("maxRe"))
                x->f_optim->setMode(Hoa2D::Optim::MaxRe);
            else if(atom_getsym(argv) == gensym("basic"))
                x->f_optim->setMode(Hoa2D::Optim::Basic);
            else
                x->f_optim->setMode(Hoa2D::Optim::InPhase);
        }
        else
        {
            if(atom_getlong(argv) == 1)
                x->f_optim->setMode(Hoa2D::Optim::MaxRe);
            else if(atom_getlong(argv) == 0)
                x->f_optim->setMode(Hoa2D::Optim::Basic);
            else
                x->f_optim->setMode(Hoa2D::Optim::InPhase);
        }
        object_error(x, "%s attribute @mode is deprecated, please use it as an argument.", eobj_getclassname(x)->s_name);
        argc = 0;free(argv);argv = NULL;
    }
}
Esempio n. 29
0
short past_compare(t_past *x, t_atom *a, long index)
{
	t_atom *b;
	float temp1;
	
	b = x->p_vector + index;
	if (atom_gettype(a) == A_LONG) {
		if (atom_gettype(b) == A_LONG) {
			if (atom_getlong(a) > atom_getlong(b))
				return 1;
			else if (atom_getlong(a) == atom_getlong(b))
				return 0;
			else
				return -1;
		} else if (atom_gettype(b) == A_FLOAT) {
			temp1 = (float)atom_getlong(a);
			if (temp1 > atom_getfloat(b))
				return 1;
			else if (temp1 == atom_getfloat(b))
				return 0;
			else
				return -1;
		} else {
			if (atom_getlong(a) > 0)
				return 1;
			else if (atom_getlong(a) == 0)
				return 0;
			else
				return -1;
		}
	} else if (atom_gettype(a) == A_FLOAT) {
		if (atom_gettype(b) == A_LONG) {
			temp1 = (float)atom_getlong(b);
			if (atom_getfloat(a) > temp1)
				return 1;
			else if (atom_getfloat(a) == temp1)
				return 0;
			else
				return -1;
		} else if (atom_gettype(b) == A_FLOAT) {
			if (atom_getfloat(a) > atom_getfloat(b))
				return 1;
			else if (atom_getfloat(a) == atom_getfloat(b))
				return 0;
			else
				return -1;
		} else {
			if (atom_getfloat(a) > 0.)
				return 1;
			else if (atom_getfloat(a) == 0.)
				return 0;
			else
				return -1;
		}
	}
	return -1;
	// uh, yeah, I guess. return -1 when in doubt. makes as much sense as anything else.
	// if someone's trying to compare a t_symbol you just say it's less than whatever you're comparing it with.
	// in theory this should never happen with the past object.
}
Esempio n. 30
0
// messages received from jcom.hub for the algorithm
void out_algorithm_message(t_out *x, t_symbol *msg, long argc, t_atom *argv)
{
	if(argc < 2)
		return;
		
	if(argv->a_type == A_SYM){
// jamoma 0.4
//		if((argv->a_w.w_sym == jps_slash_audio_gain_midi) || (argv->a_w.w_sym == jps_audio_gain_midi)){
// jamoma 0.5
		if((argv->a_w.w_sym == gensym("/audio/gain")) || (argv->a_w.w_sym == gensym("audio/gain")) || (argv->a_w.w_sym == gensym("gain")) || (argv->a_w.w_sym == gensym("/gain"))){
			// Do gain control here...
			// Should be that the gain change triggers a short tt_ramp to the new value
			x->attr_gain = atom_getfloat(argv+1);	// store as midi values
#ifdef JCOM_OUT_TILDE
			x->gain->setAttributeValue(TT("midiGain"), x->attr_gain);
#endif
		}
		else if((argv->a_w.w_sym == jps_audio_mute) || (argv->a_w.w_sym == jps_slash_audio_mute) || (argv->a_w.w_sym == gensym("mute")) || (argv->a_w.w_sym == gensym("/mute"))){
			x->attr_mute = atom_getlong(argv+1);
#ifdef JCOM_OUT_TILDE
			if(x->attr_mute)
				x->gain->setAttributeValue(TT("linearGain"), 0.0);
			else 
				x->gain->setAttributeValue(TT("midiGain"), x->attr_gain);			
#endif
		}
		else if((argv->a_w.w_sym == jps_audio_bypass) || (argv->a_w.w_sym == jps_slash_audio_bypass) || (argv->a_w.w_sym == gensym("bypass")) || (argv->a_w.w_sym == gensym("/bypass"))){
			x->attr_bypass = atom_getlong(argv+1);
#ifdef JCOM_OUT_TILDE
			if(x->attr_bypass == 0)
				x->xfade->setAttributeValue(TT("position"), x->attr_mix * 0.01);
			else
				x->xfade->setAttributeValue(TT("position"), 0.0);
#endif
		}
		else if((argv->a_w.w_sym == jps_audio_mix) || (argv->a_w.w_sym == jps_slash_audio_mix) || (argv->a_w.w_sym == gensym("mix")) || (argv->a_w.w_sym == gensym("/mix"))){
			x->attr_mix = atom_getfloat(argv+1);
#ifdef JCOM_OUT_TILDE
			if(x->attr_bypass == 0)
				x->xfade->setAttributeValue(TT("position"), x->attr_mix * 0.01);		
#endif
		}
		else if((argv->a_w.w_sym == jps_audio_meters_freeze) || (argv->a_w.w_sym == jps_slash_audio_meters_freeze) || (argv->a_w.w_sym == gensym("freeze")) || (argv->a_w.w_sym == gensym("/freeze"))){
			x->attr_defeat_meters = atom_getlong(argv+1);
		}
		else if((argv->a_w.w_sym == jps_video_preview) || (argv->a_w.w_sym == jps_slash_video_preview) || (argv->a_w.w_sym == gensym("preview")) || (argv->a_w.w_sym == gensym("/preview")))
			x->attr_preview = atom_getlong(argv+1);
	}
}