Esempio n. 1
0
void *record_new(t_symbol *s, int argc, t_atom *argv)
{
    // @arg 0 @ambisonic-order @optional 0 @type int @digest The ambisonic order
    // @description The ambisonic order, must be at least equal to 1
    
	t_object *x;
	t_atom arguments[2];
	int order = 1;
	if(atom_gettype(argv) == A_LONG)
		order = atom_getlong(argv);
	else if(atom_gettype(argv) == A_FLOAT)
		order = atom_getfloat(argv);

	if(order < 1)
		order = 1;
    
    int is2D = 1;
    
    if (s == gensym("hoa.3d.record~"))
        is2D = 0;
    
    int number_of_channels = is2D ? (order * 2 + 1) : ( (order+1)*(order+1) );
	
	atom_setlong(arguments, number_of_channels);
    
	switch (number_of_channels)
	{
		case 9:
			atom_setlong(arguments+1, 181440);
			break;
		case 10:
			atom_setlong(arguments+1, 20160);
			break;
		case 11:
			atom_setlong(arguments+1, 221760);
			break;
		case 12:
			atom_setlong(arguments+1, 60480);
			break;
		case 13:
			atom_setlong(arguments+1, 262080);
			break;
		case 14:
			atom_setlong(arguments+1, 20160);
			break;
		case 15:
			atom_setlong(arguments+1, 60480);
			break;
		case 16:
			atom_setlong(arguments+1, 40320);
			break;
		default:
			atom_setlong(arguments+1, 20160);
			break;
	}
	x = (t_object *)object_new_typed(CLASS_BOX, gensym("sfrecord~"), 2, arguments);
	
	return x;
}	
Esempio n. 2
0
void *hoa_dac_new(t_symbol *s, int argc, t_atom *argv)
{
	int i, j, count = 0;
	t_hoa_dac *x;
	t_atom channels[512];
	int min, max;
    int symPrepend = 0;

    x = (t_hoa_dac *)object_alloc(hoa_dac_class);
    
    if (argc && atom_gettype(argv) == A_SYM)
    {
        char *dac_bus_name = atom_getsym(argv)->s_name;
        if (isalpha(dac_bus_name[0])) // only works if the first letter isn't a number
        {
            symPrepend = 1;
            atom_setsym(channels, atom_getsym(argv));
        }
    }
    
	for(i = 0; i < (argc-symPrepend); i++)
	{
		if(atom_gettype(argv+i+symPrepend) == A_SYM)
		{
			min = atoi(atom_getsym(argv+i+symPrepend)->s_name);
			if (min < 10)
				max = atoi(atom_getsym(argv+i+symPrepend)->s_name+2);
			else if (min < 100)
				max = atoi(atom_getsym(argv+i+symPrepend)->s_name+3);
			else if (min < 1000)
				max = atoi(atom_getsym(argv+i+symPrepend)->s_name+4);
			else
				max = atoi(atom_getsym(argv+i+symPrepend)->s_name+5);
			if (max > min) 
			{
				for(j = min; j <= max; j++)
				{
					atom_setlong(channels + symPrepend + count++, j);
				}
			}
			else 
			{
				for(j = min; j >= max; j--)
				{
					atom_setlong(channels + symPrepend + count++, j);
				}
			}
		}	
		else if(atom_gettype(argv + symPrepend + i) == A_LONG)
		{
            atom_setlong(channels + symPrepend + count++, atom_getlong(argv + symPrepend + i));
		}
	}
	x->f_number_of_channels = count;
    dsp_setup((t_pxobject *)x, x->f_number_of_channels);
	x->f_dac = (t_object *)object_new_typed(CLASS_BOX, gensym("dac~"), count + symPrepend, channels);
	
	return x;
}
Esempio n. 3
0
t_max_err comp_set(t_HoaDelay *x, t_object *attr, long argc, t_atom *argv)
{
    if(atom_gettype(argv) == A_LONG || atom_gettype(argv) == A_FLOAT)
		x->f_AmbiDelay->setEncodingCompensation(atom_getfloat(argv));
    
	x->f_encoding_compensation = x->f_AmbiDelay->getEncodingCompensation();
	return MAX_ERR_NONE;
}
Esempio n. 4
0
t_max_err diff_set(t_HoaDelay *x, t_object *attr, long argc, t_atom *argv)
{
    if(atom_gettype(argv) == A_LONG || atom_gettype(argv) == A_FLOAT)
		x->f_AmbiDelay->setDiffuseFactor(atom_getfloat(argv));
 
	x->f_diffuse_factor = x->f_AmbiDelay->getDiffuseFactor();
	return MAX_ERR_NONE;
}
Esempio n. 5
0
t_max_err ramp_set(t_HoaDelay *x, t_object *attr, long argc, t_atom *argv)
{
    if(atom_gettype(argv) == A_LONG || atom_gettype(argv) == A_FLOAT)
		x->f_AmbiDelay->setRampInMs(atom_getfloat(argv));

	x->f_ramp_time = x->f_AmbiDelay->getRampInMs();
	return MAX_ERR_NONE;
}
Esempio n. 6
0
void breakgen_writefile(t_breakgen *x, t_symbol *s, long argc, t_atom *argv)
{
    t_atom *ap;
    long num_frames;
    // t_max_err buferror;
    float frame;
    int i;
    FILE *break_out;
    float amp = 1.0;
    
    short		path;
    char		ps[MAX_FILENAME_CHARS] = "";
    char        finalpath[MAX_PATH_CHARS];
    
    ap = argv;
    
    // if (atom_gettype(ap) == A_SYM) {
    //     if (atom_getsym(ap) != gensym("")) {
    //        *ps = atom_getsym(ap);
    //     }
    // }
    
    // strcpy(ps, "");
    
    if (saveas_dialog(ps,&path,NULL)) {
        return;
    }
    
    path_toabsolutesystempath(path, ps, finalpath);
    post(finalpath);
    
    if (atom_gettype(ap) == A_LONG) {
        if ((break_out = fopen(finalpath, "w"))) {
            post("file opened");
            num_frames = atom_getlong(ap);
            post("%i", argc);
            if (argc > 1) {
                ap++;
                if ( (atom_gettype(ap) == A_FLOAT) && (atom_getfloat(ap) < 1.0) ) {
                    amp = atom_getfloat(ap);
                }
            }
            for (i = 0; i < num_frames; i++) {
                frame = ((output_val(x) - 1) * amp) + 1;
                fprintf(break_out, "%f", frame);
                if (i + 1 != num_frames) {
                    fprintf(break_out, "\n");
                }
            }
            fclose(break_out);
            post("file closed");
        } else {
            post("couldn't create file");
        }
    } else {
        post("wrong atom type");
    }
}
Esempio n. 7
0
void wrappedClass_anything(TTPtr self, t_symbol* s, long argc, t_atom* argv)
{
	WrappedInstancePtr	x = (WrappedInstancePtr)self;
	TTSymbol			ttName;
	TTValue				v_in;
	TTValue				v_out;
	
//	err = hashtab_lookup(x->wrappedClassDefinition->pdNamesToTTNames, s, (t_object**)&ttName);
    ttName = x->wrappedClassDefinition->pdNamesToTTNames[s->s_name];
    if (ttName.string().empty()) {
        pd_error((t_object*)x, "no method found for %s", s->s_name);
		return;
	}

	if (argc && argv) {
		v_in.resize(argc);
		for (long i=0; i<argc; i++) {
			if (atom_gettype(argv+i) == A_LONG)
				v_in[i] = (TTInt32)atom_getlong(argv+i);
			else if (atom_gettype(argv+i) == A_FLOAT)
				v_in[i] = atom_getfloat(argv+i);
			else if (atom_gettype(argv+i) == A_SYM)
				v_in[i] = TT(atom_getsym(argv+i)->s_name);
			else
				pd_error((t_object*)x, "bad type for message arg");
		}
	}
	x->wrappedObject->send(ttName, v_in, v_out);
		
	// process the returned value for the dumpout outlet
	{
		long	ac = v_out.size();

		if (ac) {
			t_atom*		av = (t_atom*)malloc(sizeof(t_atom) * ac);
			
			for (long i=0; i<ac; i++) {
				if (v_out[0].type() == kTypeSymbol) {
					TTSymbol ttSym;
					ttSym = v_out[i];
					atom_setsym(av+i, gensym((char*)ttSym.c_str()));
				}
				else if (v_out[0].type() == kTypeFloat32 || v_out[0].type() == kTypeFloat64) {
					TTFloat64 f = 0.0;
					f = v_out[i];
					atom_setfloat(av+i, f);
				}
				else {
					TTInt32 l = 0;
					l = v_out[i];
					atom_setfloat(av+i, l);
				}
			}
            outlet_anything(x->dumpOut, s, ac, av);
			free(av);
		}
	}
}
Esempio n. 8
0
t_max_err hoa_poltocar_setattr_offset(t_hoa_poltocar *x, void *attr, long ac, t_atom *av)
{
	if (ac && av)
	{
		if (atom_gettype(av) == A_FLOAT || atom_gettype(av) == A_LONG)
			x->f_offset = Hoa3D::wrap_twopi(atom_getfloat(av));
	}
	return MAX_ERR_NONE;
}
Esempio n. 9
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. 10
0
t_max_err HoaRecomposer_ramp(t_HoaRecomposer *x, t_object *attr, long argc, t_atom *argv)
{
    if(argc && argv && (atom_gettype(argv) == A_FLOAT || atom_gettype(argv) == A_LONG))
    {
        x->f_ambiRecomposer->setRampInMs(atom_getfloat(argv));
        x->f_ramp_time = x->f_ambiRecomposer->getRampInMs();
    }
    return MAX_ERR_NONE;
}
Esempio n. 11
0
void wrappedClass_anything(WrappedInstancePtr self, t_symbol* s, long argc, t_atom* argv)
{
	TTValue		v;
	TTSymbol	ttName;
	t_max_err	err;
	
	err = hashtab_lookup(self->wrappedClassDefinition->maxNamesToTTNames, s, (t_object**)&ttName);
	if (err) {
		object_post(SELF, "no method found for %s", s->s_name);
		return;
	}

	if (argc && argv) {
		TTValue	v;
		
		v.resize(argc);
		for (long i=0; i<argc; i++) {
			if (atom_gettype(argv+i) == A_LONG)
				v[i] = (TTInt32)atom_getlong(argv+i);
			else if (atom_gettype(argv+i) == A_FLOAT)
				v[i] = atom_getfloat(argv+i);
			else if (atom_gettype(argv+i) == A_SYM)
				v[i] = TT(atom_getsym(argv+i)->s_name);
			else
				object_error(SELF, "bad type for message arg");
		}
		self->graphObject->mKernel.send(ttName, v, v); // FIXME: TEMPORARY HACK WHILE WE TRANSITION FROM 1-ARG MESSAGES to 2-ARG MESSAGES
		
		// process the returned value for the dumpout outlet
		{
			long	ac = v.size();

			if (ac) {
				t_atom*		av = (t_atom*)malloc(sizeof(t_atom) * ac);
				
				for (long i=0; i<ac; i++) {
					if (v[i].type() == kTypeSymbol) {
						TTSymbol ttSym = v[i];
						atom_setsym(av+i, gensym((char*)ttSym.c_str()));
					}
					else if (v[i].type() == kTypeFloat32 || v[i].type() == kTypeFloat64) {
						TTFloat64 f = v[i];
						atom_setfloat(av+i, f);
					}
					else {
						TTInt32 l = v[i];
						atom_setfloat(av+i, l);
					}
				}
				object_obex_dumpout(self, s, ac, av);
				free(av);
			}
		}
	}
	else
		self->graphObject->mKernel.send(ttName);
}
Esempio n. 12
0
t_max_err wet_set(t_HoaConvolve *x, t_object *attr, long argc, t_atom *argv)
{
	if(atom_gettype(argv) == A_LONG)
		x->f_ambiConvolve->setWetValue(atom_getlong(argv));
	else if(atom_gettype(argv) == A_FLOAT)
		x->f_ambiConvolve->setWetValue(atom_getfloat(argv));

	x->f_wet = x->f_ambiConvolve->getWetValue();
	return 0;
}
Esempio n. 13
0
t_max_err freeze_set(t_freeverb *x, t_object *attr, long argc, t_atom *argv)
{
	if(atom_gettype(argv) == A_LONG)
		x->f_freeverb->setmode(atom_getlong(argv));
	else if(atom_gettype(argv) == A_FLOAT)
		x->f_freeverb->setmode(atom_getfloat(argv));

	x->f_freeze = x->f_freeverb->getmode();
	return 0;
}
Esempio n. 14
0
t_max_err delay_set(t_HoaDelay *x, t_object *attr, long argc, t_atom *argv)
{
    if(atom_gettype(argv) == A_LONG)
		x->f_AmbiDelay->setDelayTimeInSample(atom_getlong(argv));
    else if(atom_gettype(argv) == A_FLOAT)
        x->f_AmbiDelay->setDelayTimeInMs(atom_getfloat(argv));
    
	x->f_delay = x->f_AmbiDelay->getDelayTimeInMs();
	return MAX_ERR_NONE;
}
Esempio n. 15
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. 16
0
static void blackboard_image(t_blackboard *x, t_symbol *s, int argc, t_atom *argv)
{
	int fd;
    char path[MAXPDSTRING];
	char name[MAXPDSTRING];
	char *nameptr;
    
    if(x->f_ninstructions >= _blackboard::maxcmd)
    {
        pd_error(x, "%s too many drawing commands.", eobj_getclassname(x)->s_name);
        return;
    }

    if(argc > 2 && argv)
    {
        if(atom_gettype(argv) == A_FLOAT && atom_gettype(argv+1) == A_FLOAT && atom_gettype(argv+2) == A_SYMBOL)
        {
            sprintf(path, "%s",atom_getsymbol(argv+2)->s_name);
            if(access(path, O_RDONLY) != -1)
            {
                sprintf(x->f_instructions[x->f_ninstructions], "create image %d %d -anchor nw -image [image create photo -file %s]", (int)atom_getfloat(argv), (int)atom_getfloat(argv+1), path);
                
                x->f_ninstructions++;
                ebox_redraw((t_ebox *)x);
                return;
            }
            sprintf(path, "%s/%s", canvas_getdir(x->j_box.b_obj.o_canvas)->s_name, atom_getsymbol(argv+2)->s_name);
            if(access(path, O_RDONLY) != -1)
            {
                sprintf(x->f_instructions[x->f_ninstructions], "create image %d %d -anchor nw -image [image create photo -file %s]", (int)atom_getfloat(argv), (int)atom_getfloat(argv+1), path);
                
                x->f_ninstructions++;
                ebox_redraw((t_ebox *)x);
                return;
            }
			sprintf(name, "%s", atom_getsymbol(argv+2)->s_name);
			if(!strncmp(name+strlen(name)-4, ".gif", 4))
			{
				strncpy(name+strlen(name)-4, "\0", 4);
			}

			fd = open_via_path(canvas_getdir(x->j_box.b_obj.o_canvas)->s_name, name,  ".gif", path, &nameptr, MAXPDSTRING, 0);
            if(fd >= 0)
			{
                sprintf(x->f_instructions[x->f_ninstructions], "create image %d %d -anchor nw -image [image create photo -file %s/%s.gif]", (int)atom_getfloat(argv), (int)atom_getfloat(argv+1), path, name);
                
                x->f_ninstructions++;
                ebox_redraw((t_ebox *)x);
				return;
			}
        }
    }
    
}
Esempio n. 17
0
void hoa_vector_setChannels(t_hoa_vector *x, t_symbol* s, long argc, t_atom* argv)
{
    if(argc > 2 && argv && atom_gettype(argv) == A_LONG && atom_gettype(argv+1) == A_FLOAT && atom_gettype(argv+2) == A_FLOAT)
    {
        x->f_vector->setChannelPosition(atom_getlong(argv), atom_getfloat(argv+1), atom_getfloat(argv+2));
    }
    for(int i = 0; i < x->f_vector->getNumberOfChannels(); i++)
    {
        post("ls %i %f %f", i, x->f_vector->getChannelAzimuth(i), x->f_vector->getChannelElevation(i));
        post("ls %i %f %f %f", i, x->f_vector->getChannelAbscissa(i), x->f_vector->getChannelOrdinate(i), x->f_vector->getChannelHeight(i));
    }
}
Esempio n. 18
0
t_max_err angles_set(t_hoa_vector *x, t_object *attr, long argc, t_atom *argv)
{
    if(argc && argv)
    {
        for(int i = 0; i < argc && i < x->f_vector->getNumberOfChannels(); i++)
        {
            if(atom_gettype(argv+i) == A_LONG || atom_gettype(argv+i) == A_FLOAT);
               x->f_vector->setChannelAzimuth(i, clip_minmax(atom_getfloat(argv+i), -360., 360.) / 360. * HOA_2PI);
        }
    }
    return MAX_ERR_NONE;
}
Esempio n. 19
0
t_max_err offset_set(t_hoa_vector *x, t_object *attr, long argc, t_atom *argv)
{
    if(argc && argv && (atom_gettype(argv) == A_FLOAT || atom_gettype(argv) == A_LONG))
    {
        double offset = wrap_twopi(atom_getfloat(argv) / 360. * HOA_2PI);
        if(offset != x->f_vector->getChannelsOffset())
        {
            x->f_vector->setChannelsOffset(offset);
        }
    }
    return MAX_ERR_NONE;
}
Esempio n. 20
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. 21
0
static void plane_set(t_plane *x, t_symbol* s, int argc, t_atom *argv)
{
    if(argc > 0 && atom_gettype(argv) == A_FLOAT)
    {
        ebox_parameter_setvalue((t_ebox *)x, 1, atom_getfloat(argv), 0);
    }
    if(argc > 1 && atom_gettype(argv+1) == A_FLOAT)
    {
        ebox_parameter_setvalue((t_ebox *)x, 1, atom_getfloat(argv+1), 0);
    }
    ebox_invalidate_layer((t_ebox *)x, cream_sym_points_layer);
    ebox_redraw((t_ebox *)x);
}
Esempio n. 22
0
static t_pd_err knob_minmax_set(t_knob *x, t_object *attr, int ac, t_atom *av)
{
    if(ac && av)
    {
        const float min = pd_clip((atom_gettype(av) == A_FLOAT) ? atom_getfloat(av) : ebox_parameter_getmin((t_ebox *)x, 1), -FLT_MAX, FLT_MAX);
        const float max = pd_clip((ac > 1  && atom_gettype(av+1) == A_FLOAT) ? atom_getfloat(av+1) : ebox_parameter_getmax((t_ebox *)x, 1), -FLT_MAX, FLT_MAX);
        ebox_parameter_setminmax((t_ebox *)x, 1, min, max);
    }
    
    ebox_invalidate_layer((t_ebox *)x, cream_sym_needle_layer);
    ebox_redraw((t_ebox *)x);
    return 0;
}
Esempio n. 23
0
void HoaRecomposer_wide(t_HoaRecomposer *x, t_symbol *s, short ac, t_atom *av)
{
    if(ac == 2 && atom_gettype(av) == A_LONG && atom_gettype(av+1) == A_FLOAT)
        x->f_ambiRecomposer->setMicrophoneWide(atom_getlong(av), atom_getfloat(av+1));
    else
    {
        for(int i = 0; i < ac; i++)
        {
            if(i < x->f_ambiRecomposer->getNumberOfOutputs() && atom_gettype(av+i) == A_FLOAT)
                x->f_ambiRecomposer->setMicrophoneWide(i, atom_getfloat(av+i));
        }
    }
}
Esempio n. 24
0
t_pd_err ramp_set(t_hoa_map_3D_tilde *x, t_object *attr, long argc, t_atom *argv)
{
    if(argc && argv)
    {
        if(atom_gettype(argv) == A_LONG || atom_gettype(argv) == A_FLOAT)
        {
            x->f_ramp = clip_min(atom_getfloat(argv), 0);
            x->f_lines->setRamp(x->f_ramp / 1000. * sys_getsr());
        }
    }
    
    return 0;
}
Esempio n. 25
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. 26
0
void breakpoints_add(t_breakpoints *x, t_symbol* s, int argc, t_atom* argv)
{
    int index, i;
    float abs, ord;
    if(x->f_number_of_points == MAXPOINTS)
        return;

    if(argc && argv)
    {
        if(argc == 2 && atom_gettype(argv) == A_FLOAT && atom_gettype(argv+1) == A_FLOAT)
        {
            abs = atom_getfloat(argv);
            ord = pd_clip_minmax(atom_getfloat(argv+1), x->f_range_ordinate[0], x->f_range_ordinate[1]);

            if(abs < x->f_range_abscissa[0] || abs > x->f_range_abscissa[1])
                return;

            if(x->f_number_of_points == 0)
            {
                index  = 0;
            }
            else if(abs >= x->f_point_abscissa[x->f_number_of_points-1])
            {
                index = x->f_number_of_points;
            }
            else
            {
                index = 0;
                for(i = 0; i < x->f_number_of_points-1; i++)
                {
                    if(abs > x->f_point_abscissa[i])
                        index = i+1;
                }

                for(i = x->f_number_of_points-1; i >= index; i--)
                {
                    x->f_point_abscissa[i+1] = x->f_point_abscissa[i];
                    x->f_point_ordinate[i+1] = x->f_point_ordinate[i];
                }
            }
            x->f_point_abscissa[index] = abs;
            x->f_point_ordinate[index] = ord;
            x->f_number_of_points++;
            x->f_point_last_created = index;

            ebox_invalidate_layer((t_ebox *)x, gensym("points_layer"));
            ebox_redraw((t_ebox *)x);

        }
    }
}
Esempio n. 27
0
static void pak_list(t_pak *x, t_symbol *s, int argc, t_atom *argv)
{
    int index = eobj_getproxy((t_ebox *)x);
    if(argc && x->f_selectors[index] == 0 && atom_gettype(argv) == A_FLOAT)
    {
        atom_setfloat(x->f_argv+index, atom_getfloat(argv));
        pak_output(x);
    }
    else if(argc && x->f_selectors[index] == 1 && atom_gettype(argv) == A_SYMBOL)
    {
        atom_setsym(x->f_argv+index, atom_getsymbol(argv));
        pak_output(x);
    }
}
Esempio n. 28
0
t_max_err angles_set(t_hoa_decoder *x, t_object *attr, long argc, t_atom *argv)
{
    if(argc && argv && x->f_decoder->getDecodingMode() == Hoa2D::DecoderMulti::Irregular)
    {
        object_method(gensym("dsp")->s_thing, gensym("stop"));
        for(int i = 0; i < argc && i < x->f_decoder->getNumberOfChannels(); i++)
        {
            if(atom_gettype(argv+i) == A_FLOAT || atom_gettype(argv+i) == A_LONG)
                x->f_decoder->setChannelPosition(i, atom_getfloat(argv+i) / 360. * HOA_2PI);
        }
    }
    send_configuration(x);
    return 0;
}
Esempio n. 29
0
static void blackboard_color(t_blackboard *x, t_symbol *s, int argc, t_atom *argv)
{
    t_rgb color_rgb = {0., 0., 0.};
    t_hsl color_hsl = {0., 0., 0.};
    if(argc > 1 && atom_gettype(argv) == A_SYMBOL)
    {
        if(atom_getsymbol(argv) == gensym("rgba") || atom_getsymbol(argv) == gensym("rgb"))
        {
            if(atom_gettype(argv+1) == A_FLOAT)
                color_rgb.red = atom_getfloat(argv+1);
            if(argc > 2 && atom_gettype(argv+2) == A_FLOAT)
                color_rgb.green = atom_getfloat(argv+2);
            if(argc > 3 && atom_gettype(argv+3) == A_FLOAT)
                color_rgb.blue = atom_getfloat(argv+3);
            x->f_color = gensym(rgb_to_hex(color_rgb));
        }
        else if(atom_getsymbol(argv) == gensym("hsla") || atom_getsymbol(argv) == gensym("hsl"))
        {
            if(atom_gettype(argv+1) == A_FLOAT)
                color_hsl.hue = atom_getfloat(argv+1);
            if(argc > 2 && atom_gettype(argv+2) == A_FLOAT)
                color_hsl.saturation = atom_getfloat(argv+2);
            if(argc > 3 && atom_gettype(argv+3) == A_FLOAT)
                color_hsl.lightness = atom_getfloat(argv+3);
            x->f_color = gensym(hsl_to_hex(color_hsl));
        }
        else if(atom_getsymbol(argv) == gensym("hex") || atom_getsymbol(argv) == gensym("hexa"))
        {
            if(atom_gettype(argv+1) == A_SYMBOL)
                x->f_color = atom_getsymbol(argv+1);
        }
    }
}
Esempio n. 30
0
File: iter.c Progetto: CICM/max6-sdk
void iter_bang(t_iter *x)
{
	short i;
	t_atom *av;
	
	for (i=0, av = x->i_av; i < x->i_ac; i++,av++) {
		if (atom_gettype(av) == A_LONG)
			outlet_int(x->i_ob.o_outlet,atom_getlong(av));
		else if (atom_gettype(av) == A_FLOAT)
			outlet_float(x->i_ob.o_outlet,atom_getfloat(av));
		else if (atom_gettype(av) == A_SYM)
			outlet_anything(x->i_ob.o_outlet,atom_getsym(av),0,0);
	}
}