Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 7 technical preview.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For the technical preview this file cannot be licensed commercially.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. namespace juce
  14. {
  15. int RangedAudioParameter::getNumSteps() const
  16. {
  17. const auto& range = getNormalisableRange();
  18. if (range.interval > 0)
  19. return (static_cast<int> ((range.end - range.start) / range.interval) + 1);
  20. return AudioProcessor::getDefaultNumParameterSteps();
  21. }
  22. float RangedAudioParameter::convertTo0to1 (float v) const noexcept
  23. {
  24. const auto& range = getNormalisableRange();
  25. return range.convertTo0to1 (range.snapToLegalValue (v));
  26. }
  27. float RangedAudioParameter::convertFrom0to1 (float v) const noexcept
  28. {
  29. const auto& range = getNormalisableRange();
  30. return range.snapToLegalValue (range.convertFrom0to1 (jlimit (0.0f, 1.0f, v)));
  31. }
  32. } // namespace juce