| 708 | } |
| 709 | |
| 710 | void _setNormalizedPluginParameterValue(const uint32_t index, const double normalized) |
| 711 | { |
| 712 | const ParameterRanges& ranges(fPlugin.getParameterRanges(index)); |
| 713 | const uint32_t hints = fPlugin.getParameterHints(index); |
| 714 | float value = ranges.getUnnormalizedValue(normalized); |
| 715 | |
| 716 | // convert as needed as check for changes |
| 717 | if (hints & kParameterIsBoolean) |
| 718 | { |
| 719 | const float midRange = ranges.min + (ranges.max - ranges.min) / 2.f; |
| 720 | const bool isHigh = value > midRange; |
| 721 | |
| 722 | if (isHigh == (fCachedParameterValues[kVst3InternalParameterBaseCount + index] > midRange)) |
| 723 | return; |
| 724 | |
| 725 | value = isHigh ? ranges.max : ranges.min; |
| 726 | } |
| 727 | else if (hints & kParameterIsInteger) |
| 728 | { |
| 729 | const int ivalue = d_roundToInt(value); |
| 730 | |
| 731 | if (d_roundToInt(fCachedParameterValues[kVst3InternalParameterBaseCount + index]) == ivalue) |
| 732 | return; |
| 733 | |
| 734 | value = ivalue; |
| 735 | } |
| 736 | else |
| 737 | { |
| 738 | // deal with low resolution of some hosts, which convert double to float internally and lose precision |
| 739 | if (std::abs(ranges.getNormalizedValue(static_cast<double>(fCachedParameterValues[kVst3InternalParameterBaseCount + index])) - normalized) < 0.0000001) |
| 740 | return; |
| 741 | } |
| 742 | |
| 743 | fCachedParameterValues[kVst3InternalParameterBaseCount + index] = value; |
| 744 | |
| 745 | #if DISTRHO_PLUGIN_HAS_UI |
| 746 | #if DPF_VST3_USES_SEPARATE_CONTROLLER |
| 747 | if (!fIsComponent) |
| 748 | #endif |
| 749 | { |
| 750 | fParameterValueChangesForUI[kVst3InternalParameterBaseCount + index] = true; |
| 751 | } |
| 752 | #endif |
| 753 | |
| 754 | if (!fPlugin.isParameterOutputOrTrigger(index)) |
| 755 | fPlugin.setParameterValue(index, value); |
| 756 | } |
| 757 | |
| 758 | // ---------------------------------------------------------------------------------------------------------------- |
| 759 | // stuff called for UI creation |
no test coverage detected