From db3b85e941148a872c7a62072f010c146eb33db6 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Mon, 9 Dec 2019 23:24:25 +0100 Subject: [PATCH] Added a helper to normalize bend ranges --- src/sfizz/SfzHelpers.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/sfizz/SfzHelpers.h b/src/sfizz/SfzHelpers.h index 2290d5df..0f9284c7 100644 --- a/src/sfizz/SfzHelpers.h +++ b/src/sfizz/SfzHelpers.h @@ -87,6 +87,17 @@ inline constexpr float normalizePercents(T percentValue) return std::min(std::max(static_cast(percentValue), 0.0f), 100.0f) / 100.0f; } +/** + * @brief Normalize bends between -1 and 1 + * + * @param bendValue + * @return constexpr float + */ +inline constexpr float normalizeBend(int bendValue) +{ + return std::min(std::max(static_cast(bendValue), -8192.0f), 8192.0f) / 8192.0f; +} + /** * @brief Normalize a possibly negative percentage between -1 and 1 *