/* Adds a new value to the sma_i_t instances.  */
void sma_i_add(sma_i_t *sma, int32_t x)
/* Adds a new value to the sma_i_t instances.  */
void sma_i_add(sma_i_t *sma, int32_t x)
{
  int32_t *pSource = sma->buffer + (sma->k % sma->size);
  sma->total -= *pSource;
  *pSource = x;
  sma->total += x;
  sma->k++;
  if (sma->k < sma->size)
    return;
  sma->avg = (int32_t)(sma->total >> sma->exponent);
}