Add a helper to get the normalized phase
This commit is contained in:
parent
bad1120296
commit
b223fb5e4f
2 changed files with 19 additions and 0 deletions
|
|
@ -917,6 +917,19 @@ float sfz::Region::getBaseGain() noexcept
|
|||
return normalizePercents(amplitude);
|
||||
}
|
||||
|
||||
float sfz::Region::getPhase() noexcept
|
||||
{
|
||||
float phase;
|
||||
if (oscillatorPhase >= 0) {
|
||||
phase = oscillatorPhase * (1.0f / 360.0f);
|
||||
phase -= static_cast<int>(phase);
|
||||
} else {
|
||||
std::uniform_real_distribution<float> phaseDist { 0.0001f, 0.9999f };
|
||||
phase = phaseDist(Random::randomGenerator);
|
||||
}
|
||||
return phase;
|
||||
}
|
||||
|
||||
uint32_t sfz::Region::getOffset(Oversampling factor) noexcept
|
||||
{
|
||||
return (offset + offsetDistribution(Random::randomGenerator)) * static_cast<uint32_t>(factor);
|
||||
|
|
|
|||
|
|
@ -167,6 +167,12 @@ struct Region {
|
|||
* @return float
|
||||
*/
|
||||
float getBaseGain() noexcept;
|
||||
/**
|
||||
* @brief Get the base gain of the region.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
float getPhase() noexcept;
|
||||
/**
|
||||
* @brief Computes the gain value related to the velocity of the note
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue