Ejemplo n.º 1
0
String MouseOverKnob::getTextFromValue(double val)
{
    // calculate bipolar value, only makes sense if minimum is 0 since maximum is used for scaling
    if (displayBipolarValue)
    {
        float coeff = toBipolar(static_cast<float>(this->getMinimum()), static_cast<float>(this->getMaximum()), static_cast<float>(val));
        val = this->getMaximum() * coeff;
    }

    int decimal = getNumDecimalPlacesToDisplay();
    if (decimal > 0)
    {
        return String(val, decimal) + getTextValueSuffix();
    }
    return String(roundToInt(val)) + getTextValueSuffix();
}
Ejemplo n.º 2
0
/// <summary>Gets GUI text from a given value by converting the value into Decibels</summary>
/// <param name="value">Input value where 0 represents -inf dB and 1.0 represents max Decibels in specified range</param>
/// <returns>String representing the input value in decibelsFS + Unit label</returns>
String GainCtrlSlider::getTextFromValue(double value)
{
	float decibelsFromGain = static_cast<float>(DecibelConversions::mapNormalizedValueToDecibels<float>(static_cast<float>(value), 0.0, 1.0, 0.5, minimumDecibelsInRange, maximumDecibelsInRange, 0.0));
	if (decibelsFromGain <= -96.0f)
	{
		return String("-INF dB");
	}
	else
	{
		std::stringstream gainRound;
		gainRound.setf(std::ios::fixed, std::ios::floatfield);
		gainRound << std::setprecision(2) << static_cast<float>(decibelsFromGain);
		
		return String(String(gainRound.str()) + getTextValueSuffix());
	}
}