Remove hack to match Python code

This commit is contained in:
Jean-Marc Valin 2019-03-20 03:21:03 -04:00
parent 492ef9b362
commit 2bc20e65c7

View file

@ -128,9 +128,7 @@ LPCNET_EXPORT void lpcnet_synthesize(LPCNetState *lpcnet, short *output, const f
float gru_a_condition[3*GRU_A_STATE_SIZE]; float gru_a_condition[3*GRU_A_STATE_SIZE];
int pitch; int pitch;
float pitch_gain; float pitch_gain;
/* FIXME: Remove this -- it's just a temporary hack to match the Python code. */ /* Matches the Python code -- the 0.1 avoids rounding issues. */
static int start = LPC_ORDER+1;
/* FIXME: Do proper rounding once the Python code rounds properly. */
pitch = (int)floor(.1 + 50*features[36]+100); pitch = (int)floor(.1 + 50*features[36]+100);
pitch_gain = lpcnet->old_gain[FEATURES_DELAY-1]; pitch_gain = lpcnet->old_gain[FEATURES_DELAY-1];
memmove(&lpcnet->old_gain[1], &lpcnet->old_gain[0], (FEATURES_DELAY-1)*sizeof(lpcnet->old_gain[0])); memmove(&lpcnet->old_gain[1], &lpcnet->old_gain[0], (FEATURES_DELAY-1)*sizeof(lpcnet->old_gain[0]));
@ -144,7 +142,7 @@ LPCNET_EXPORT void lpcnet_synthesize(LPCNetState *lpcnet, short *output, const f
RNN_CLEAR(output, N); RNN_CLEAR(output, N);
return; return;
} }
for (i=start;i<N;i++) for (i=0;i<N;i++)
{ {
int j; int j;
float pcm; float pcm;
@ -167,7 +165,6 @@ LPCNET_EXPORT void lpcnet_synthesize(LPCNetState *lpcnet, short *output, const f
if (pcm>32767) pcm = 32767; if (pcm>32767) pcm = 32767;
output[i] = (int)floor(.5 + pcm); output[i] = (int)floor(.5 + pcm);
} }
start = 0;
} }