Added a clearer name for the velocity normalization

This commit is contained in:
Paul Ferrand 2019-12-28 22:31:53 +01:00
parent f02f96cad5
commit 4a25e6a4b8
2 changed files with 20 additions and 6 deletions

View file

@ -79,7 +79,7 @@ struct EGDescription
*/
float getAttack(const SfzCCArray &ccValues, uint8_t velocity) const noexcept
{
return ccSwitchedValue(ccValues, ccAttack, attack) + normalizeCC(velocity)*vel2attack;
return ccSwitchedValue(ccValues, ccAttack, attack) + normalizeVelocity(velocity)*vel2attack;
}
/**
* @brief Get the decay with possibly a CC modifier and a velocity modifier
@ -90,7 +90,7 @@ struct EGDescription
*/
float getDecay(const SfzCCArray &ccValues, uint8_t velocity) const noexcept
{
return ccSwitchedValue(ccValues, ccDecay, decay) + normalizeCC(velocity)*vel2decay;
return ccSwitchedValue(ccValues, ccDecay, decay) + normalizeVelocity(velocity)*vel2decay;
}
/**
* @brief Get the delay with possibly a CC modifier and a velocity modifier
@ -101,7 +101,7 @@ struct EGDescription
*/
float getDelay(const SfzCCArray &ccValues, uint8_t velocity) const noexcept
{
return ccSwitchedValue(ccValues, ccDelay, delay) + normalizeCC(velocity)*vel2delay;
return ccSwitchedValue(ccValues, ccDelay, delay) + normalizeVelocity(velocity)*vel2delay;
}
/**
* @brief Get the holding duration with possibly a CC modifier and a velocity modifier
@ -112,7 +112,7 @@ struct EGDescription
*/
float getHold(const SfzCCArray &ccValues, uint8_t velocity) const noexcept
{
return ccSwitchedValue(ccValues, ccHold, hold) + normalizeCC(velocity)*vel2hold;
return ccSwitchedValue(ccValues, ccHold, hold) + normalizeVelocity(velocity)*vel2hold;
}
/**
* @brief Get the release duration with possibly a CC modifier and a velocity modifier
@ -123,7 +123,7 @@ struct EGDescription
*/
float getRelease(const SfzCCArray &ccValues, uint8_t velocity) const noexcept
{
return ccSwitchedValue(ccValues, ccRelease, release) + normalizeCC(velocity)*vel2release;
return ccSwitchedValue(ccValues, ccRelease, release) + normalizeVelocity(velocity)*vel2release;
}
/**
* @brief Get the starting level with possibly a CC modifier and a velocity modifier
@ -145,7 +145,7 @@ struct EGDescription
*/
float getSustain(const SfzCCArray &ccValues, uint8_t velocity) const noexcept
{
return ccSwitchedValue(ccValues, ccSustain, sustain) + normalizeCC(velocity)*vel2sustain;
return ccSwitchedValue(ccValues, ccSustain, sustain) + normalizeVelocity(velocity)*vel2sustain;
}
LEAK_DETECTOR(EGDescription);
};

View file

@ -64,6 +64,20 @@ constexpr float normalizeCC(T ccValue)
return static_cast<float>(std::min(std::max(ccValue, static_cast<T>(0)), static_cast<T>(127))) / 127.0f;
}
/**
* @brief Normalize a velocity between (T)0.0 and (T)1.0
*
* @tparam T
* @param ccValue
* @return constexpr float
*/
template<class T>
constexpr float normalizeVelocity(T velocity)
{
return normalizeCC(velocity);
}
/**
* @brief Normalize a percentage between 0 and 1
*