diff --git a/src/sfizz/Region.cpp b/src/sfizz/Region.cpp index 4f05f314..d21b3cc2 100644 --- a/src/sfizz/Region.cpp +++ b/src/sfizz/Region.cpp @@ -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(phase); + } else { + std::uniform_real_distribution 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(factor); diff --git a/src/sfizz/Region.h b/src/sfizz/Region.h index ebacc207..b3966a47 100644 --- a/src/sfizz/Region.h +++ b/src/sfizz/Region.h @@ -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 *