Browse Source

Avoid using floating-point operation

This has varying behavior depending on toolchain and processor.

Fixes #1151
master
Samuel Thibault 3 years ago
parent
commit
310e8fc768
1 changed files with 1 additions and 4 deletions
  1. 1
    4
      src/libespeak-ng/voices.c

+ 1
- 4
src/libespeak-ng/voices.c 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;

Loading…
Cancel
Save