Esempio n. 1
0
/*
	This routine gets instrument parameters.
	npv is number of valid AUpvlist pairs
*/
void _af_instparam_get (AFfilehandle file, int instid, AUpvlist pvlist, int npv,
	bool forceLong)
{
	int	i, instno, j;

	if (!_af_filehandle_ok(file))
		return;

	if ((instno = _af_handle_instrument_index_from_id(file, instid)) == -1)
		return;

	if (AUpvgetmaxitems(pvlist) < npv)
		npv = AUpvgetmaxitems(pvlist);

	for (i=0; i < npv; i++)
	{
		int param;
		int type;
		AUpvgetparam(pvlist, i, &param);

		if  ((j = _af_instparam_index_from_id(file->fileFormat, param)) == -1)
			/* no parameter with that id; ignore */
			continue;

		type = _af_units[file->fileFormat].instrumentParameters[j].type;

		/*
			forceLong is true when this routine called by
			afGetInstParamLong().
		*/
		if (forceLong && type != AU_PVTYPE_LONG)
		{
			_af_error(AF_BAD_INSTPTYPE, "type of instrument parameter %d is not AU_PVTYPE_LONG", param);
			continue;
		}

		AUpvsetvaltype(pvlist, i, type);

		switch (type)
		{
			case AU_PVTYPE_LONG:
				AUpvsetval(pvlist, i, &file->instruments[instno].values[j].l);
				break;
			case AU_PVTYPE_DOUBLE:
				AUpvsetval(pvlist, i, &file->instruments[instno].values[j].d);
				break;
			case AU_PVTYPE_PTR:
				AUpvsetval(pvlist, i, &file->instruments[instno].values[j].v);
				break;

			default:
				_af_error(AF_BAD_INSTPTYPE, "invalid instrument parameter type %d", type);
				return;
		}
	}
}
Esempio n. 2
0
/*
	This routine checks and sets instrument parameters.
	npv is number of valid AUpvlist pairs.
*/
void _af_instparam_set (AFfilehandle file, int instid, AUpvlist pvlist, int npv)
{
	int i, instno, j;

	if (!_af_filehandle_ok(file))
		return;

	if (!_af_filehandle_can_write(file))
		return;

	if ((instno = _af_handle_instrument_index_from_id(file, instid)) == -1)
		return;

	if (AUpvgetmaxitems(pvlist) < npv)
	npv = AUpvgetmaxitems(pvlist);

	for (i=0; i < npv; i++)
	{
		int	param;
		int	type;

		AUpvgetparam(pvlist, i, &param);

		if  ((j = _af_instparam_index_from_id(file->fileFormat, param)) == -1)
			/* no parameter with that id; ignore */
			continue;

		if (_af_units[file->fileFormat].write.instparamvalid &&
			!_af_units[file->fileFormat].write.instparamvalid(file, pvlist, i))
			/* bad parameter value; ignore */
			continue;

		type = _af_units[file->fileFormat].instrumentParameters[j].type;

		switch (type)
		{
			case AU_PVTYPE_LONG:
				AUpvgetval(pvlist, i, &file->instruments[instno].values[j].l);
				break;
			case AU_PVTYPE_DOUBLE:
				AUpvgetval(pvlist, i, &file->instruments[instno].values[j].d);
				break;
			case AU_PVTYPE_PTR:
				AUpvgetval(pvlist, i, &file->instruments[instno].values[j].v);
				break;
			default:
				return;
		}
	}
}
Esempio n. 3
0
/*
	This routine checks and sets instrument parameters.
	npv is number of valid AUpvlist pairs.
*/
void _af_instparam_set (AFfilehandle file, int instid, AUpvlist pvlist, int npv)
{
	if (!_af_filehandle_ok(file))
		return;

	if (!file->checkCanWrite())
		return;

	Instrument *instrument = file->getInstrument(instid);
	if (!instrument)
		return;

	if (AUpvgetmaxitems(pvlist) < npv)
	npv = AUpvgetmaxitems(pvlist);

	for (int i=0; i < npv; i++)
	{
		int	param;

		AUpvgetparam(pvlist, i, &param);

		int j;
		if ((j = _af_instparam_index_from_id(file->m_fileFormat, param)) == -1)
			/* no parameter with that id; ignore */
			continue;

		if (!file->isInstrumentParameterValid(pvlist, i))
			/* bad parameter value; ignore */
			continue;

		int	type = _af_units[file->m_fileFormat].instrumentParameters[j].type;

		switch (type)
		{
			case AU_PVTYPE_LONG:
				AUpvgetval(pvlist, i, &instrument->values[j].l);
				break;
			case AU_PVTYPE_DOUBLE:
				AUpvgetval(pvlist, i, &instrument->values[j].d);
				break;
			case AU_PVTYPE_PTR:
				AUpvgetval(pvlist, i, &instrument->values[j].v);
				break;
			default:
				return;
		}
	}
}
Esempio n. 4
0
bool _af_pv_getptr (AUpvlist pvlist, int param, void **v)
{
	int	i;

	for (i=0; i<AUpvgetmaxitems(pvlist); i++)
	{
		int	p, t;

		AUpvgetparam(pvlist, i, &p);

		if (p != param)
			continue;

		AUpvgetvaltype(pvlist, i, &t);

		/* Ensure that this parameter is of type AU_PVTYPE_PTR. */
		if (t != AU_PVTYPE_PTR)
			return false;

		AUpvgetval(pvlist, i, v);
		return true;
	}

	return false;
}
Esempio n. 5
0
bool _af_pv_getdouble (AUpvlist pvlist, int param, double *d)
{
	int	i;

	for (i=0; i<AUpvgetmaxitems(pvlist); i++)
	{
		int	p, t;

		AUpvgetparam(pvlist, i, &p);

		if (p != param)
			continue;

		AUpvgetvaltype(pvlist, i, &t);

		/* Ensure that this parameter is of type AU_PVTYPE_DOUBLE. */
		if (t != AU_PVTYPE_DOUBLE)
			return false;

		AUpvgetval(pvlist, i, d);
		return true;
	}

	return false;
}
Esempio n. 6
0
bool _af_pv_getlong (AUpvlist pvlist, int param, long *l)
{
	int	i;

	for (i=0; i<AUpvgetmaxitems(pvlist); i++)
	{
		int	p, t;

		AUpvgetparam(pvlist, i, &p);

		if (p != param)
			continue;

		AUpvgetvaltype(pvlist, i, &t);

		/* Ensure that this parameter is of type AU_PVTYPE_LONG. */
		if (t != AU_PVTYPE_LONG)
			return false;

		AUpvgetval(pvlist, i, l);
		return true;
	}

	return false;
}
Esempio n. 7
0
int main (int argc, char **argv)
{
	AUpvlist		list;
	int				size;
	AFfilehandle	file;

	long	f**k = 99;

	if (argc != 2)
	{
		fprintf(stderr, "usage: testaupv filename\n");
		exit(EXIT_FAILURE);
	}

	file = afOpenFile(argv[1], "r", NULL);

	list = AUpvnew(4);
	size = AUpvgetmaxitems(list);

	printf("AUpvsetparam: %d\n", AUpvsetparam(list, 0, AF_INST_MIDI_BASENOTE));
	printf("AUpvsetparam: %d\n", AUpvsetparam(list, 1, AF_INST_MIDI_LONOTE));
	printf("AUpvsetparam: %d\n", AUpvsetparam(list, 2, AF_INST_SUSLOOPID));
	printf("AUpvsetparam: %d\n", AUpvsetparam(list, 3, AF_INST_RELLOOPID));

	afGetInstParams(file, AF_DEFAULT_INST, list, 4);

	AUpvgetval(list, 0, &f**k);
	printf("AUpvgetval: %ld\n", f**k);

	AUpvgetval(list, 1, &f**k);
	printf("AUpvgetval: %ld\n", f**k);

	AUpvgetval(list, 2, &f**k);
	printf("AUpvgetval: %ld\n", f**k);

	AUpvgetval(list, 3, &f**k);
	printf("AUpvgetval: %ld\n", f**k);

	afCloseFile(file);

	return 0;
}