Ejemplo n.º 1
0
GMexport double FMODGMS_Effect_Get_Parameter(double e, double p)
{
	int effectIndex = (int)round(e);
	if ((effectIndex < 0) || (effectIndex >= (int)effectList.size()))
	{
		errorMessage = "Invalid effect index";
		return GMS_error;
	}
	FMOD::DSP* effect = effectList[effectIndex];

	int param = (int)round(p);
	FMOD_DSP_PARAMETER_DESC* desc = NULL;
	if (effect->getParameterInfo(param, &desc) != FMOD_OK)
	{
		errorMessage = "Could not get effect parameter info, probably invalid param index";
		return GMS_error;
	}

	if (desc->type == FMOD_DSP_PARAMETER_TYPE_FLOAT)
	{
		float value;
		if (effect->getParameterFloat(param, &value, NULL, 0) == FMOD_OK)
			return (double)value;
	}
	else if (desc->type == FMOD_DSP_PARAMETER_TYPE_INT)
	{
		int value;
		if (effect->getParameterInt(param, &value, NULL, 0) == FMOD_OK)
			return (double)value;
	}
	else if (desc->type == FMOD_DSP_PARAMETER_TYPE_BOOL)
	{
		bool value;
		if (effect->getParameterBool(param, &value, NULL, 0) == FMOD_OK)
			return (double)value;
	}
	else
	{
		errorMessage = "Unsupported effect parameter type";
		return GMS_error;
	}

	errorMessage = "Could not get effect parameter";
	return GMS_error;
}
Ejemplo n.º 2
0
//Sets a parameter a of effect e to value v. For parameters of different effects, see fmod_dsp_effects.h
GMexport double FMODGMS_Effect_Set_Parameter(double e, double p, double v)
{
	int effectIndex = (int)round(e);
	if ((effectIndex < 0) || (effectIndex >= (int)effectList.size()))
	{
		errorMessage = "Invalid effect index";
		return GMS_error;
	}
	FMOD::DSP* effect = effectList[effectIndex];

	int param = (int)round(p);
	int value = (int)round(v);
	FMOD_DSP_PARAMETER_DESC* desc = NULL;
	if (effect->getParameterInfo(param, &desc) != FMOD_OK)
	{
		errorMessage = "Could not get effect parameter info, probably invalid param index";
		return GMS_error;
	}

	if (desc->type == FMOD_DSP_PARAMETER_TYPE_FLOAT)
	{
		if (effect->setParameterFloat(param, (float)value) == FMOD_OK)
			return FMODGMS_Util_ErrorChecker();
	}
	else if (desc->type == FMOD_DSP_PARAMETER_TYPE_INT)
	{
		if (effect->setParameterInt(param, (int)round(value)) == FMOD_OK)
			return FMODGMS_Util_ErrorChecker();
	}
	else if (desc->type == FMOD_DSP_PARAMETER_TYPE_BOOL)
	{
		if (effect->setParameterBool(param, (bool)(value > 0.5)) == FMOD_OK)
			return FMODGMS_Util_ErrorChecker();
	}
	else
	{
		errorMessage = "Unsupported effect parameter type";
		return GMS_error;
	}
	
	errorMessage = "Could not set effect parameter";
	return GMS_error;
}