Avoid using floating-point operation

This has varying behavior depending on toolchain and processor.

Fixes #1151
This commit is contained in:
Samuel Thibault
2022-04-10 20:48:43 +02:00
parent b3ba314ba7
commit 310e8fc768
+1 -4
View File
@@ -222,7 +222,6 @@ static void SetToneAdjust(voice_t *voice, int *tone_pts)
int freq2;
int height1 = tone_pts[1];
int height2;
double rate;
for (pt = 0; pt < 12; pt += 2) {
if (tone_pts[pt] == -1) {
@@ -233,10 +232,8 @@ static void SetToneAdjust(voice_t *voice, int *tone_pts)
freq2 = tone_pts[pt] / 8; // 8Hz steps
height2 = tone_pts[pt+1];
if ((freq2 - freq1) > 0) {
rate = (double)(height2-height1)/(freq2-freq1);
for (ix = freq1; ix < freq2; ix++) {
y = height1 + (int)(rate * (ix-freq1));
y = height1 + (int)((ix-freq1) * (height2-height1) / (freq2-freq1));
if (y > 255)
y = 255;
voice->tone_adjust[ix] = y;