Implement VIBRATO

This commit is contained in:
Jack Andersen
2018-05-18 19:15:12 -10:00
parent 594fb346e1
commit 1fefba66e7
4 changed files with 22 additions and 8 deletions

View File

@@ -448,6 +448,18 @@ void Voice::preSupplyAudio(double dt)
refresh = true;
}
/* Process vibrato */
if (m_vibratoTime >= 0.f)
{
m_vibratoTime += dt;
float vibrato = std::sin(m_vibratoTime / m_vibratoPeriod * (2.f * M_PIF));
if (m_vibratoModWheel)
newPitch += m_vibratoModLevel * vibrato;
else
newPitch += m_vibratoLevel * vibrato;
refresh = true;
}
/* Process pitch sweep 1 */
if (m_pitchSweep1It < m_pitchSweep1Times)
{
@@ -1199,10 +1211,11 @@ void Voice::setPedal(bool pedal)
void Voice::setDoppler(float) {}
void Voice::setVibrato(int32_t level, int32_t modLevel, float period)
void Voice::setVibrato(int32_t level, bool modScale, float period)
{
m_vibratoTime = std::fabs(period) < FLT_EPSILON ? -1.f : 0.f;
m_vibratoLevel = level;
m_vibratoModLevel = modLevel;
m_vibratoModWheel = modScale;
m_vibratoPeriod = period;
}