diff --git a/buffer.c b/buffer.c index e860467..8733d51 100644 --- a/buffer.c +++ b/buffer.c @@ -12,8 +12,8 @@ float *do_buffer(struct buffer *d, float input) { d->s[d->last0] = input; d->s[d->last1] = input; - d->last0 = (d->last0 - 1) < 0 ? d->len : d->last0 - 1; - d->last1 = (d->last1 - 1) < 0 ? d->len : d->last1 - 1; + d->last0 = (d->last0 - 1) < 0 ? d->len - 1 : d->last0 - 1; + d->last1 = (d->last1 - 1) < 0 ? d->len - 1 : d->last1 - 1; int last = d->last0 < d->last1 ? d->last0 : d->last1; return d->s + last; }