コード例 #1
0
t_max_err db_view_setquery(t_db_view *dbview, char *newquery)
{
	if (dbview)
		return object_attr_setsym(dbview, _sym_query, gensym(newquery));
	else
		return MAX_ERR_GENERIC;
}
コード例 #2
0
ファイル: cc.c プロジェクト: CNMAT/CNMAT-Externs
void cc_open_editor(t_cc *x){
	// this should be done only if the file was actually modified--otherwise, just use the buffer

	//post("%s ofile: %s", __PRETTY_FUNCTION__, x->ofile_fullpath);
	FILE *fp = fopen(x->cfile_fullpath, "r");
	if(fp){
		x->code_len = fread(x->code_buf, sizeof(char), x->code_buf_len, fp);
	}else{
		x->code_len = cc_write_template(x, x->code_buf);
	}
	fclose(fp);
	if(x->ed){
		object_method(x->ed, gensym("settext"), x->code_buf, gensym("utf-8"));
	}else{
		x->ed = (t_object *)object_new(CLASS_NOBOX, gensym("jed"), (t_object *)x, 0);
		if(x->have_valid_filename){
			short path;
			char filename[MAX_FILENAME_CHARS];
			if(path_frompathname(x->cfile_fullpath, &path, filename)){
				error("cc: couldn't find %s", x->cfile_fullpath);
				return;
			}
			object_method(x->ed, gensym("filename"), filename, path);
		}else{
			object_attr_setsym(x->ed, gensym("title"), gensym("Untitled"));
		}
		object_method(x->ed, gensym("settext"), x->code_buf, gensym("utf-8"));
	}

	object_attr_setchar(x->ed, gensym("visible"), 1);
}
コード例 #3
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
}
コード例 #4
0
t_max_err attr_set_hasmix(t_ui *obj, void *attr, long argc, t_atom *argv)
{
	uiInternalObject	*anObject;
	t_max_err			err = MAX_ERR_NONE;
	float				range[2];

	obj->attr_hasmix = atom_getlong(argv);
	
	if(obj->attr_hasmix){
		range[0] = 0.0;
		range[1] = 100.0;
		anObject = new uiInternalObject("jcom.parameter", "mix", obj->box.b_patcher, "decimal", "scheduler", "Controls the wet/dry mix of the module's processing routine in percent.", range, NULL, NULL, NULL);
		anObject->setAction((method)ui_mix, (t_object*)obj);
		hashtab_store(obj->hash_internals, gensym("mix"), (t_object*)anObject);
		object_attr_setsym(obj, gensym("prefix"), obj->attrPrefix);
	}
	else{
		err = hashtab_lookup(obj->hash_internals, gensym("mix"), (t_object**)&anObject);
		if(!err){
			hashtab_chuckkey(obj->hash_internals, gensym("mix"));
			delete anObject;
		}
	}
	return err;
}
コード例 #5
0
t_max_err attr_set_hasgain(t_ui *obj, void *attr, long argc, t_atom *argv)
{
	uiInternalObject	*anObject;
	t_max_err			err = MAX_ERR_NONE;
	float				range[2];

	obj->attr_hasgain = atom_getlong(argv);
	
	if(obj->attr_hasgain){
		range[0] = 0.0;
		range[1] = 127.0;
		anObject = new uiInternalObject("jcom.parameter", "gain", obj->box.b_patcher, "decimal", "scheduler", "Set gain (as MIDI value by default).", range, "gain", "midi", "midi");
		anObject->setAction((method)ui_gain, (t_object*)obj);
		hashtab_store(obj->hash_internals, gensym("gain"), (t_object*)anObject);
		object_attr_setsym(obj, gensym("prefix"), obj->attrPrefix);
	}
	else{
		err = hashtab_lookup(obj->hash_internals, gensym("gain"), (t_object**)&anObject);
		if(!err){
			hashtab_chuckkey(obj->hash_internals, gensym("gain"));
			delete anObject;
		}
	}
	return err;
}
コード例 #6
0
ファイル: j.ui.presets.cpp プロジェクト: EQ4/JamomaMax
void ui_preset_interface(t_ui *x)
{
	char			filename[MAX_FILENAME_CHARS];
	short			path;
	t_fourcc		type;
	t_fourcc		filetype = 'JSON';
	t_dictionary*	d;
	t_object*		p;
	t_atom			a;
	
	strncpy_zero(filename, "j.preset_interface.maxpat", MAX_FILENAME_CHARS);
	locatefile_extended(filename, &path, &type, &filetype, 1);
	dictionary_read(filename, path, &d);
	
	atom_setobj(&a, d);
	p = (t_object*)object_new_typed(_sym_nobox, _sym_jpatcher, 1, &a);
	object_attr_setlong(p, _sym_locked, 1);										// start out locked
	object_attr_setchar(p, _sym_enablehscroll, 0);								// turn off scroll bars
	object_attr_setchar(p, _sym_enablevscroll, 0);
	object_attr_setchar(p, _sym_openinpresentation, 1);	
	object_attr_setchar(p, _sym_toolbarvisible, 0);	
	object_attr_setsym(p, _sym_title, gensym("preset_interface"));		
	object_method_parse(p, _sym_window, "constrain 5 320 179 595", NULL);
	object_attach_byptr_register(x, p, _sym_nobox);
	
	object_method(p, _sym_vis);													// "vis" happens immediately, "front" is defer_lowed
	object_attr_setobj(jpatcher_get_firstview(p), _sym_owner, (t_object*)x);	// become the owner
	
	OBJ_ATTR_SYM(p, "arguments", 0, gensym((char*)x->modelAddress.c_str()));	// the patch needs a [j.interfaceArguments.js]
	
	object_method(p, _sym_loadbang);
}
コード例 #7
0
void setGainDataspaceUnit(t_ui* obj, t_symbol* unit)
{
	uiInternalObject	*anObject = NULL;
	t_max_err			err = MAX_ERR_NONE;
	
	err = hashtab_lookup(obj->hash_internals, gensym("gain"), (t_object**)&anObject);
	if(!err)
		object_attr_setsym(anObject->theObject, gensym("dataspace/unit/active"), unit);
}
コード例 #8
0
ファイル: dbviewer.c プロジェクト: pukulsesuatu/max6-sdk
t_max_err dbviewer_set_query(t_dbviewer *x, void *attr, long argc, t_atom *argv)
{
	if(argc && argv){
		x->d_query = atom_getsym(argv);
		object_attr_setsym(x->d_view, _sym_query, x->d_query);
		if (x->d_db && x->d_query) {
			db_view_create(x->d_db, x->d_query->s_name, &x->d_view);
			object_attach_byptr_register(x, x->d_view, _sym_nobox);
		}
	}
	return MAX_ERR_NONE;
}
コード例 #9
0
ファイル: jcom.hub.cpp プロジェクト: alexarje/JamomaModular
void hub_getstate(t_hub *x)
{
	subscriberList*		subscriber = x->subscriber;	// head of the linked list
	subscriberIterator	i;
	t_subscriber*		t;
	char*				text = NULL;
	long				textsize = 0;

	if(!x->textEditor)
		x->textEditor = (t_object*)object_new(_sym_nobox, _sym_jed, x, 0);
	
	if(!x->textSize){
		x->textSize = 4096;
		x->text = (char*)malloc(sizeof(char) * x->textSize);
	}
	x->text[0] = 0;
	
	critical_enter(0);
	for(i = subscriber->begin(); i != subscriber->end(); ++i) {
		t = *i;
		if(t->type == jps_subscribe_parameter){
			long	ac = NULL; 
			t_atom* av = NULL;
			
			object_attr_getvalueof(t->object, jps_value, &ac, &av);		// get
			atom_gettext(ac, av, &textsize, &text, 0);
			
			// this is a really lame way to do this...
			if(strlen(x->text) > (x->textSize - 1024)){
				x->textSize += 4096;
				x->text = (char*)realloc(x->text, x->textSize);
			}
			
			strncat_zero(x->text, x->osc_name->s_name, x->textSize);
			strncat_zero(x->text, "/", x->textSize);
			strncat_zero(x->text, t->name->s_name, x->textSize);
			strncat_zero(x->text, " ", x->textSize);
			strncat_zero(x->text, text, x->textSize);
			strncat_zero(x->text, "\n", x->textSize);

			sysmem_freeptr(text);
			text = NULL;
			textsize = 0;
		}
	}
	critical_exit(0);
	
	object_method(x->textEditor, _sym_settext, x->text, _sym_utf_8);
	object_attr_setchar(x->textEditor, gensym("scratch"), 1); 
	object_attr_setsym(x->textEditor, _sym_title, gensym("jamoma module state"));
	
	sysmem_freeptr(text);
}
コード例 #10
0
t_max_err paramui_setDescription(t_paramui *x, void *attr, long argc, t_atom *argv)
{
	long	textsize = 0;
	char	*text = NULL;

	if (argc) {
		atom_gettext(argc, argv, &textsize, &text, 0);
		x->attr_description = gensym(text);
		sysmem_freeptr(text);
	}
	object_attr_setsym(x->obj_parameter, gensym("description"), x->attr_description);
	return MAX_ERR_NONE;
}
コード例 #11
0
t_max_err attr_set_haspreview(t_ui *obj, void *attr, long argc, t_atom *argv)
{
	uiInternalObject	*anObject;
	t_max_err			err = MAX_ERR_NONE;

	obj->attr_haspreview = atom_getlong(argv);
	
	if(obj->attr_haspreview){
		anObject = new uiInternalObject("jcom.parameter", "preview", obj->box.b_patcher, "boolean", "none", "Turns on/off the video display in the module's preview window.", NULL, NULL, NULL, NULL);
		anObject->setAction((method)ui_preview, (t_object*)obj);
		hashtab_store(obj->hash_internals, gensym("preview"), (t_object*)anObject);
		object_attr_setsym(obj, gensym("prefix"), obj->attrPrefix);
	}
	else{
		err = hashtab_lookup(obj->hash_internals, gensym("preview"), (t_object**)&anObject);
		if(!err){
			hashtab_chuckkey(obj->hash_internals, gensym("preview"));
			delete anObject;
		}
	}
	return err;
}
コード例 #12
0
t_max_err attr_set_hasfreeze(t_ui *obj, void *attr, long argc, t_atom *argv)
{
	uiInternalObject	*anObject;
	t_max_err			err = MAX_ERR_NONE;

	obj->attr_hasfreeze = atom_getlong(argv);
	
	if(obj->attr_hasfreeze){
		anObject = new uiInternalObject("jcom.parameter", "freeze", obj->box.b_patcher, "boolean", "none", "Freezes the last frame of output from the module's processing algorithm.", NULL, NULL, NULL, NULL);
		anObject->setAction((method)ui_freeze, (t_object*)obj);
		hashtab_store(obj->hash_internals, gensym("freeze"), (t_object*)anObject);
		object_attr_setsym(obj, gensym("prefix"), obj->attrPrefix);
	}
	else{
		err = hashtab_lookup(obj->hash_internals, gensym("freeze"), (t_object**)&anObject);
		if(!err){
			hashtab_chuckkey(obj->hash_internals, gensym("freeze"));
			delete anObject;
		}
	}
	return err;
}
コード例 #13
0
t_max_err attr_set_hasbypass(t_ui *obj, void *attr, long argc, t_atom *argv)
{
	uiInternalObject	*anObject;
	t_max_err			err = MAX_ERR_NONE;

	obj->attr_hasbypass = atom_getlong(argv);
	
	if(obj->attr_hasbypass){
		anObject = new uiInternalObject("jcom.parameter", "bypass", obj->box.b_patcher, "boolean", "none", "When active, this attribute bypasses the module's processing algtorithm, letting audio or video pass through unaffected", NULL, NULL, NULL, NULL);
		anObject->setAction((method)ui_bypass, (t_object*)obj);
		hashtab_store(obj->hash_internals, gensym("bypass"), (t_object*)anObject);
		object_attr_setsym(obj, gensym("prefix"), obj->attrPrefix);
	}
	else{
		err = hashtab_lookup(obj->hash_internals, gensym("bypass"), (t_object**)&anObject);
		if(!err){
			hashtab_chuckkey(obj->hash_internals, gensym("bypass"));
			delete anObject;
		}
	}
	return err;
}
コード例 #14
0
t_max_err attr_set_hasmute(t_ui *obj, void *attr, long argc, t_atom *argv)
{
	uiInternalObject	*anObject;
	t_max_err			err = MAX_ERR_NONE;

	obj->attr_hasmute = atom_getlong(argv);
	
	if(obj->attr_hasmute){
		anObject = new uiInternalObject("jcom.parameter", "mute", obj->box.b_patcher, "boolean", "none", "When active, this attribute turns off the module's processing algorithm to save CPU", NULL, NULL, NULL, NULL);
		anObject->setAction((method)ui_mute, (t_object*)obj);
		hashtab_store(obj->hash_internals, gensym("mute"), (t_object*)anObject);
		object_attr_setsym(obj, gensym("prefix"), obj->attrPrefix);
	}
	else{
		err = hashtab_lookup(obj->hash_internals, gensym("mute"), (t_object**)&anObject);
		if(!err){
			hashtab_chuckkey(obj->hash_internals, gensym("mute"));
			delete anObject;
		}
	}
	return err;
}
コード例 #15
0
ファイル: j.unit.cpp プロジェクト: EQ4/JamomaMax
void *dataspace_new(t_symbol *name, long argc, t_atom *argv)
{
	t_dataspace *self;
	TTValue		none;
	
	self = (t_dataspace *)object_alloc(dataspace_class);
	if (self) {
		object_obex_store((void*)self, _sym_dumpout, (object*)outlet_new(self, NULL));

        // Make sure that environment sample rate is set correctly at instantiated,
        // as it is used by time dataspace for conversions to and from sample
        TTValue		sr(sys_getsr());
        ttEnvironment->setAttributeValue(kTTSym_sampleRate, sr);
        
        self->outlet_native = outlet_new(self, 0);
		TTObjectBaseInstantiate(TT("dataspace"), &self->dataspace, none);
		
		attr_args_process(self, argc, argv);
		if (!self->dataspace)
			object_attr_setsym(self, gensym("dataspace"), gensym("temperature"));
	}
	return self;
}
コード例 #16
0
ファイル: jcom.hub.cpp プロジェクト: alexarje/JamomaModular
// TODO: When running in the debugger, it seems like we are iterating through this function a whole bunch of times!
// Can we put it in a qelem or something so that it only gets called once? [TAP]
// But actually, maybe it is just a Max 4.6 funky Runtime thing?  Let's take a look again when we get to Max 5
void hub_examine_context(t_hub *x)
{
	AtomCount	argc = 0;
	AtomPtr		argv = NULL;
	SymbolPtr	context = jamoma_patcher_getcontext(x->container);

	// Try to get OSC Name of module from an argument
	jamoma_patcher_getargs(x->container, &argc, &argv);	// <-- this call allocates memory for argv
	if(argc){
		x->osc_name = atom_getsym(argv+(argc-1));
		sysmem_freeptr(argv);
	}
	else
		x->osc_name = _sym_nothing;
	
	// Try to get OSC Name of module from scripting name
	if(x->osc_name == _sym_nothing)
		x->osc_name = jamoma_patcher_getvarname(x->container);

	// In this case we overwrite whatever happened above
	if(context == gensym("toplevel")){
		x->osc_name = gensym("/editing_this_module");
		x->editing = true;
	}
	else{
		t_object*	patcher = jamoma_object_getpatcher((t_object*)x);
		t_object*	box = object_attr_getobj(patcher, jps_box);
		t_object*	ui = NULL;
		t_symbol*	objclass = NULL;
		
		x->editing = false;		
		ui = object_attr_getobj(patcher, gensym("firstobject"));
		while(ui){
			objclass = object_attr_getsym(ui, gensym("maxclass"));
			if(objclass == gensym("jcom.ui"))
				break;
			ui = object_attr_getobj(ui, gensym("nextobject"));
		}
		
		if(ui){
			t_rect	boxRect;
			t_rect	uiRect;
			
			if(context == gensym("bpatcher")){
				object_attr_get_rect(ui, _sym_presentation_rect, &uiRect);
				object_attr_get_rect(box, _sym_patching_rect, &boxRect);
				boxRect.width = uiRect.width;
				boxRect.height = uiRect.height;
				object_attr_set_rect(box, _sym_patching_rect, &boxRect);

				object_attr_get_rect(box, _sym_presentation_rect, &boxRect);
				boxRect.width = uiRect.width;
				boxRect.height = uiRect.height;
				object_attr_set_rect(box, _sym_presentation_rect, &boxRect);
			}
			else if(context == gensym("subpatcher")){
				object_attr_get_rect(ui, _sym_presentation_rect, &uiRect);
				object_attr_get_rect(patcher, _sym_defrect, &boxRect);
				boxRect.width = uiRect.width;
				boxRect.height = uiRect.height;
				object_attr_set_rect(patcher, _sym_defrect, &boxRect);				
				object_attr_setchar(patcher, _sym_toolbarvisible, 0);				
			}
		
		}
	}

	object_attr_setsym(x, _sym_name, x->osc_name);
	
	hub_subscriptions_refresh(x);
	hub_internals_create(x);

	qelem_unset(x->init_qelem);		// clear the last thing to make sure we don't call into this a bunch of times
	qelem_set(x->init_qelem);		// flag the queue for initialization
}
コード例 #17
0
ファイル: j.cue.cpp プロジェクト: Rocknrenew/JamomaMax
void cue_edit(TTPtr self, t_symbol *msg, long argc, const t_atom *argv)
{
	WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;
	TTString			*buffer;
	char				title[MAX_FILENAME_CHARS];
	TTObject            aTextHandler;
	TTHashPtr			allCues;
	TTValue				v, o;
	TTSymbol			name = kTTSymEmpty;
    t_atom				a;
	TTErr				tterr;
	
	// choose object to edit : default the cuelist
	*EXTRA->toEdit = x->wrappedObject;
	EXTRA->cueName = kTTSymEmpty;
	
	if (argc && argv)
    {
		if (atom_gettype(argv) == A_LONG)
        {
            TTUInt32 index = atom_getlong(argv);
			
			// get cues names
			x->wrappedObject.get("names", v);
			
			if (index > 0 && index <= v.size())
				name = v[index-1];
			else
            {
				object_error((t_object*)x, "%d doesn't exist", atom_getlong(argv));
				return;
			}
		}
		else if (atom_gettype(argv) == A_SYM)
			name = TTSymbol(atom_getsym(argv)->s_name);
		
		if (name != kTTSymEmpty)
        {
			// get cue object table
			x->wrappedObject.get("cues", v);
			allCues = TTHashPtr((TTPtr)v[0]);
			
			if (allCues)
            {
				// get cue to edit
				if (!allCues->lookup(name, v))
                {
					// edit a cue
					*EXTRA->toEdit = v[0];
					EXTRA->cueName = name;
				}
				else
                {
					object_error((t_object*)x, "%s doesn't exist", atom_getsym(argv)->s_name);
					return;
				}
			}
		}
	}
	
	// only one editor can be open in the same time
	if (!EXTRA->textEditor) {
		
		EXTRA->textEditor = (t_object*)object_new(_sym_nobox, _sym_jed, x, 0);
		
		buffer = new TTString();
		
		// get the buffer handler
		tterr = x->internals->lookup(kTTSym_TextHandler, o);
		
		if (!tterr) {
			
			aTextHandler = o[0];
			
			critical_enter(0);
			aTextHandler.set(kTTSym_object, *EXTRA->toEdit);
			tterr = aTextHandler.send(kTTSym_Write, (TTPtr)buffer);
			critical_exit(0);
		}
		
		// pass the buffer to the editor
		object_method(EXTRA->textEditor, _sym_settext, buffer->c_str(), _sym_utf_8);
		object_attr_setchar(EXTRA->textEditor, gensym("scratch"), 1);
		
		snprintf(title, MAX_FILENAME_CHARS, "cuelist editor");
		object_attr_setsym(EXTRA->textEditor, _sym_title, gensym(title));
        
        // output a flag
        atom_setsym(&a, gensym("opened"));
        object_obex_dumpout(self, gensym("editor"), 1, &a);
		
		buffer->clear();
		delete buffer;
		buffer = NULL;
	}
    else
    {
        object_attr_setchar(EXTRA->textEditor, gensym("visible"), 1);
    }
}
コード例 #18
0
int main(void)
{
	common_symbols_init();
	PlugtasticInit();

	plugtastic_classinit();
	sPlugtasticObject = (t_object*)plugtastic_new();
	ps_plugtastic = GENSYM("plugtastic");
	ps_plugtastic->s_thing = sPlugtasticObject;

	sMaxObject = _sym_max->s_thing;
	ps_objectfile				= GENSYM("objectfile");
	ps_db_object_addinternal	= GENSYM("db.object_addinternal");
	ps_oblist					= GENSYM("oblist");
	ps_db_addmetadata			= GENSYM("db.addmetadata");
	
	//defer_low(sMaxObject, (method)plug_setup_db, NULL, 0, NULL);
	plug_setup_db();
	
	post("Plugtastic                                            Version %s | 74Objects.com", PLUGTASTIC_VERSION);
	

	// This tells Max 5.0.6 and higher that we want the patcher files to be saved such that they are sorted.
	// Having the saved this way makes our SVN diffs much more meaningful.
	object_method_long(sMaxObject, GENSYM("sortpatcherdictonsave"), 1, NULL);
	
	// This tells Max 4.5.7 and higher to take any posts to the Max window and also make the
	// post to the system console, which greatly aids in debugging problems and crashes
	object_method_long(sMaxObject, GENSYM("setmirrortoconsole"), 1, NULL);
	
	
	// OPEN THE SPLASH
	
	if (sPlugtasticSplash) {
		char			name[MAX_FILENAME_CHARS];
		short			path = 0;
		long			type = 0;
		long			typelist[2] = {'JSON', 'TEXT'};
		short			err;
		t_dictionary*	d;
		t_object*		p;
		t_atom			a[2];
		
		strncpy_zero(name, "Plugtastic.maxpat", MAX_FILENAME_CHARS);
		err = locatefile_extended(name, &path, &type, typelist, 2);
		dictionary_read(name, path, &d);
		
		atom_setobj(a, d);
		p = (t_object*)object_new_typed(_sym_nobox, _sym_jpatcher, 1, a);
		object_attr_setlong(p, _sym_locked, 1);			// start out locked
		object_attr_setchar(p, _sym_enablehscroll, 0);		// turn off scroll bars
		object_attr_setchar(p, _sym_enablevscroll, 0);
		object_attr_setchar(p, _sym_toolbarvisible, 0);	
		object_attr_setsym(p, _sym_title, gensym("Welcome to Plugtastic"));		
		object_attr_setparse(p, _sym_rect, "271 170 799 489");
		object_attr_setparse(p, _sym_defrect, "271 170 799 489");

		object_method(p, _sym_vis);	// "vis" happens immediately, "front" is defer_lowed
		object_method(p, _sym_loadbang);

//		object_method_parse(p, _sym_window, "constrain 799 489 799 489", NULL);
		object_method_parse(p, _sym_window, "flags nozoom", NULL);
		object_method_parse(p, _sym_window, "flags nogrow", NULL);
		object_method_parse(p, _sym_window, "exec", NULL);
	}	
	
	
	return 0;
}