[Subject Prev][Subject Next][Thread Prev][Thread Next][Date Index][Thread Index]

[hts-users:01636] HTS_vocoder.c: float to short conversion


Hi,

Some minor corrections/suggestions...

The conversion of sample from float to short x in HTS_vocoder.c is
currently done as follows:

      /* output */
      xs = (short) x;

However, if x exceeds the minimum or maximum value of short, the
signedness may go wrong (you can see the difference in alice01.wav when
using LSP (Cygwin/gcc)). A simple fix should do:

      /* output */
      if ( x > 32767 ) { x = 32767; }
      else if ( x < -32768 ) { x = -32768; }
      xs = (short) x;


Also in the same file, I think it would be much more simpler to replace
v->pade with:

static const double pade[21] = {
  1.00000000000,
  1.00000000000, 0.00000000000,
  1.00000000000, 0.00000000000, 0.00000000000,
  1.00000000000, 0.00000000000, 0.00000000000, 0.00000000000,
  1.00000000000, 0.49992730000, 0.10670050000, 0.01170221000, 0.00056562790,
  1.00000000000, 0.49993910000, 0.11070980000, 0.01369984000, 0.00095648530,
  0.00003041721
};

(Less code, no memory allocations etc required...)

br,
  Nicholas





Follow-Ups
[hts-users:01637] harmless bug in HTS_pstream(), Nicholas Volk
[hts-users:01640] Re: HTS_vocoder.c: float to short conversion, Keiichiro Oura