Wrap the cycle amount when passing to sin()

This commit is contained in:
Chris Robinson 2019-10-12 16:41:13 -07:00
parent 630d4d573d
commit e70f98c95a

View File

@ -82,7 +82,10 @@ static void ApplySin(ALfloat *data, ALdouble g, ALuint srate, ALuint freq)
ALdouble smps_per_cycle = (ALdouble)srate / freq;
ALuint i;
for(i = 0;i < srate;i++)
data[i] += (ALfloat)(sin(i/smps_per_cycle * 2.0*M_PI) * g);
{
ALdouble ival;
data[i] += (ALfloat)(sin(modf(i/smps_per_cycle, &ival) * 2.0*M_PI) * g);
}
}
/* Generates waveforms using additive synthesis. Each waveform is constructed