Avoid narrowing conversion for panning

This commit is contained in:
Jack Andersen 2018-09-02 20:33:41 -10:00
parent 1312a5fa86
commit 8fee7a282b
2 changed files with 10 additions and 10 deletions

View File

@ -56,8 +56,8 @@ class Voice : public Entity
struct Panning
{
float m_time; /**< time of PANNING command */
float m_dur; /**< requested duration of PANNING command */
double m_time; /**< time of PANNING command */
double m_dur; /**< requested duration of PANNING command */
uint8_t m_pos; /**< initial pan value of PANNING command */
int8_t m_width; /**< delta pan value to target of PANNING command */
};

View File

@ -435,10 +435,10 @@ void Voice::preSupplyAudio(double dt)
{
Panning& p = m_panningQueue.front();
p.m_time += dt;
float start = (p.m_pos - 64) / 64.f;
float end = (p.m_pos + p.m_width - 64) / 64.f;
float t = clamp(0.f, p.m_time / p.m_dur, 1.f);
_setPan((start * (1.0f - t)) + (end * t));
double start = (p.m_pos - 64) / 64.0;
double end = (p.m_pos + p.m_width - 64) / 64.0;
double t = clamp(0.0, p.m_time / p.m_dur, 1.0);
_setPan(float((start * (1.0 - t)) + (end * t)));
refresh = true;
/* Done with panning */
@ -451,10 +451,10 @@ void Voice::preSupplyAudio(double dt)
{
Panning& s = m_spanningQueue.front();
s.m_time += dt;
float start = (s.m_pos - 64) / 64.f;
float end = (s.m_pos + s.m_width - 64) / 64.f;
float t = clamp(0.f, s.m_time / s.m_dur, 1.f);
_setSurroundPan((start * (1.0f - t)) + (end * t));
double start = (s.m_pos - 64) / 64.0;
double end = (s.m_pos + s.m_width - 64) / 64.0;
double t = clamp(0.0, s.m_time / s.m_dur, 1.0);
_setSurroundPan(float((start * (1.0 - t)) + (end * t)));
refresh = true;
/* Done with spanning */