mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-10-31 05:35:35 +00:00
Avoid using floating-point operation
This has varying behavior depending on toolchain and processor. Fixes #1151
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user