Fix quantization bug where pitch can get too low

Would cause unused pitch embedding vectors to be used
This commit is contained in:
Jean-Marc Valin 2021-01-10 03:15:30 -05:00
parent f0df3e82ec
commit 56d9f13efd
3 changed files with 4 additions and 2 deletions

View file

@ -130,6 +130,7 @@ LPCNET_EXPORT void lpcnet_synthesize(LPCNetState *lpcnet, const float *features,
float pitch_gain;
/* Matches the Python code -- the 0.1 avoids rounding issues. */
pitch = (int)floor(.1 + 50*features[36]+100);
pitch = IMIN(255, IMAX(33, pitch));
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]));
lpcnet->old_gain[0] = features[PITCH_GAIN_FEATURE];