/// Transform **internal** value to string. /// /// @param newValue **internal** value /// /// @return formatted string /// const String PluginParameterContinuous::getTextFromFloat(float newValue) { // transform internal value to real value float newRealValue = toRealFloat(newValue); String textValueNew; // use decimal places if (decimalPlaces > 0) { // format parameter value using given number of decimal places textValueNew = String(newRealValue, decimalPlaces); } else { // round real parameter value newRealValue = MZ_Juce_Common::round_mz(newRealValue); // format parameter value textValueNew = String(newRealValue); } // add parameter suffix textValueNew += valueSuffix; // return formatted string return textValueNew; }
/// Set **internal** parameter value from float. The new value must /// be in the range from 0.0 to 1.0. /// /// @param newValue new value (between 0.0 and 1.0) /// void PluginParameterContinuous::setFloat(float newValue) { // confine new value to internal parameter range if (newValue < 0.0f) { newValue = 0.0f; } else if (newValue > 1.0f) { newValue = 1.0f; } // value has changed if (newValue != value) { // update internal parameter value value = newValue; // update real parameter value realValue = toRealFloat(value); // mark parameter as changed setChangeFlag(); } }
/// Set **real** default value from float. The new value must be in /// the defined range of the parameter's values. /// /// @param newRealValue new default value /// /// @param updateParameter if this is true, the parameter's value will /// be set to the new default value /// void ParSwitch::setDefaultRealFloat(float newRealValue, bool updateParameter) { // update internal default value defaultValue_ = toInternalFloat(newRealValue); // update real default value defaultRealValue_ = toRealFloat(defaultValue_); // optionally, update current parameter value if (updateParameter) { setFloat(defaultValue_); } }
/// Set **internal** parameter value from float. The new value must /// be in the range from 0.0 to 1.0. /// /// @param newValue new value (between 0.0 and 1.0) /// void ParSwitch::setFloat(float newValue) { // calculate internal value float newRealValue = toRealFloat(newValue); // value has changed if (newRealValue != realValue_) { // update real parameter value realValue_ = newRealValue; // update internal parameter value value_ = toInternalFloat(realValue_); // mark parameter as changed setChangeFlag(); } }