Esempio n. 1
0
void model_preset_dowrite_again(TTPtr self)
{
	WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;
	TTObject        aTextHandler;
	TTValue			o;
	TTErr			tterr;

    // stop filewatcher
	if (EXTRA->filewatcher)
		filewatcher_stop(EXTRA->filewatcher);

	tterr = x->internals->lookup(kTTSym_TextHandler, o);

	if (!tterr) {

		aTextHandler = o[0];

		aTextHandler.set(kTTSym_object, *EXTRA->presetManager);

		critical_enter(0);
		tterr = aTextHandler.send(kTTSym_WriteAgain);
		critical_exit(0);

		if (!tterr)
			object_obex_dumpout(self, _sym_write, 0, NULL);
		else
			object_obex_dumpout(self, _sym_error, 0, NULL);
	}

    // start filewatcher
	if (EXTRA->filewatcher)
		filewatcher_start(EXTRA->filewatcher);
}
Esempio n. 2
0
void cue_dowrite(TTPtr self, t_symbol *msg, long argc, t_atom *argv)
{
	WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;
	char 			filename[MAX_FILENAME_CHARS];
	TTSymbol		fullpath;
	TTValue			o, v;
	TTObject        aTextHandler;
	TTErr			tterr;
	
	if (x->wrappedObject.valid()) {
		
		// Default TEXT File Name
		snprintf(filename, MAX_FILENAME_CHARS, "untitled.cues.txt");
		
		fullpath = jamoma_file_write((t_object*)x, argc, argv, filename);
		v.append(fullpath);
		
		tterr = x->internals->lookup(kTTSym_TextHandler, o);
		
		if (!tterr) {
			aTextHandler = o[0];

			aTextHandler.set(kTTSym_object, x->wrappedObject);
			
			critical_enter(0);
			tterr = aTextHandler.send(kTTSym_Write, v);
			critical_exit(0);
			
			if (!tterr)
				object_obex_dumpout(self, _sym_write, argc, argv);
			else
				object_obex_dumpout(self, _sym_error, 0, NULL);
		}
	}
}
Esempio n. 3
0
void cue_dowrite_again(TTPtr self)
{	
	WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;
	TTValue			o, v;
	TTObject        aTextHandler;
	TTErr			tterr;
	
	if (x->wrappedObject.valid()) {
		
		tterr = x->internals->lookup(kTTSym_TextHandler, o);
		
		if (!tterr) {
			
			aTextHandler = o[0];

			aTextHandler.set(kTTSym_object, x->wrappedObject);
			
			critical_enter(0);
			tterr = aTextHandler.send(kTTSym_WriteAgain, v);
			critical_exit(0);
			
			if (!tterr)
				object_obex_dumpout(self, _sym_write, 0, NULL);
			else
				object_obex_dumpout(self, _sym_error, 0, NULL);
		}
	}
}
Esempio n. 4
0
void model_preset_doread_again(TTPtr self)
{
	WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;
	TTObject        aTextHandler;
	TTValue			o;
	TTErr			tterr;

	tterr = x->internals->lookup(kTTSym_TextHandler, o);

	if (!tterr) {

		aTextHandler = o[0];

		aTextHandler.set(kTTSym_object, *EXTRA->presetManager);

		critical_enter(0);
		tterr = aTextHandler.send(kTTSym_ReadAgain);
		critical_exit(0);

		if (!tterr)
			object_obex_dumpout(self, _sym_read, 0, NULL);
		else
			object_obex_dumpout(self, _sym_error, 0, NULL);
	}
}
Esempio n. 5
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;
}
Esempio n. 6
0
void cue_doread(TTPtr self, t_symbol *msg, long argc, t_atom *argv)
{	
	WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;
	TTValue			o, v;
	TTSymbol		fullpath;
	TTObject		aTextHandler;
	TTErr			tterr;
	
	if (x->wrappedObject.valid()) {
		
		fullpath = jamoma_file_read((t_object*)x, argc, argv, (t_fourcc)'TEXT');
		v.append(fullpath);
		
		tterr = x->internals->lookup(kTTSym_TextHandler, o);
		
		if (!tterr) {
			
			aTextHandler = o[0];

			aTextHandler.set(kTTSym_object, x->wrappedObject);
			
			critical_enter(0);
			tterr = aTextHandler.send(kTTSym_Read, v);
			critical_exit(0);
			
			if (!tterr)
				object_obex_dumpout(self, _sym_read, argc, argv);
			else
				object_obex_dumpout(self, _sym_error, 0, NULL);
		}
	}
}
Esempio n. 7
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);
}
Esempio n. 8
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);
}
Esempio n. 9
0
TTErr wrappedModularClass_setAttribute(TTPtr self, t_symbol *s, long argc, const t_atom *argv)
{
	WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;
	TTValue			inputValue, outputValue;
	TTSymbol		ttName;
	TTAttributePtr	anAttribute= NULL;
	long            ac = 0;
	t_atom			*av = NULL;
	TTErr			err;
	
	err = selectedObject->findAttribute(TTSymbol(s->s_name), &anAttribute);
	if (!err) {
		
		// set attribute's value
		if (argc && argv) {
			jamoma_ttvalue_from_Atom(inputValue, _sym_nothing, argc, argv);
			selectedObject->setAttributeValue(TTSymbol(s->s_name), inputValue);
		}
		// or get it and dumpout his value
		else {
			selectedObject->getAttributeValue(TTSymbol(s->s_name), outputValue);
			
			jamoma_ttvalue_to_Atom(outputValue, &ac, &av);
			object_obex_dumpout(self, s, ac, av);
			sysmem_freeptr(av);
		}
	}
	
	return err;
}
Esempio n. 10
0
void folder_docopy(t_folder *x, t_symbol *srcin, long argc, t_atom *argv)
{
	t_symbol*	dstin = atom_getsym(argv);
	char		srcname[MAX_PATH_CHARS];
	short		srcpath = 0;
	char		srcfilename[MAX_FILENAME_CHARS];
	char		dstname[MAX_PATH_CHARS];
	short		dstpath = 0;
	char		dstfilename[MAX_FILENAME_CHARS];
	short		newpath = 0;
	char*		tempstr = NULL;
	
	strncpy_zero(srcname, srcin->s_name, MAX_PATH_CHARS);
	path_frompathname(srcname, &srcpath, srcfilename);

	strncpy_zero(dstname, dstin->s_name, MAX_PATH_CHARS);
	tempstr = strrchr(dstname, '/');
	*tempstr = 0;
	tempstr++;
	path_frompathname(dstname, &dstpath, dstfilename);
	if (tempstr)
		strncpy_zero(dstfilename, tempstr, MAX_FILENAME_CHARS);

	if (!srcfilename[0])
		path_copyfolder(srcpath, dstpath, dstfilename, true, &newpath);
	else
		path_copyfile(srcpath, srcfilename, dstpath, dstfilename);
	object_obex_dumpout(x, _sym_bang, 0, NULL);
}
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
void dataspace_getUnits(t_dataspace *self)
{
	t_atom	a[2];
	TTValue	v;
	
	atom_setsym(a+0, gensym("clear"));
	object_obex_dumpout(self, gensym("UnitMenu"), 1, a);
	
	self->dataspace->sendMessage(TT("getAvailableUnits"), v, v);	
	for (int i=0; i < v.getSize(); i++) {
		TTSymbol	name;
		
		v.get(i, name);
		atom_setsym(a+0, gensym("append"));
		atom_setsym(a+1, gensym(name.c_str()));
		object_obex_dumpout(self, gensym("UnitMenu"), 2, a);
	}
}
Esempio n. 13
0
TTErr wrappedModularClass_sendMessage(TTPtr self, t_symbol *s, long argc, const t_atom *argv)
{
	WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;
	TTValue			inputValue, outputValue;
	TTSymbol		ttName;
	TTMessagePtr	aMessage = NULL;
	long            ac = 0;
	t_atom			*av = NULL;
	t_max_err		m_err;
	TTErr			err;
    TTPtr           ptr;
	
	m_err = hashtab_lookup(x->wrappedClassDefinition->maxNamesToTTNames, s, (t_object**)&ptr);
	if (!m_err)
    {
		// Is it a message of the wrapped object ?
        ttName = TTSymbol(ptr);
		err = selectedObject->findMessage(ttName, &aMessage);
		if (!err)
        {
			// send message
			if (argc && argv)
            {
				jamoma_ttvalue_from_Atom(inputValue, _sym_nothing, argc, argv);
				selectedObject->sendMessage(ttName, inputValue, outputValue);
				
                inputValue.append(outputValue);
				jamoma_ttvalue_to_Atom(inputValue, &ac, &av);
				object_obex_dumpout(self, s, ac, av);
				sysmem_freeptr(av);
			}
			else
            {
				selectedObject->sendMessage(ttName);
                object_obex_dumpout(self, s, ac, av);
            }
		}
		
		return err;
	}
	else
		return kTTErrGeneric;
}
Esempio n. 14
0
void tap_folder_dodeletedir(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];
	t_atom	a;
	
	path_nameconform(s->s_name, name, PATH_STYLE_SLASH, PATH_TYPE_BOOT);
	snprintf(script, MAX_PATH_CHARS + 200, 
		"tell application \"Finder\" \ntry \nset thing to \"%s\" as POSIX file \ndelete thing \nend try \nend tell \n",
		name);
	atom_setsym(&a, gensym(script));
	object_method_typed(x->applescript, gensym("script"), 1, &a, NULL);
	object_method(x->applescript, _sym_bang);
#else // WIN_VERSION
	int				err = 0;
	char			winpath[4096];
	char			winpath2[4096];
	char*			winpathfile = NULL;
	SHFILEOPSTRUCT	fileop;

	path_nameconform(s->s_name, winpath, PATH_STYLE_NATIVE_WIN, PATH_TYPE_ABSOLUTE);
	strcat(winpath, "\\*");

	// This is exceedingly annoying: this string has to be double-terminated in order to work!
	winpath[strlen(winpath)] = 0;
	winpath[strlen(winpath)+1] = 0;

	fileop.hwnd = NULL;
	fileop.wFunc = FO_DELETE;
	fileop.pFrom = (LPCSTR)winpath;
	fileop.pTo = (LPCSTR)winpath;
	fileop.pTo = NULL;
	fileop.fFlags = FOF_NOCONFIRMATION | FOF_SILENT;
	fileop.fAnyOperationsAborted = FALSE;

	// !!!
	// THE SUCCESS OF SHFILEOPERATION() SEEMS TO BE EXTREMELY INTERMITTENT
	// MULTIPLE CALLS TO THIS METHOD WILL EVENTUALLY RESULT IN SUCCESS
	// !!!
	err = SHFileOperation(&fileop);
	if(err)
		object_error((t_object *)x, "ERROR: %i deleting %s", err, winpath);
	else{
		winpath[strlen(winpath)-2] = 0;
		err = RemoveDirectory((LPCSTR)winpath);
		if(err == 0){
			err = GetLastError();
			object_error((t_object *)x, "ERROR: %i deleting the folder", err);
		}
	}
#endif
	object_obex_dumpout(x, _sym_bang, 0, NULL);
}
Esempio n. 15
0
void model_preset_dowrite(TTPtr self, t_symbol *msg, long argc, t_atom *argv)
{
	WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;
	char 			filename[MAX_FILENAME_CHARS];
	TTSymbol		fullpath;
	TTValue			o, v, none;
	TTObject        aTextHandler;
	TTErr			tterr;

	// stop filewatcher
	if (EXTRA->filewatcher)
		filewatcher_stop(EXTRA->filewatcher);

	if (EXTRA->presetManager->valid()) {

		// Default TEXT File Name
		snprintf(filename, MAX_FILENAME_CHARS, "%s.%s.presets.txt", x->patcherClass.c_str(), x->patcherContext.c_str());
		fullpath = jamoma_file_write((t_object*)x, argc, argv, filename);
		v.append(fullpath);

		tterr = x->internals->lookup(kTTSym_TextHandler, o);

		if (!tterr) {
			aTextHandler = o[0];

			aTextHandler.set(kTTSym_object, *EXTRA->presetManager);

			critical_enter(0);
			tterr = aTextHandler.send(kTTSym_Write, v, none);
			critical_exit(0);

			if (!tterr)
				object_obex_dumpout(self, _sym_write, argc, argv);
			else
				object_obex_dumpout(self, _sym_error, 0, NULL);
		}
	}

	// start filewatcher
	if (EXTRA->filewatcher)
		filewatcher_start(EXTRA->filewatcher);
}
Esempio n. 16
0
void ramp_getDrives(t_ramp *x)
{
	t_atom		a[2];
	long		numRampUnits = 0;
	long		i;
	TTValue		rampUnitNames;
	TTSymbol*	aName;
	
	atom_setsym(a+0, gensym("clear"));
	object_obex_dumpout(x, gensym("drives"), 1, a);
	
	RampLib::getUnitNames(rampUnitNames);
	numRampUnits = rampUnitNames.getSize();
	
	atom_setsym(a+0, gensym("append"));
	for (i=0; i<numRampUnits; i++) {
		rampUnitNames.get(i, &aName);
		atom_setsym(a+1, gensym((char*)aName->getCString()));
		object_obex_dumpout(x, gensym("drives"), 2, a);
	}}
Esempio n. 17
0
void ramp_getFunctions(t_ramp *x)
{
	t_atom		a[2];
	long		numFunctions = 0;
	long		i;
	TTValue		functionNames;
	TTSymbol*	aName;
	
	atom_setsym(a+0, gensym("clear"));
	object_obex_dumpout(x, gensym("functions"), 1, a);
	
	FunctionLib::getUnitNames(functionNames);
	numFunctions = functionNames.getSize();
	
	atom_setsym(a+0, gensym("append"));
	for (i=0; i<numFunctions; i++) {
		functionNames.get(i, &aName);
		atom_setsym(a+1, gensym((char*)aName->getCString()));
		object_obex_dumpout(x, gensym("functions"), 2, a);
	}
}
Esempio n. 18
0
void wrappedModularClass_dump(TTPtr self)
{
    WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;
    TTValue			names, v;
    TTUInt32		i;
    TTSymbol		aName, address;
    t_symbol		*s;
    long            ac;
    t_atom			*av;
	
#ifndef ARRAY_EXTERNAL
    t_atom			a;
	
    if (x->subscriberObject.valid())
    {
    	// send out the absolute address of the subscriber
        x->subscriberObject.get("nodeAddress", v);
        address = v[0];
        atom_setsym(&a, gensym((char *) address.c_str()));
        object_obex_dumpout(self, gensym("address"), 1, &a);
    }
#endif
    
    selectedObject->getAttributeNames(names);
	
    for (i = 0; i < names.size(); i++) {
		
        aName = names[i];
		
		selectedObject->getAttributeValue(aName, v);
		
		s = jamoma_TTName_To_MaxName(aName);
		
		ac = 0;
		av = NULL;
		jamoma_ttvalue_to_Atom(v, &ac, &av);
		object_obex_dumpout(self, s, ac, av);
		sysmem_freeptr(av);
    }
}
Esempio n. 19
0
void wrappedClass_anything(WrappedInstancePtr self, SymbolPtr s, AtomCount argc, AtomPtr argv)
{
	if (argc && argv) {
		TTValue	v;
		
		v.setSize(argc);
		for (AtomCount i=0; i<argc; i++) {
			if (atom_gettype(argv+i) == A_LONG)
				v.set(i, AtomGetInt(argv+i));
			else if (atom_gettype(argv+i) == A_FLOAT)
				v.set(i, atom_getfloat(argv+i));
			else if (atom_gettype(argv+i) == A_SYM)
				v.set(i, TT(atom_getsym(argv+i)->s_name));
			else
				object_error(SELF, "bad type for message arg");
		}
		self->audioGraphObject->mUnitGenerator->sendMessage(TT(s->s_name), v);
		
		// process the returned value for the dumpout outlet
		{
			AtomCount	ac = v.getSize();

			if (ac) {
				AtomPtr		av = (AtomPtr)malloc(sizeof(Atom) * ac);
				
				for (AtomCount i=0; i<ac; i++) {
					if (v.getType() == kTypeSymbol){
						TTSymbolPtr ttSym = NULL;
						v.get(i, &ttSym);
						atom_setsym(av+i, gensym((char*)ttSym->getCString()));
					}
					else if (v.getType() == kTypeFloat32 || v.getType() == kTypeFloat64) {
						TTFloat64 f = 0.0;
						v.get(i, f);
						atom_setfloat(av+i, f);
					}
					else {
						TTInt32 l = 0;
						v.get(i, l);
						atom_setfloat(av+i, l);
					}
				}
				object_obex_dumpout(self, s, ac, av);
			}
		}
	}
	else
		self->audioGraphObject->mUnitGenerator->sendMessage(TT(s->s_name));
}
Esempio n. 20
0
// Attributes of attributes
void ramp_getFunctionParameter(t_ramp *obj, t_symbol *msg, long argc, t_atom *argv)
{
	t_atom*		a;
	TTSymbol*	parameterName;
	TTValue		parameterValue;
	int			numValues;
	int			i;
	TTSymbol*	tempSymbol;
	double		tempValue;
	TTValue		v;
	
	if (!argc) {
		error("jcom.ramp: not enough arguments to function.parameter.get");
		return;
	}
	
	// get the correct TT name for the parameter given the Max name
	parameterName = TT(atom_getsym(argv)->s_name);
	obj->parameterNames->lookup(parameterName, v);
	v.get(0, &parameterName);
	
	obj->rampUnit->getFunctionParameterValue(parameterName, parameterValue);
	numValues = parameterValue.getSize();
	if (numValues) {
		a = (t_atom *)sysmem_newptr(sizeof(t_atom) * (numValues+1));
		// First list item is name of parameter
		atom_setsym(a, gensym((char*)parameterName->getCString()));
		// Next the whole shebang is copied
		for (i=0; i<numValues; i++) {
			if (parameterValue.getType(i) == kTypeSymbol) {
				parameterValue.get(i, &tempSymbol);
				atom_setsym(a+i+1, gensym((char*)tempSymbol->getCString()));
			}
			else {
				parameterValue.get(i, tempValue);
				atom_setfloat(a+i+1, tempValue);
			}
		}
		object_obex_dumpout(obj, gensym("function.parameter.get"), numValues+1, a);
		
		// The pointer to an atom assign in the getParameter method needs to be freed.
		sysmem_freeptr(a);
	}
}
Esempio n. 21
0
// LIST INPUT
void pack_list(t_pack *x, t_symbol *msg, short argc, t_atom *argv)
{
	long inletnum = proxy_getinlet((object *)x);

	switch(argv[0].a_type){
		case A_LONG:
			atom_setlong(x->mylist+(inletnum), argv[0].a_w.w_long);
			break;
		case A_FLOAT:
			atom_setfloat(x->mylist+(inletnum), argv[0].a_w.w_float);
			break;
		default:
			object_obex_dumpout(x, gensym("error - unrecognised 1st element for list"), 0, 0L);		
			break;
	}

	if (x->triggerlist[(inletnum)] != 0)
		outlet_list(x->my_outlet, 0L, x->mylistlen, x->mylist);	// output the result	
}
Esempio n. 22
0
void cue_get(TTPtr self, t_symbol *msg, long argc, t_atom *argv)
{
    WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;
    TTHashPtr   allCues;
	TTValue     v;
	TTSymbol    name, attribute;
    TTObject	cue;
    long        ac = 0;
	t_atom      *av = NULL;
    
    if (argc == 2) {
        
        if (atom_gettype(argv) == A_SYM && atom_gettype(argv+1) == A_SYM) {
            
            attribute = TTSymbol((char*)atom_getsym(argv)->s_name);
            name = TTSymbol((char*)atom_getsym(argv+1)->s_name);
            
            // get cue object table
            x->wrappedObject.get("cues", v);
            allCues = TTHashPtr((TTPtr)v[0]);
            
            if (allCues) {
                
                // get cue
                if (!allCues->lookup(name, v)) {
                    
                    cue = v[0];
                    if (!cue.get(attribute, v)) {
                        
                        v.prepend(name);
                        jamoma_ttvalue_to_Atom(v, &ac, &av);
                        
                        object_obex_dumpout(self, atom_getsym(argv), ac, av);
                    }
                    else
                        object_error((t_object*)x, "%s attribute doesn't exist", atom_getsym(argv)->s_name);
                }
                else
                    object_error((t_object*)x, "%s cue doesn't exist", atom_getsym(argv+1)->s_name);
            }
        }
    }
}
Esempio n. 23
0
void MidiOutGetDeviceNames(MidiOutPtr self)
{
	TTValue		v;
	TTErr		err;
	AtomCount	ac;
	AtomPtr		ap;
	TTSymbol	name;
	
	err = self->graphObject->mKernel->sendMessage(TT("getAvailableDeviceNames"), kTTValNONE, v);
	if (!err) {
		ac = v.getSize();
		ap = new Atom[ac];
		
		for (AtomCount i=0; i<ac; i++) {
			v.get(i, name);
			atom_setsym(ap+i, gensym((char*)name.c_str()));
		}
		object_obex_dumpout(self, gensym("getAvailableDeviceNames"), ac, ap);
		delete ap;
	}
}
Esempio n. 24
0
void ramp_attrget(t_ramp *x, t_symbol *msg, long argc, t_atom *argv)
{
	t_atom*		a;
	TTSymbol*	parameterName;
	TTValue		parameterValue;
	int			numValues;
	int			i;
	TTSymbol*	tempSymbol;
	double		tempValue;
	
	if (!argc) {
		error("jcom.ramp: not enough arguments to parameter.get");
		return;
	}
	
	parameterName = TT(atom_getsym(argv)->s_name);
	x->rampUnit->getAttributeValue(parameterName, parameterValue);
	numValues = parameterValue.getSize();

	if (numValues) {
		a = (t_atom *)sysmem_newptr(sizeof(t_atom) * (numValues+1));
		// First list item is name of parameter
		atom_setsym(a, gensym((char*)parameterName->getCString()));
		// Next the whole shebang is copied
		for (i=0; i<numValues; i++) {
			if (parameterValue.getType(i) == kTypeSymbol) {
				parameterValue.get(i, &tempSymbol);
				atom_setsym(a+i+1, gensym((char*)tempSymbol->getCString()));
			}
			else {
				parameterValue.get(i, tempValue);
				atom_setfloat(a+i+1, tempValue);
			}
		}
		object_obex_dumpout(x, gensym("current.parameter"), numValues+1, a);
	
		// The pointer to an atom assign in the getParameter method needs to be freed.
		sysmem_freeptr(a);
	}
}
Esempio n. 25
0
void dbapBformatInfo(t_dbapBformat *x)
{
	t_atom		a[4];
	long i;

	atom_setfloat(&a[0], x->attrRollOff);
	object_obex_dumpout(x, psRollOff, 1, a);
	
	atom_setlong(&a[0], x->attrNumberOfSources);
	object_obex_dumpout(x, psNumberOfSources, 1, a);
	
	for (i=0; i<x->attrNumberOfSources; i++) {
		atom_setlong(&a[0], i+1);
		atom_setfloat(&a[1], x->sourcePosition[i].x);
		atom_setfloat(&a[2], x->sourcePosition[i].y);
		atom_setfloat(&a[3], x->sourcePosition[i].z);
		object_obex_dumpout(x, psSourcePosition, 4, a);
		atom_setfloat(&a[1], x->sourceGain[i]);
		object_obex_dumpout(x, psSourceGain, 2, a);
		atom_setlong(&a[1], (x->sourceNotMuted[i]==0));
		object_obex_dumpout(x, psSourceMute, 2, a);
		atom_setfloat(&a[1], x->blur[i]);
		object_obex_dumpout(x, psSourceBlur, 1, a);
	}
	
	atom_setlong(&a[0], x->attrNumberOfDestinations);
	object_obex_dumpout(x, psNumberOfDestinations, 1, a);
	
	for (i=0; i<x->attrNumberOfDestinations; i++) {
		atom_setlong(&a[0], i+1);
		atom_setfloat(&a[1], x->destinationPosition[i].x);
		atom_setfloat(&a[2], x->destinationPosition[i].y);
		atom_setfloat(&a[3], x->destinationPosition[i].z);
		object_obex_dumpout(x, psDestinationPosition, 4, a);
	}
}
Esempio n. 26
0
void folder_domakedir(t_folder *x, t_symbol *s, long argc, t_atom *argv)
{
	short	path = 0;				// parent folder, which we supply
	short	createdPath = 0;		// the new folder after it is created
	char	*folderName;			// the name of the new folder
	char	fullpath[4096];
	short	err = 0;
	char	temp[256];
	
	path_nameconform(s->s_name, fullpath, PATH_STYLE_MAX, PATH_TYPE_ABSOLUTE);
	folderName = strrchr(fullpath, '/');
	
	if (folderName) {
		*folderName = 0;
		folderName++;
		
		err = path_frompathname(fullpath, &path, temp);
		if (!err)
			err = path_createfolder(path, folderName, &createdPath);
		if (err)
			object_error((t_object*)x, "error %hd trying to create folder", err);
	}
	object_obex_dumpout(x, _sym_bang, 0, NULL);
}
Esempio n. 27
0
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);
    }
}
Esempio n. 28
0
t_max_err wrappedModularClass_attrSet(TTPtr self, t_object *attr, long argc, const t_atom *argv)
{
	WrappedModularInstancePtr x = (WrappedModularInstancePtr)self;
	t_symbol	*attrName = (t_symbol*)object_method(attr, _sym_getname);
	TTValue		v;
	long        ac = 0;
	t_atom		*av = NULL;
	t_max_err	m_err;
	TTErr		err;
	TTPtr		ptr;
	
	// for an array of wrapped object
	if (x->useInternals && !x->iterateInternals) {
		
		TTValue		keys;
		
		// temporary set x->iterateInternals to YES
		x->iterateInternals = YES;
		
		// then recall this method for each element of the array
		if (!x->internals->isEmpty()) {
			err = x->internals->getKeys(keys);
			if (!err) {
				for (TTUInt32 i = 0; i < keys.size(); i++) {
					x->cursor = keys[i];
					wrappedModularClass_attrSet(self, attr, argc, argv);
				}
			}
		}
		
		// reset x->iterateInternals to NO
		x->iterateInternals = NO;
		
		return MAX_ERR_NONE;
	}
	
	m_err = hashtab_lookup(x->wrappedClassDefinition->maxNamesToTTNames, attrName, (t_object**)&ptr);
	if (m_err)
		return m_err;
	
	TTSymbol	ttAttrName(ptr);
	
	// set attribute's value
	if (argc && argv) {
		
		jamoma_ttvalue_from_Atom(v, _sym_nothing, argc, argv);
		
		if (selectedObject) {
			selectedObject->setAttributeValue(ttAttrName, v);
			return MAX_ERR_NONE;
		}
		else
			return MAX_ERR_GENERIC;
        
	}
	// or get it and dumpout his value
	else {
		
		if (selectedObject) {
			// don't consider array case here (they should have all the same attribute value)
			selectedObject->getAttributeValue(ttAttrName, v);
			
			jamoma_ttvalue_to_Atom(v, &ac, &av);
			object_obex_dumpout(self, attrName, ac, av);
			sysmem_freeptr(av);
			return MAX_ERR_NONE;
		}
		else
			return MAX_ERR_GENERIC;
	}
	
	return MAX_ERR_GENERIC;
}