Example #1
0
//-----------------------------------------------------------------------------
tresult RangeNoteExpressionType::getStringByValue (NoteExpressionValue valueNormalized /*in*/, String128 string /*out*/)
{
	NoteExpressionValue plain = valueNormalized * (getMax () - getMin ()) + getMin ();
	UString128 wrapper;
	wrapper.printFloat (plain, precision);
	wrapper.copyTo (string, 128);
	return kResultTrue;
}
Example #2
0
//-----------------------------------------------------------------------------
tresult NoteExpressionType::getStringByValue (NoteExpressionValue valueNormalized /*in*/, String128 string /*out*/)
{
	if (associatedParameter)
	{
		associatedParameter->toString (valueNormalized, string);
		return kResultTrue;
	}
	UString128 wrapper;
	if (info.valueDesc.stepCount > 0)
	{
		int32 value = Min<int32> (info.valueDesc.stepCount, (int32)(valueNormalized * (info.valueDesc.stepCount + 1)));
		wrapper.printInt (value);
	}
	else
	{
		wrapper.printFloat (valueNormalized, precision);
	}
	wrapper.copyTo (string, 128);
	return kResultTrue;
}
Example #3
0
//-----------------------------------------------------------------------------
tresult PLUGIN_API MultiBandController::getParamStringByValue (ParamID tag, ParamValue valueNormalized, String128 string)
{
	UString128 result;
	switch (tag)
	{
		case 1:
		{
			float fi1 = (float)pow (10.0,valueNormalized - 1.70);
			result.printInt (getSampleRate () * fi1 * (0.098 + 0.09*fi1 + 0.5*(float)pow (fi1,8.2f)));
			break;
		}
		case 2:
		{
			float fi2 = (float)pow (10.0,valueNormalized - 1.05);
			result.printInt (getSampleRate () * fi2 * (0.015 + 0.15*fi2 + 0.9*(float)pow (fi2,8.2f)));
			break;
		}
		case 9:
		{
			float att2 = (float)pow (10.0, -0.05 -(2.0 * valueNormalized));
			result.printInt (-301030.1 / (getSampleRate () * log10(1.0 - att2)));
			break;
		}
		case 10:
		{
			float rel2 = (float)pow (10.0, -2.0 - (3.0 * valueNormalized));
			result.printInt (-301.0301 / (getSampleRate () * log10(1.0 - rel2)));
			break;
		}
		default:
			return BaseController::getParamStringByValue (tag, valueNormalized, string);
	}
	result.copyTo (string, 128);
	return kResultTrue;
}
Example #4
0
//-----------------------------------------------------------------------------
tresult PLUGIN_API RezFilterController::getParamStringByValue (ParamID tag, ParamValue valueNormalized, String128 string)
{
	UString128 result;
	switch (tag)
	{
		case 4:
		{
			float att = (float)pow (10.0, -0.01 - 4.0 * valueNormalized);
			result.printFloat (-301.0301 / (getSampleRate () * log10(1.0 - att)), 2);
			break;
		}
		case 5:
		{
			float rel = 1.f - (float)pow (10.0, -2.00 - 4.0 * valueNormalized);
			result.printFloat (-301.0301 / (getSampleRate () * log10(rel)), 2);
			break;
		}
		case 7:
		{
			result.printFloat (pow (10.0f, (float)(4.f*valueNormalized - 2.f)), 2);
			break;
		}
		case 8:
		{
			float tthr = 0;
			if (valueNormalized<0.1f) tthr=0.f; else tthr = 3.f * valueNormalized * valueNormalized;
			if (tthr == 0)
				result.fromAscii("FREE RUN");
			else
				result.printFloat (20*log10 (0.5*tthr), 2);
			break;
		}
		default:
			return BaseController::getParamStringByValue (tag, valueNormalized, string);
	}
	result.copyTo (string, 128);
	return kResultTrue;
}
Example #5
0
//------------------------------------------------------------------------
tresult PLUGIN_API AGain::setState (IBStream* state)
{
	// called when we load a preset, the model has to be reloaded

	float savedGain = 0.f;
	if (state->read (&savedGain, sizeof (float)) != kResultOk)
	{
		return kResultFalse;
	}

	float savedGainReduction = 0.f;
	if (state->read (&savedGainReduction, sizeof (float)) != kResultOk)
	{
		return kResultFalse;
	}

	int32 savedBypass = 0;
	if (state->read (&savedBypass, sizeof (int32)) != kResultOk)
	{
		return kResultFalse;
	}

#if BYTEORDER == kBigEndian
	SWAP_32 (savedGain)
	SWAP_32 (savedGainReduction)
	SWAP_32 (savedBypass)
#endif
	
	fGain = savedGain;
	fGainReduction = savedGainReduction;
	bBypass = savedBypass > 0;

	// Example of using the IStreamAttributes interface
	FUnknownPtr<IStreamAttributes> stream (state);
	if (stream)
	{
		IAttributeList* list = stream->getAttributes ();
		if (list)
		{
			// get the current type (project/Default..) of this state
			String128 string;
			if (list->getString (PresetAttributes::kStateType, string, 128 * sizeof (TChar)) == kResultTrue)
			{
				UString128 tmp (string);
				char ascii[128];
				tmp.toAscii (ascii, 128);
				if (!strncmp (ascii, StateType::kProject, strlen (StateType::kProject)))
				{
					// we are in project loading context...
				}
			}

			// get the full file path of this state
			TChar fullPath[1024];
			if (list->getString (PresetAttributes::kFilePathStringType, fullPath, 1024 * sizeof (TChar)) == kResultTrue)
			{
				// here we have the full path ...
			}
		}
	}

	return kResultOk;
}