Ejemplo n.º 1
0
t_max_err db_open(t_symbol *dbname, const char *filename, t_database **db)
{
	long	ac=0;
	t_atom	av[6];
	
	if (*db)
		object_free(*db);
	
	if (filename) {
		atom_setsym(av+ac, gensym("@rambased"));
		ac++;
		atom_setlong(av+ac, 0);
		ac++;
		atom_setsym(av+ac, gensym("@filename"));
		ac++;
		atom_setsym(av+ac, gensym((char*)filename));
		ac++;
	}
	atom_setsym(av+ac, gensym("@db"));
	ac++;
	atom_setsym(av+ac, dbname);
	ac++;
	
	*db = (t_database*)object_new_typed(_sym_nobox, _sym_sqlite, ac, av);
	if (!*db)
		return MAX_ERR_GENERIC;
	
	return MAX_ERR_NONE;
}
Ejemplo n.º 2
0
short posit_enumnames(t_patcher *p, t_posit *x)
{
	t_object *jb;
	t_rect jr;
	t_symbol *scriptingname;
	t_symbol *patchername;
	t_symbol *classname;
	
	t_atom *outlist;
	outlist = x->p_outlist;
	
	patchername = jpatcher_get_name(p);
	if(patchername && patchername != ps_nothing) {
		// post("patchername is %s", patchername->s_name
		jb = jpatcher_get_firstobject(p); // get the first BOX in the object list
		while(jb) { // iterate through patcher
			
			classname = jbox_get_maxclass(jb); // class name
			scriptingname = jbox_get_varname(jb); // scripting name
			if (scriptingname && scriptingname != ps_nothing) {
				jbox_get_patching_rect(jb, &jr);			// x, y, width, height (double)
				atom_setsym(outlist+0,  classname);			// class name
				atom_setsym(outlist+1,  scriptingname);		// scripting name
				atom_setlong(outlist+2, (long)((long)jr.x));
				atom_setlong(outlist+3, (long)((long)jr.y));
				atom_setlong(outlist+4, (long)((long)jr.x + (long)jr.width)); 
				atom_setlong(outlist+5, (long)((long)jr.y + (long)jr.height));
				atom_setsym(outlist+6,  patchername);		// patcher name
				outlet_list(x->p_outlet,0L,7,outlist); 
			}
			jb = jbox_get_nextobject(jb); // iterate
		}
	}
	return 0;
}
Ejemplo n.º 3
0
void SDIFfileinfo_output1NVT(t_sdif_fileinfo *x, char *buf, SDIF_FrameHeader *fhp){
	char key[256], val[256];
	char *ptr = buf;
	int i = 0;
	char msg_char[16];
	sprintf(msg_char, "/1NVT/%d", fhp->streamID);
	t_symbol *msg = gensym(msg_char);
	while(*ptr != 0x0){
		i = 0;
		while(*ptr != 0x09 && *ptr != 0x0){
			key[i++] = *ptr;
			ptr++;
		}
		key[i++] = 0x0;
		i = 0;
		while(*ptr != 0x0A && *ptr != 0x0){
			val[i++] = *ptr;
			ptr++;
		}
		val[i++] = 0x0;
		//post("%s %s", key, val);
		if(i > 1){
			t_atom out[2];
			atom_setsym(&(out[0]), gensym(key));
			atom_setsym(&(out[1]), gensym(val));
			outlet_anything(x->outlet2, msg, 2, out);
		}else{
			/*
			t_atom out;
			atom_setsym(&out, gensym("bang"));
			outlet_anything(x->outlet2, msg, 1, &out);
			*/
		}
	}
}
Ejemplo n.º 4
0
void eobj_write(t_eobj* x, t_symbol* s, int argc, t_atom *argv)
{
    char buf[MAXPDSTRING];
    char* pch;
    t_atom av[1];
    t_eclass* c = eobj_getclass(x);

    // The file name is defined
    if(argc && argv && atom_gettype(argv) == A_SYMBOL)
    {
        pch = strpbrk(atom_getsymbol(argv)->s_name, "/\"");
        // The folder seems defined
        if(pch != NULL)
        {
            atom_setsym(av, atom_getsymbol(argv));
            if(c->c_widget.w_write)
                c->c_widget.w_write(x, s, 1, av);
            return;
        }
        // The folder isn't defined so write it in the canvas folder
        else
        {
            sprintf(buf, "%s/%s", canvas_getdir(x->o_canvas)->s_name, atom_getsymbol(argv)->s_name);
            atom_setsym(av, gensym(buf));
            if(c->c_widget.w_write)
                c->c_widget.w_write(x, s, 1, av);
            return;
        }
    }
    // The file name is not defined so we popup a window
    else
    {
        sys_vgui("eobj_saveas %s nothing nothing\n", x->o_id->s_name);
    }
}
Ejemplo n.º 5
0
void SDIFfileinfo_output(t_sdif_fileinfo *x) {
	int i;
	
	t_atom arguments[5];  // ID, type, start, end, #frames
	

	// post("File %s has %d streams:", x->x_filenameSymbol->s_name, x->x_ns);

	atom_setsym(arguments, x->x_filenameSymbol);
	atom_setlong(arguments+1, x->x_ns);
	outlet_anything(x->outlet, ps_file, 2, arguments);

	for (i = 0; i < x->x_ns; ++i) {
		/* post("  ID %d, type %c%c%c%c, start %g end %g, %d frames",
			 x->x_streamID[i], x->x_frameType[i][0], x->x_frameType[i][1],
			 x->x_frameType[i][2], x->x_frameType[i][3], x->x_starttime[i],
			 x->x_endtime[i], x->x_numframes[i]); */
			 
		atom_setlong(arguments, x->x_streamID[i]);
		atom_setsym(arguments+1, x->x_frameTypeSymbol[i]);
		atom_setfloat(arguments+2, x->x_starttime[i]);
		atom_setfloat(arguments+3, x->x_endtime[i]);
		atom_setlong(arguments+4, x->x_numframes[i]);
		outlet_anything(x->outlet, ps_stream, 5, arguments);
	}	
}
Ejemplo n.º 6
0
void prepend_anything(t_prepend *x, t_symbol *s, int argc, t_atom *argv)
{
    int i;
    if(x->f_argc || x->f_selector != &s_list)
    {
        if(x->f_argc + argc + 1 > 255)
        {
            argc = 255 - x->f_argc - 1;
        }
        atom_setsym(x->f_argv, s);
        for(i = x->f_argc; i < x->f_argc + argc; i++)
        {
            x->f_argv[i+1] = argv[i - x->f_argc];
        }
        outlet_anything(x->f_out, x->f_selector, x->f_argc + argc + 1, x->f_argv);
    }
    else if(x->f_selector != &s_list)
    {
        if(argc > 255)
            argc = 255;
        atom_setsym(x->f_argv, s);
        for(i = 0; i < argc; i++)
        {
            x->f_argv[i+1] = argv[i];
        }
        outlet_anything(x->f_out, x->f_selector, argc+1, argv);
    }
    else
    {
        outlet_anything(x->f_out, s, argc, argv);
    }
}
Ejemplo n.º 7
0
short posit_enumquery(t_patcher *p, t_posit *x)
{
	t_object *jb;
	t_rect jr;
	t_symbol *scriptingname;
	t_symbol *patchername;
	t_symbol *classname;
	t_atom *outlist;
	outlist = x->p_outlist;

	jb = jpatcher_get_firstobject(p); // get the first BOX in the object list
	patchername = jpatcher_get_name(p);
	
	while(jb) { // iterate through patcher
		
		classname = jbox_get_maxclass(jb); // class name
		scriptingname = jbox_get_varname(jb); // scripting name
		if (scriptingname && scriptingname == x->p_query[0].a_w.w_sym) {
			jbox_get_patching_rect(jb, &jr);			// x, y, width, height (double)
			atom_setsym(outlist+0,  classname);			// class name
			atom_setsym(outlist+1,  scriptingname);		// scripting name
			atom_setlong(outlist+2, (long)((long)jr.x));
			atom_setlong(outlist+3, (long)((long)jr.y));
			atom_setlong(outlist+4, (long)((long)jr.x + (long)jr.width)); 
			atom_setlong(outlist+5, (long)((long)jr.y + (long)jr.height));
			atom_setsym(outlist+6,  patchername);		// patcher name
			outlet_list(x->p_outlet,0L,7,outlist);
			x->p_state = 1;
			break;
		}
		jb = jbox_get_nextobject(jb); // iterate
	}	
	return 0;
}
void bufreverse_process(t_bufreverse *x, t_symbol *target, t_symbol *source)
{
    t_atom args[2];

    atom_setsym(args + 0, target);
    atom_setsym(args + 1, source);

    defer(x, (method) bufreverse_process_internal, 0, 2, args);
}
void irphase_process (t_irphase *x, t_symbol *target, t_symbol *source, double phase, double time_mul, t_phase_type mode)
{
	t_atom args[5];

	atom_setsym(args + 0, target);
	atom_setsym(args + 1, source);
	atom_setfloat(args + 2, phase);
	atom_setfloat(args + 3, time_mul);
	atom_setlong(args + 4, mode);
	
	defer(x, (method) irphase_process_internal, 0, 5, args);
}
Ejemplo n.º 10
0
t_max_err ocontext_attr_prefix_get(t_ocontext *x, t_object *attr, long *argc, t_atom **argv)
{
	char alloc;
    atom_alloc(argc, argv, &alloc);
    
    if(x->prefix){
		atom_setsym(*argv, x->prefix);
	}else{
		atom_setsym(*argv, gensym(""));
	}
    
    return 0;
}
Ejemplo n.º 11
0
t_max_err db_open(t_symbol *dbname, const char *fullpath, t_database **db)
{
	long	ac=0;
	t_atom	av[6];
	
	if (*db)
		object_free(*db);
	
	if (fullpath) {
		char	coercedpath[MAX_PATH_CHARS];
		short	err;
		char	dbpath[MAX_PATH_CHARS];
#ifdef MAC_VERSION
		char	*temppath;
#endif

		err = path_nameconform((char*)fullpath, coercedpath, PATH_STYLE_NATIVE_PLAT, PATH_TYPE_ABSOLUTE);
		if (err)
			strncpy_zero(coercedpath, fullpath, MAX_PATH_CHARS);
		
#ifdef MAC_VERSION
		temppath = strchr(coercedpath, ':');
		*temppath = '\0';
		temppath += 1;
		
		// at this point temppath points to the path after the volume, and coercedpath has the volume
		snprintf(dbpath, MAX_PATH_CHARS, "/Volumes/%s%s", coercedpath, temppath);
#else // WIN_VERSION
		strncpy_zero(dbpath, coercedpath, MAX_PATH_CHARS);
#endif
		
		atom_setsym(av+ac, gensym("@rambased"));
		ac++;
		atom_setlong(av+ac, 0);
		ac++;
		atom_setsym(av+ac, gensym("@filename"));
		ac++;
		atom_setsym(av+ac, gensym(dbpath));
		ac++;
	}
	atom_setsym(av+ac, gensym("@db"));
	ac++;
	atom_setsym(av+ac, dbname);
	ac++;
	
	*db = (t_database*)object_new_typed(_sym_nobox, _sym_sqlite, ac, av);
	if (!*db)
		return MAX_ERR_GENERIC;
	
	return MAX_ERR_NONE;
}
Ejemplo n.º 12
0
void model_preset_default(TTPtr self)
{
	WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;
	short		outvol;
	t_fourcc	outtype, filetype = 'TEXT';
	char 		fullpath[MAX_PATH_CHARS];		// path and name passed on to the xml parser
	char		posixpath[MAX_PATH_CHARS];
	t_atom		a;
	t_symbol*	textfile;

	if (x->patcherClass != kTTSymEmpty) {

        if (EXTRA->attr_presets != kTTSym_none) {

            textfile = gensym(EXTRA->attr_presets.c_str());
        }
		else if (x->patcherContext == kTTSym_model)
			jamoma_edit_filename(*ModelPresetFormat, x->patcherClass, &textfile);

		else if (x->patcherContext == kTTSym_view)
			jamoma_edit_filename(*ViewPresetFormat, x->patcherClass, &textfile);
		else
			return object_error((t_object*)x, "preset_default : can't get the context of the patcher");

		if (locatefile_extended((char*)textfile->s_name, &outvol, &outtype, &filetype, 1)) {
			//object_warn((t_object*)x, "preset_default : can't find %s file in the Max search path", textfile.data());
			return;
		}

		path_topathname(outvol, (char*)textfile->s_name, fullpath);
		path_nameconform(fullpath, posixpath, PATH_STYLE_NATIVE, PATH_TYPE_BOOT);

		atom_setsym(&a, gensym(posixpath));
		defer_low(self, (method)model_preset_doread, gensym("read"), 1, &a);

		// recall the default preset if exists
        atom_setsym(&a, gensym("default"));
		defer_low((t_object*)x, (method)model_preset_dorecall, NULL, 1, &a);

		// replace filewatcher
		if (EXTRA->filewatcher) {
			filewatcher_stop(EXTRA->filewatcher);
			object_free(EXTRA->filewatcher);
		}

		EXTRA->filewatcher = filewatcher_new((t_object*)x, outvol, (char*)textfile->s_name);
		filewatcher_start(EXTRA->filewatcher);
	}
	else
		object_error((t_object*)x, "preset_default : can't get the class of the patcher");
}
Ejemplo n.º 13
0
void filterview_output(t_filterview *x)
{
    t_atom argv[5];
    if(x->j_box.e_ready_to_draw)
    {
        atom_setfloat(argv, x->f_coeff_a0);
        atom_setfloat(argv+1, x->f_coeff_a1);
        atom_setfloat(argv+2, x->f_coeff_a2);
        atom_setfloat(argv+3, x->f_coeff_b1);
        atom_setfloat(argv+4, x->f_coeff_b2);
        outlet_list(x->f_out_coeffs, &s_list, 5, argv);
        
        if(x->f_type == Lowpass)
            atom_setsym(argv, gensym("lowpass"));
        else if(x->f_type == Highpass)
            atom_setsym(argv, gensym("highpass"));
        else if(x->f_type == Bandpass)
            atom_setsym(argv, gensym("bandpass"));
        else if(x->f_type == Notch)
            atom_setsym(argv, gensym("notch"));
        else if(x->f_type == Peak)
            atom_setsym(argv, gensym("peak"));
        else if(x->f_type == Lowshelf)
            atom_setsym(argv, gensym("lowshelf"));
        else if(x->f_type == Highshelf)
            atom_setsym(argv, gensym("highshelf"));
        else
            atom_setsym(argv, gensym("nothing"));
        
        atom_setfloat(argv+1, x->f_frequency);
        atom_setfloat(argv+2, x->f_gain_factor);
        atom_setfloat(argv+3, x->f_q_factor);
        outlet_anything(x->f_out_config, &s_list, 4, argv);
    }
}
Ejemplo n.º 14
0
void ep_print_credit()
{
    if(gensym("ep_print_credits")->s_thing == NULL)
    {
		t_object* print;
		t_atom* sym = (t_atom*) malloc( sizeof(t_atom));
		atom_setsym(sym, gensym("EpLib Beta 0.1"));
		print = (t_object*)object_new_typed(CLASS_BOX, gensym("print"), 1, sym);
		atom_setsym(sym, gensym("Copyright \u00a9 2014, Eliott Paris"));
		object_method_typed(print, gensym("list"), 1, sym, NULL);
		gensym("hoa_print_credits")->s_thing = print;
		freeobject(print);
		free(sym);
    }
}
Ejemplo n.º 15
0
void posit_getinfo(t_posit *x)
{
	t_object *jp;
	t_object *jb;
	t_object *pbox;
	t_rect jr;
	t_symbol *scriptingname = ps_none;
	t_symbol *patchername = ps_none;
	t_symbol *patcherscriptingname = ps_none;
	t_max_err err;
	t_symbol *classname;
	t_atom *outlist;
	outlist = x->p_outlist;
	
	err = object_obex_lookup(x, gensym("#P"), (t_object **)&jp);		// get the object's parent patcher
	if (err != MAX_ERR_NONE)
		return;
	
	err = object_obex_lookup(x, gensym("#B"), (t_object **)&jb);		// get the object's wrapping box
	if (err != MAX_ERR_NONE)
		return;
	
	patchername = jpatcher_get_name(jp);

	classname = jbox_get_maxclass(jb); // class name
	scriptingname = jbox_get_varname(jb); // scripting name
	if (scriptingname == NULL || scriptingname == ps_nothing) {
		scriptingname = ps_none;
	}
	pbox = jpatcher_get_box(jp);
	if(pbox)
		patcherscriptingname = jbox_get_varname(pbox); // scripting name
	if (patcherscriptingname == NULL || patcherscriptingname == ps_nothing) {
		patcherscriptingname = ps_none;
	}
	jbox_get_patching_rect(jb, &jr);			// x, y, width, height (double)
	atom_setsym(outlist+0,  classname);			// class name
	atom_setsym(outlist+1,  scriptingname);		// scripting name
	atom_setlong(outlist+2, (long)((long)jr.x));
	atom_setlong(outlist+3, (long)((long)jr.y));
	atom_setlong(outlist+4, (long)((long)jr.x + (long)jr.width)); 
	atom_setlong(outlist+5, (long)((long)jr.y + (long)jr.height));
	atom_setsym(outlist+6,  patchername);		// patcher name
	atom_setsym(outlist+7, patcherscriptingname);
	outlet_list(x->p_outlet,0L,8,outlist); 
		
	outlet_bang(x->p_outlet2); //bang to notify of end of dump
}
Ejemplo n.º 16
0
void folder_copy(t_folder *x, t_symbol *srcpath, t_symbol *dstpath)
{
	t_atom a;
	
	atom_setsym(&a, dstpath);
	defer(x, (method)folder_docopy, srcpath, 1, &a);
}
Ejemplo n.º 17
0
t_plugtastic* plugtastic_new()
{
	t_plugtastic*	self = (t_plugtastic*)(object_alloc(sPlugtasticClass));
	t_atom			a;
	t_class*		c;
	t_object*		p;

	c = class_findbyname(_sym_box, _sym_forward);
	if (!c) {
		p = (t_object*)newinstance(_sym_forward, 0, NULL);
		if (p) {
			c = class_findbyname(_sym_box, _sym_forward);
			freeobject(p);
			p = NULL;
		}
	}
	atom_setsym(&a, GENSYM("plugtastic_extra_toggle"));
	self->forward = (t_object*)object_new_typed(CLASS_BOX, _sym_forward, 1, &a);
	
	self->openSplash = &sPlugtasticSplash;
	a.a_type = 0;
	preferences_getatomforkey(GENSYM("plugtastic_splash"), &a);
	if (a.a_type)
		*self->openSplash = atom_getlong(&a);
		
	return self;
}
Ejemplo n.º 18
0
void *hoa_canvas_new(t_symbol *s, long argc, t_atom *argv)
{
    t_atom av[3];
    
    atom_setfloat(av, 0);
	t_hoa_canvas *x = (t_hoa_canvas *)pd_new(hoa_canvas_class);
    t_canvas* owner = canvas_getcurrent();
    x->x_canvas = canvas_new(0, 0, 0, NULL);
    canvas_vis(x->x_canvas, 0);
    pd_typedmess((t_pd *)x->x_canvas, gensym("pop"), 1, av);
    canvas_setcurrent(owner);
    
    if(argc && atom_gettype(argv) == A_SYM)
    {
        
        
        atom_setfloat(av, 0);
        atom_setfloat(av+1, 20);
        atom_setsym(av+2, atom_getsym(argv));
        pd_typedmess((t_pd *)x->x_canvas, gensym("obj"), 3, av);
    }
    
    canvas_loadbang(x->x_canvas);
    canvas_vis(x->x_canvas, 1);
    
    outlet_new((t_object *)x, &s_signal);
    return (x);
}
Ejemplo n.º 19
0
void dict_route_dictionary(t_dict_route *x, t_symbol *s)
{
	t_dictionary	*d = dictobj_findregistered_retain(s);

	if (!d) {
		object_error((t_object*)x, "unable to reference dictionary named %s", s);
		return;
	}

	if (proxy_getinlet((t_object*)x) == 0) {	
		// left inlet : validate the input against the schema

		long			validates = false;
		t_atom			a;

		validates = dictobj_validate(x->schema_dict, d);
		atom_setsym(&a, s);
		if (validates)
			outlet_anything(x->outlet_dict, _sym_dictionary, 1, &a);
		else
			outlet_anything(x->outlet_nomatch, _sym_dictionary, 1, &a);
	}
	else {
		// right inlet : set the contents of the schema with a copy of the incoming dictionary

		if (d) {
			dictionary_clear(x->schema_dict);
			dictionary_clone_to_existing(d, x->schema_dict);
		}
	}
	dictobj_release(d);
}
void max_jit_gl_spout_receiver_getavailablesenders(t_max_jit_gl_spout_receiver *x)
#endif
{
	int nSenders;
	t_atom atomName; // to send out
	string namestring; // sender name string in the list of names
	char sendername[256]; // array to clip a passed name if > 256 bytes


	SpoutReceiver * myReceiver;
	myReceiver = new SpoutReceiver;

	// post("max_jit_gl_spout_receiver_getavailablesenders");

	nSenders = myReceiver->GetSenderCount();
	if(nSenders > 0) {
	    // send a clear first.
		outlet_anything(max_jit_obex_dumpout_get(x), ps_clear, 0, 0); 
		for(int i=0; i<nSenders; i++) {
			myReceiver->GetSenderName(i, sendername);
			// post("    %s", sendername);
			atom_setsym(&atomName, gensym((char*)sendername));
			outlet_anything(x->dumpout, ps_spoutsendername, 1, &atomName); 
		}
	}

	delete myReceiver;
	myReceiver = NULL;


}
Ejemplo n.º 21
0
void omax_object_ioReport(t_object *x, t_symbol *msg, int argc, t_atom *argv)
{
	long buflen;
	char *buf = NULL;

	if(argc == 0){
		t_atom a;
		atom_setsym(&a, gensym("/*"));
		omax_object_createIOReport(x, msg, 1, &a, &buflen, &buf);
	}else{
		omax_object_createIOReport(x, msg, argc, argv, &buflen, &buf);
	}
	if(!buf){
		return;
	}
	char bundle[buflen + OSC_HEADER_SIZE];
	osc_bundle_s_setBundleID(bundle);
	memcpy(bundle + OSC_HEADER_SIZE, buf, buflen);
	void *outlet = omax_object_getInfoOutlet(x);
	if(outlet){
		t_atom out[2];
		atom_setlong(out, buflen + OSC_HEADER_SIZE);
		atom_setlong(out + 1, (long)bundle);
		outlet_anything(outlet, gensym("FullPacket"), 2, out);
	}
	if(buf){
		sysmem_freeptr(buf);
	}
}
Ejemplo n.º 22
0
void jamoma_class_attr_get(t_object *o, t_symbol *attrName, long, t_atom *)
{
	char		cAttrName[256];
	t_symbol	*sAttrName;
	char		*temp;
	long		ac = 0;
	t_atom		*av = NULL;
	t_jcom_core_subscriber_common *x = (t_jcom_core_subscriber_common*)o;
	
	strcpy(cAttrName, attrName->s_name);
	temp = strrchr(cAttrName, '/');
	if(temp)
		*temp = 0;
	sAttrName = gensym(cAttrName);

	object_attr_getvalueof(o, sAttrName, &ac, &av);
	object_obex_dumpout(o, sAttrName, ac, av);
	if(x->hub != NULL){
		char		s[256];
		t_atom		a[4];
	
		snprintf(s, 256, "%s:/%s", x->attr_name->s_name, attrName->s_name);
		atom_setsym(a+0, gensym(s));
		sysmem_copyptr(av, a+1, sizeof(t_atom) * ac);
		object_method_typed(x->hub, jps_feedback, ac + 1, a, NULL);
	}

	if(ac)
		sysmem_freeptr(av);
}
Ejemplo n.º 23
0
MaxErr OpGetOperand(OpPtr self, ObjectPtr attr, AtomCount* argc, AtomPtr* argv)
{
	TTValue v;
	
	self->audioGraphObject->getUnitGenerator()->getAttributeValue(TT("operand"), v);
	
	*argc = v.getSize();
	if (!(*argv)) // otherwise use memory passed in
		*argv = (t_atom *)sysmem_newptr(sizeof(t_atom) * v.getSize());
	
	for (int i=0; i<v.getSize(); i++) {
		if(v.getType(i) == kTypeFloat32 || v.getType(i) == kTypeFloat64){
			TTFloat64	value;
			v.get(i, value);
			atom_setfloat(*argv+i, value);
		}
		else if(v.getType(i) == kTypeSymbol){
			TTSymbol	value;
			v.get(i, value);
			atom_setsym(*argv+i, gensym((char*)value.c_str()));
		}
		else{	// assume int
			TTInt32		value;
			v.get(i, value);
			atom_setlong(*argv+i, value);
		}
	}	
	return MAX_ERR_NONE;
}
Ejemplo n.º 24
0
void model_preset_filechanged(TTPtr self, char *filename, short path)
{
	WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;
	char 		fullpath[MAX_PATH_CHARS];		// path and name passed on to the xml parser
	char		posixpath[MAX_PATH_CHARS];
	TTValue		v;
	TTSymbol    current;
	t_atom		a;

	// get current preset
	EXTRA->presetManager->get("current", v);

	path_topathname(path, filename, fullpath);
	path_nameconform(fullpath, posixpath, PATH_STYLE_NATIVE, PATH_TYPE_BOOT);

	atom_setsym(&a, gensym(posixpath));
	defer_low(self, (method)model_preset_doread, gensym("read"), 1, &a);

    /* since JamomaMax#711 : we decide to mute the triggering of the current preset

    // try to recall last current preset
	current = v[0];
	atom_setsym(&a, gensym((char*)current.c_str()));
	defer_low((t_object*)x, (method)model_preset_dorecall, NULL, 1, &a);

    */
}
Ejemplo n.º 25
0
void odisplay_anything(t_odisplay *x, t_symbol *msg, short argc, t_atom *argv)
{
	t_atom av[argc + 1];
	int ac = argc;

	if (msg) {
        ac = argc + 1;
        atom_setsym(av, msg);
        if (argc > 0) {
            memcpy(av + 1, argv, argc * sizeof(t_atom));
        }
	} else {
        memcpy(av, argv, argc * sizeof(t_atom));
	}

    t_osc_msg_u *m = NULL;
    t_osc_err e = omax_util_maxAtomsToOSCMsg_u(&m, msg, argc, argv);
    if(e){
        return;
    }
    t_osc_bndl_u *b = osc_bundle_u_alloc();
    osc_bundle_u_addMsg(b, m);
    t_osc_bndl_s *bs = osc_bundle_u_serialize(b);
    odisplay_newBundle(x, b, bs);

#ifdef OMAX_PD_VERSION
    x->draw_new_data_indicator = 1;
    x->have_new_data = 1;
    jbox_redraw((t_jbox *)x);
#else
    x->draw_new_data_indicator = 1;
    x->have_new_data = 1;
    qelem_set(x->qelem);
#endif
}
Ejemplo n.º 26
0
void tap_folder_dounzip(t_folder *x, t_symbol *s, long argc, t_atom *argv)
{
	char	name[MAX_PATH_CHARS];

#ifdef MAC_VERSION
	char	script[MAX_PATH_CHARS + 200];
	char*	tempstr = NULL;
	t_atom	a;
	
	path_nameconform(s->s_name, name, PATH_STYLE_SLASH, PATH_TYPE_BOOT);
	tempstr = strrchr(name, '/');
	if(!tempstr)
		return;
		
	*tempstr = 0;
	tempstr++;
	if(tempstr){
		snprintf(script, MAX_PATH_CHARS + 200, "do shell script \"cd \\\"%s\\\"; unzip %s\"", name, tempstr);
		atom_setsym(&a, gensym(script));
		object_method_typed(x->applescript, gensym("script"), 1, &a, NULL);
		object_method(x->applescript, _sym_bang);
	}
#else // WIN_VERSION
	; // TODO: what do we do here?
#endif
	object_obex_dumpout(x, _sym_bang, 0, NULL);
}
Ejemplo n.º 27
0
void *ramp_new(t_symbol *s, long argc, t_atom *argv)
{
	t_ramp	*x = (t_ramp *)object_alloc(ramp_class);

	if (x) {
		x->outlets[k_outlet_dumpout] = outlet_new(x, 0L);
		x->outlets[k_outlet_value]   = outlet_new(x, 0L);
		object_obex_store((void *)x, _sym_dumpout, (t_object *)x->outlets[k_outlet_dumpout]);
		x->parameterNames = new TTHash;

		x->rampUnit = NULL;

		// Set default attributes
		// @drive
		Atom a;
		atom_setsym(&a, gensym("scheduler"));
		object_attr_setvalueof(x, gensym("drive"), 1, &a);
		// @function
		object_attr_setsym(x, gensym("function"), jps_linear);

		// Now set specified attributes, if any
		attr_args_process(x, argc, argv);

	}
	return (x);		// return the pointer to our new instantiation
}
Ejemplo n.º 28
0
void cue_doedit(TTPtr self)
{
	WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;
	TTObject    aTextHandler;
	TTValue		o, args;
    t_atom		a;
	TTErr		tterr;
	
	// get the buffer handler
	tterr = x->internals->lookup(kTTSym_TextHandler, o);
	
	if (!tterr) {
		
		aTextHandler = o[0];
		
		critical_enter(0);
		tterr = aTextHandler.send(kTTSym_Read, (TTPtr)EXTRA->text);
		critical_exit(0);
		
		// output a flag
        atom_setsym(&a, gensym("closed"));
        object_obex_dumpout(self, gensym("editor"), 1, &a);
		
		if (tterr)
			object_obex_dumpout(self, _sym_error, 0, NULL);
	}
	
	delete EXTRA->text;
	EXTRA->text = NULL;
	EXTRA->textEditor = NULL;
	*EXTRA->toEdit = x->wrappedObject;
	EXTRA->cueName = kTTSymEmpty;
}
Ejemplo n.º 29
0
void inquisitor_attributes(t_inquisitor* x)
{
	t_symbol**	names = NULL;
	long		count = 0;
	t_atom*		av = NULL;
	
	if(!x->subject){
		t_object* b = jpatcher_get_firstobject(x->patcher);
		
		while(b){			
			if(x->name == jbox_get_varname(b)){
				x->subject = jbox_get_object(b);
				break;
			}
			b = jbox_get_nextobject(b);
		}
	}

	if(x->subject){
		object_attr_getnames(x->subject, &count, (t_symbol***)&names);
		if(count && names){
			av = (t_atom*)sysmem_newptr(sizeof(t_atom) * count);
			for(long i=0; i<count; i++)
				atom_setsym(av+i, names[i]);
			outlet_anything(x->outlet_names, atom_getsym(av), count-1, av+1);
			
			sysmem_freeptr(av);
			sysmem_freeptr(names);
		}
	}
}
Ejemplo n.º 30
0
void wsserver::outputData()
{
  t_atom argv[2];
  
  for (int i=0; i<getMaxNConnections(); i++) 
  {
    wsserver::ws_connection* ws_conn = getConnection(i);
    WDL_MutexLock(&ws_conn->mutex);

    if(ws_conn->newdatatoserver && ws_conn->toserver.GetLength())
    {
      atom_setlong(&argv[0], i); 

      if (strncmp(ws_conn->toserver.Get(), "cx", 2) == 0) // connected
      {
        atom_setlong(&argv[1], 1);
        outlet_anything(m_outlets[0], gensym("cx"), 2, argv);
      }
      else if (strncmp(ws_conn->toserver.Get(), "dx", 2) == 0) // disconnected
      {
        atom_setlong(&argv[1], 0);
        outlet_anything(m_outlets[0], gensym("cx"), 2, argv);
      }
      else // message
      {
        atom_setsym(&argv[1], gensym(ws_conn->toserver.Get()));
        outlet_anything(m_outlets[0], gensym("rx"), 2, argv);
      }
          
      ws_conn->newdatatoserver = false;
    }
  }
}