Exemple #1
0
void scripto_dblclick(t_scripto *x)
{
	if (x->s_patcher)
		object_method(x->s_patcher, gensym("vis"));
	else {
		t_dictionary *d = dictionary_new();
		char parsebuf[256];
		t_atom a;
		long ac = 0;
		t_atom *av = NULL;

		// create a patcher without scroll bars and a toolbar
		sprintf(parsebuf,"@defrect 0 0 300 400 @title scripto @enablehscroll 0 @enablevscroll 0 @presentation 0 @toolbarid \"\"");
		atom_setparse(&ac,&av,parsebuf);
		attr_args_dictionary(d,ac,av);
		atom_setobj(&a,d);
		sysmem_freeptr(av);
		x->s_patcher = (t_object *)object_new_typed(CLASS_NOBOX,gensym("jpatcher"),1, &a);
		freeobject((t_object *)d);	// we created this dictionary and we don't need it anymore

		object_method(x->s_patcher,gensym("vis"));
		x->s_ui = newobject_sprintf(x->s_patcher, "@maxclass scripto_ui @patching_rect 0 0 300 400 @oncolor %.2f %.2f %.2f %.2f @offcolor %.2f %.2f %.2f %.2f",
									x->s_oncolor.red, x->s_oncolor.green, x->s_oncolor.blue, x->s_oncolor.alpha, x->s_offcolor.red, x->s_offcolor.green, x->s_offcolor.blue, x->s_offcolor.alpha);
		object_attach_byptr_register(x, x->s_ui, CLASS_BOX);			// attach our UI object to us
		object_attach_byptr_register(x, x->s_patcher, CLASS_NOBOX);		// attach our UI object to us
	}
}
Exemple #2
0
// Start keeping track of edits and connections in the patcher
void PackStartTracking(PackPtr self)
{
	ObjectPtr	patcher = NULL;
	ObjectPtr	parent = NULL;
	ObjectPtr	patcherview = NULL;
	MaxErr		err;
	Atom		result;
	
	// first find the top-level patcher
	err = object_obex_lookup(self, gensym("#P"), &patcher);
	parent = patcher;
	while (parent) {
		patcher = parent;
		parent = object_attr_getobj(patcher, _sym_parentpatcher);
	}
	
	// now iterate recursively from the top-level patcher down through all of the subpatchers
	object_method(patcher, gensym("iterate"), (method)PackIterateResetCallback, self, PI_DEEP, &result);
	object_method(patcher, gensym("iterate"), (method)PackIterateSetupCallback, self, PI_DEEP, &result);
	
	
	// now let's attach to the patcherview to get notifications about any further changes to the patch cords
	// the patcher 'dirty' attribute is not modified for each change, but the patcherview 'dirty' attribute is
	if (!self->patcherview) {
		patcherview = jpatcher_get_firstview(patcher);
		self->patcherview = patcherview;
		self->patcher = patcher;
		object_attach_byptr_register(self, patcherview, _sym_nobox);			
	}

	// now we want to go a step further and attach to all of the patch cords 
	// this is how we will know if one is deleted
	PackAttachToPatchlinesForPatcher(self, self->patcher);
}
Exemple #3
0
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);
}
Exemple #4
0
void omax_init(t_object *x)
{
	t_omax *osc = omax_object_getOmaxObj(x);
	if(!osc){
		return;
	}
	osc->continuation_outlet = outlet_new(x, "FullPacket");
	osc->info_outlet = outlet_new(x, "FullPacket");
	object_attach_byptr_register(x, x, CLASS_BOX);
}
Exemple #5
0
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;
}
Exemple #6
0
void iterator_attach(t_iterator *x)
{
	t_atom *av = NULL;
	long ac = 0;

	x->a_patcherview = object_attr_getobj(x->a_patcher, gensym("firstview"));
	object_attach_byptr_register(x, x->a_patcherview, CLASS_NOBOX);

	// get the bounds of the first patcherview and cache them
	object_attr_getvalueof(x->a_patcherview, gensym("rect"), &ac, &av);
	if (ac && av) {
		x->a_cached.x = atom_getfloat(av+2); // width
		x->a_cached.y = atom_getfloat(av+3); // height
		freebytes(av, sizeof(t_atom) * ac); // or sysmem_freeptr()
	}
}
Exemple #7
0
t_max_err dbviewer_set_database(t_dbviewer *x, void *attr, long argc, t_atom *argv)
{
	t_max_err err;
	
	if(argc && argv){
		db_view_remove(x->d_db, &x->d_view);
		db_close(&x->d_db);
		
		x->d_database = atom_getsym(argv);
		err = db_open(x->d_database, NULL, &x->d_db);
		if (!err && 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;
}
void UnpackAttachToPatchlinesForPatcher(UnpackPtr self, ObjectPtr patcher)
{
	ObjectPtr	patchline = object_attr_getobj(patcher, _sym_firstline);
	ObjectPtr	box = jpatcher_get_firstobject(patcher);
	
	while (patchline) {
		object_attach_byptr_register(self, patchline, _sym_nobox);
		patchline = object_attr_getobj(patchline, _sym_nextline);
	}
		
	while (box) {
		SymbolPtr	classname = jbox_get_maxclass(box);
		
		if (classname == _sym_jpatcher) {
			ObjectPtr	subpatcher = jbox_get_object(box);
			
			UnpackAttachToPatchlinesForPatcher(self, subpatcher);
		}
		box = jbox_get_nextobject(box);
	}
}
Exemple #9
0
void OutAttachToPatchlinesForPatcher(OutPtr self, t_object* patcher)
{
	t_object*	patchline = object_attr_getobj(patcher, _sym_firstline);
	t_object*	box = jpatcher_get_firstobject(patcher);

	while (patchline) {
		object_attach_byptr_register(self, patchline, _sym_nobox);
		patchline = object_attr_getobj(patchline, _sym_nextline);
	}

	while (box) {
		t_symbol *classname = jbox_get_maxclass(box);

		if (classname == _sym_jpatcher) {
			t_object*	subpatcher = jbox_get_object(box);

			OutAttachToPatchlinesForPatcher(self, subpatcher);
		}
		box = jbox_get_nextobject(box);
	}
}
Exemple #10
0
void testrunner_one_integration(t_testrunner *r, t_symbol *testname)
{
	t_testdb	*db = (t_testdb*)((t_testmaster*)(ps_testmaster->s_thing))->m_db;
	t_symbol	*pound_t = gensym("#T");
	
	if (!r->r_running) { // start it
		t_testunit	*testunit = (t_testunit*)testunit_new(NULL, 0, NULL);
		
		r->r_testid = testdb_createcase(db, testname->s_name);
		testunit->o_db = db;
		testunit->o_id = r->r_testid;
		testdb_log(db, r->r_testid, "preparing to run %s", testname->s_name);

		pound_t->s_thing = (t_object*)testunit;
		object_method(_sym_max->s_thing, _sym_openfile, symbol_unique(), testname, 0);
		
		object_attach_byptr_register(r, testunit, _sym_nobox);
		r->r_testunit = (t_test*)testunit;
		r->r_running = true;
	}
	else { // try to finish it
		if (r->r_terminated) {
			t_max_err	err = MAX_ERR_NONE;
			
			// moved to here from the block above because when loading a maxzip the patcher instantiation maybe deferred/asynchronous
			pound_t->s_thing = NULL;

			testdb_log(db, r->r_testid, "concluding test");
			
			err = object_free(r->r_testunit);
			
			testdb_log(db, r->r_testid, "test patcher freed with status %i", err);
			testdb_closecase(db, r->r_testid);	

			r->r_running = false;
			return;
		}
	}
	qelem_set(r->r_qelem);
}
// DSP Method
void UnpackDsp64(UnpackPtr self, ObjectPtr dsp64, short *count, double samplerate, long maxvectorsize, long flags)
{
	TTUInt16	i;
	MaxErr		err;
	long		result = 0;
	
	self->vectorSize = maxvectorsize;
	
#ifdef DEBUG_NOTIFICATIONS
	object_post(SELF, "dsp method called");
#endif // DEBUG_NOTIFICATIONS
	
	/*	We need to figure out what objects are connected to what inlets to build the graph:
	 
	 1. Broadcast 'audio.reset' to every object in the patcher, to remove all existing connections.
	 2. Broadcast 'audio.setup' to every object in the patcher, to tell objects to then send
	 'audio.connect' messages to any objects below them.
	 3. When an object received 'audio.connect', then it makes the connection.
	 
	 At this point, the graph is configured and we just need to execute it.
	 We execute the graph from our perform method, which MSP calls once per signal vector.
	 
	 5. Crawl the graph from bottom to top, calling the audio graph preprocess method (prepare for process)
	 6. Crawl the graph from bottom to top, calling the audio graph process method (calculate the samples)
	 7. (Maybe) crawl the graph from bottom to top, calling a audio graph postprocess method
	 
	 For steps 1 & 2, we have to traverse thge patcher twice, 
	 because we have to clear all connections first, then add connections.
	 It won't work to do them both during the same traversal because situations arise
	 Where we setup the chain and then it gets reset again by another object 
	 (since the order in which we traverse objects is undefined).
	 */ 
	
	if (!self->hasReset) {
		ObjectPtr	patcher = NULL;
		ObjectPtr	parent = NULL;
		ObjectPtr	patcherview = NULL;
		
		// first find the top-level patcher
		err = object_obex_lookup(self, gensym("#P"), &patcher);
		parent = patcher;
		while (parent) {
			patcher = parent;
			parent = object_attr_getobj(patcher, _sym_parentpatcher);
		}
		
		// now iterate recursively from the top-level patcher down through all of the subpatchers
		object_method(patcher, gensym("iterate"), (method)UnpackIterateResetCallback, self, PI_DEEP, &result);
		object_method(patcher, gensym("iterate"), (method)UnpackIterateSetupCallback, self, PI_DEEP, &result);
		
		// now let's attach to the patcherview to get notifications about any further changes to the patch cords
		// the patcher 'dirty' attribute is not modified for each change, but the patcherview 'dirty' attribute is
		if (!self->patcherview) {
			patcherview = jpatcher_get_firstview(patcher);
			self->patcherview = patcherview;
			self->patcher = patcher;
			object_attach_byptr_register(self, patcherview, _sym_nobox);			
		}
	}
	
	// now we want to go a step further and attach to all of the patch cords 
	// this is how we will know if one is deleted
	UnpackAttachToPatchlinesForPatcher(self, self->patcher);
		
	self->numChannels = 0;
	for (i=1; i <= self->maxNumChannels; i++) {
		self->numChannels++;
	}
	
	self->audioGraphObject->getUnitGenerator()->setAttributeValue(kTTSym_sampleRate, samplerate);
	self->audioGraphObject->resetSampleStamp();
	self->sampleStamp = 0;
	
	self->initData.vectorSize = self->vectorSize;
	
	object_method(dsp64, gensym("dsp_add64"), self, UnpackPerform64, 0, NULL);
	//dsp_add64(dsp64, (ObjectPtr)self, (t_perfroutine64)UnpackPerform64, 0, NULL);
}
Exemple #12
0
void *cc_new(t_symbol *msg, short argc, t_atom *argv){
	t_cc *x;

	if(x = (t_cc *)object_alloc(cc_class)){
#if defined(CC_JBOX)
		t_dictionary *d = NULL; 
		long boxflags; 

		if(!(d = object_dictionaryarg(argc, argv))){ 
			return NULL; 
		} 
    
		boxflags = 0 
			| JBOX_DRAWFIRSTIN 
			//| JBOX_NODRAWBOX
			| JBOX_DRAWINLAST
			//| JBOX_TRANSPARENT  
			//      | JBOX_NOGROW
			//| JBOX_GROWY
			| JBOX_GROWBOTH
			//      | JBOX_HILITE
			| JBOX_BACKGROUND
			| JBOX_DRAWBACKGROUND
			//      | JBOX_NOFLOATINSPECTOR
			//      | JBOX_MOUSEDRAGDELTA
			//      | JBOX_TEXTFIELD
			;
		jbox_new((t_jbox *)x, boxflags, argc, argv); 
#if defined(CC_MSP)
		x->ob.z_box.b_firstin = (void *)x;
#else
 		x->ob.b_firstin = (void *)x; 
#endif
#endif
		x->ht = (t_hashtab *)hashtab_new(0);
		hashtab_flags(x->ht, OBJ_FLAG_DATA);

		x->ok_to_compile = 1;
		x->compiling = 0;
		x->have_valid_filename = 0;

		x->build_path_is_tmp = 1;

		x->ed = NULL;
		x->code_buf_len = BUFSIZE;
		x->code_buf = (char *)calloc(BUFSIZE, sizeof(char));

		x->cfile_path = (char *)calloc(MAX_FILENAME_CHARS, sizeof(char));
		x->build_path = (char *)calloc(MAX_FILENAME_CHARS, sizeof(char));
		x->basename = (char *)calloc(MAX_FILENAME_CHARS, sizeof(char));

		x->cfile_fullpath = (char *)calloc(MAX_PATH_CHARS, sizeof(char));
		x->ofile_fullpath = (char *)calloc(MAX_PATH_CHARS, sizeof(char));
		x->dfile_fullpath = (char *)calloc(MAX_PATH_CHARS, sizeof(char));
		x->logfile_fullpath = (char *)calloc(MAX_PATH_CHARS, sizeof(char));

		x->path_to_maxsdk = gensym("");
		x->user_obj = (char *)calloc(OBJSIZE, sizeof(char));

		x->verbose = 0;

		long ic = (long)(ps_cc_instance_count->s_thing);
		ic += 1;
		ps_cc_instance_count->s_thing = (void *)ic;

#if defined(CC_MSP) && defined(CC_JBOX)
		sprintf(x->basename, "cc_jbox~_%ld", (long)ps_cc_instance_count->s_thing);
#elif defined(CC_MSP)
		sprintf(x->basename, "cc~_%ld", (long)ps_cc_instance_count->s_thing);
#elif defined(CC_JBOX)
		sprintf(x->basename, "cc_jbox_%ld", (long)ps_cc_instance_count->s_thing);
#else
		sprintf(x->basename, "cc_%ld", (long)ps_cc_instance_count->s_thing);
#endif

		short tmpdir;
		sprintf(x->build_path, "/private/var/tmp");
		char fn[512];
		path_frompathname(x->build_path, &tmpdir, fn);
		x->build_path_id = tmpdir;

		//sprintf(x->cfile_fullpath, "%s/%s.c", x->build_path, x->basename);
		sprintf(x->ofile_fullpath, "%s/%s.o", x->build_path, x->basename);
		sprintf(x->dfile_fullpath, "%s/%s.dylib", x->build_path, x->basename);
		sprintf(x->logfile_fullpath, "%s/%s.log", x->build_path, x->basename);

		x->code_len = cc_write_template(x, x->code_buf);

		x->function_names = (t_symbol **)calloc(128, sizeof(t_symbol *));

		x->ninlets = 1;
		x->noutlets = 1;

		x->def_cflags = (char *)calloc(4096, sizeof(char));
		x->def_ldflags = (char *)calloc(4096, sizeof(char));

		char *sdk = x->path_to_maxsdk->s_name;

#if defined(CC_MSP)
		sprintf(x->def_cflags, CFLAGS, sdk, sdk, sdk, sdk, sdk);
		sprintf(x->def_ldflags, LDFLAGS, sdk, sdk);
#else
		sprintf(x->def_cflags, CFLAGS, sdk, sdk, sdk);
		sprintf(x->def_ldflags, LDFLAGS, sdk);
#endif

		x->user_cflags = gensym("");
		x->user_ldflags = gensym("");

#ifdef CC_JBOX
		x->user_paint = NULL;
#endif

#if !defined(CC_JBOX)
		attr_args_process(x, argc, argv);
#else
		attr_dictionary_process(x, d);
#endif

		int i;
#if defined(CC_MSP)
#if defined(CC_JBOX)
		dsp_setupjbox((t_pxjbox *)x, x->nsiginlets);
#else
		dsp_setup((t_pxobject *)x, x->nsiginlets);
#endif
		for(i = 0; i < x->nsigoutlets; i++){
			outlet_new((t_object *)x, "signal");
		}
		x->svin = (t_float **)calloc(x->nsiginlets, sizeof(t_float *));
		x->svout = (t_float **)calloc(x->nsigoutlets, sizeof(t_float *));
#endif
		x->proxies = (void **)calloc(x->ninlets - 1, sizeof(void *));
		for(i = 0; i < x->ninlets - 1; i++){
			x->proxies[0] = proxy_new((t_object *)x, x->ninlets - (i + 1), &(x->inlet));
		}
#if !defined(CC_MSP)
		x->outlets = (void **)calloc(x->noutlets, sizeof(void *));
		for(i = x->noutlets - 1; i >= 0; i--){
			x->outlets[i] = outlet_new((t_object *)x, NULL);
		}
#endif

		x->handle = NULL;

		object_attach_byptr_register(x, x, CLASS_BOX);

#ifdef CC_JBOX
		jbox_ready((t_jbox *)x);
#endif
		return x;
	}
	return NULL;
}
Exemple #13
0
void connect_attach(t_connect *x)
{
	object_obex_lookup(x, gensym("#P"), &x->f_patcher);
	x->f_patcherview = object_attr_getobj(x->f_patcher, hoa_sym_firstview);
	object_attach_byptr_register(x, x->f_patcherview, CLASS_NOBOX);
}
Exemple #14
0
// DSP Method
void OutDsp(OutPtr self, t_signal** sp, short* count)
{
	//TTUInt16	i;
	TTUInt16	k=0;
	void		**audioVectors = NULL;
	t_max_err		err;
	long		result = 0;

	self->vectorSize = sp[0]->s_n;

	#ifdef DEBUG_NOTIFICATIONS
	object_post(SELF, "dsp method called");
	#endif // DEBUG_NOTIFICATIONS

	/*	We need to figure out what objects are connected to what inlets to build the graph:

		1. Broadcast 'audio.reset' to every object in the patcher, to remove all existing connections.
		2. Broadcast 'audio.setup' to every object in the patcher, to tell objects to then send
			'audio.connect' messages to any objects below them.
		3. When an object received 'audio.connect', then it makes the connection.

		At this point, the graph is configured and we just need to execute it.
		We execute the graph from our perform method, which MSP calls once per signal vector.

		5. Crawl the graph from bottom to top, calling the audio graph preprocess method (prepare for process)
		6. Crawl the graph from bottom to top, calling the audio graph process method (calculate the samples)
		7. (Maybe) crawl the graph from bottom to top, calling a audio graph postprocess method

		For steps 1 & 2, we have to traverse thge patcher twice,
		because we have to clear all connections first, then add connections.
		It won't work to do them both during the same traversal because situations arise
		Where we setup the chain and then it gets reset again by another object
		(since the order in which we traverse objects is undefined).
	 */

	if (!self->hasReset) {
		t_object*	patcher = NULL;
		t_object*	parent = NULL;
		t_object*	patcherview = NULL;

		// first find the top-level patcher
		err = object_obex_lookup(self, gensym("#P"), &patcher);
		parent = patcher;
		while (parent) {
			patcher = parent;
			parent = object_attr_getobj(patcher, _sym_parentpatcher);
		}

		// now iterate recursively from the top-level patcher down through all of the subpatchers
		object_method(patcher, gensym("iterate"), (method)OutIterateResetCallback, self, PI_DEEP, &result);
		object_method(patcher, gensym("iterate"), (method)OutIterateSetupCallback, self, PI_DEEP, &result);

		// now let's attach to the patcherview to get notifications about any further changes to the patch cords
		// the patcher 'dirty' attribute is not modified for each change, but the patcherview 'dirty' attribute is
		if (!self->patcherview) {
			patcherview = jpatcher_get_firstview(patcher);
			self->patcherview = patcherview;
			self->patcher = patcher;
			object_attach_byptr_register(self, patcherview, _sym_nobox);
		}
	}

	// now we want to go a step further and attach to all of the patch cords
	// this is how we will know if one is deleted
	OutAttachToPatchlinesForPatcher(self, self->patcher);

	// Setup the perform method
	//audioVectors = (void**)sysmem_newptr(sizeof(void*) * (self->maxNumChannels + 1));
	audioVectors = (void**)sysmem_newptr(sizeof(void*) * (1));

	audioVectors[k] = self;
	k++;

	//self->numChannels = 0;
	/*for (i=1; i <= self->maxNumChannels; i++) {
		self->numChannels++;
		audioVectors[k] = sp[i]->s_vec;
		k++;
	}*/
	self->numChannels = self->maxNumChannels; //[np]
	self->audioGraphObject->getUnitGenerator().get(kTTSym_sampleRate, sp[0]->s_sr);
	self->audioGraphObject->resetSampleStamp();
	self->sampleCount = 0;

	dsp_addv(OutPerform, k, audioVectors);
	sysmem_freeptr(audioVectors);

	self->initData.vectorSize = self->vectorSize;
}
void ww_attach(t_ww *x)
{
	x->w_patcherview = object_attr_getobj(x->w_patcher, gensym("firstview"));
	object_attach_byptr_register(x, x->w_patcherview, CLASS_NOBOX);
}