simple-tone: use integer mod not fmod

This commit is contained in:
Kamal Mostafa 2012-08-15 16:57:39 -07:00
parent c039dad33a
commit 6ee10626c9
1 changed files with 4 additions and 6 deletions

View File

@ -68,9 +68,8 @@ simpleaudio_tone_init( unsigned int new_sin_table_len )
static inline short
sin_lu_short( float turns )
{
turns = fmodf(turns, 1.0);
int t = (float)sin_table_len * turns;
// assert ( t >= 0 && t < sin_table_len );
int t = (float)sin_table_len * turns + 0.5f;
t %= sin_table_len;
return sin_table_short[t];
}
@ -80,9 +79,8 @@ sin_lu_short( float turns )
static inline float
sin_lu_float( float turns )
{
turns = fmodf(turns, 1.0);
int t = (float)sin_table_len * turns;
// assert ( t >= 0 && t < sin_table_len );
int t = (float)sin_table_len * turns + 0.5f;
t %= sin_table_len;
return sin_table_float[t];
}