Esempio n. 1
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);
}
Esempio n. 2
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);
}
Esempio n. 3
0
void iterator_free(t_iterator *x)
{
	t_object *jp = NULL;
	t_object *pv;

	// detach from any objects that you have attached to.
	object_obex_lookup(x, gensym("#P"), &jp);
	if (jp) {
		pv = jpatcher_get_firstview(jp);
		object_detach_byptr(x, pv);
	}
}
Esempio n. 4
0
// 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);
}
Esempio n. 5
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;
}