[specdesc] fix definition of rolloff (closes gh-318, thanks to @Polochon-street)
authorPaul Brossier <piem@piem.org>
Sun, 16 Nov 2025 13:32:13 +0000 (14:32 +0100)
committerPaul Brossier <piem@piem.org>
Sun, 16 Nov 2025 14:09:54 +0000 (15:09 +0100)
We now return at least the first bin, and at most the last bin number, to
prevent returning a value greater than the length of the norm vector size.

src/spectral/statistics.c

index 4fd66c0..d303364 100644 (file)
@@ -199,6 +199,6 @@ aubio_specdesc_rolloff (aubio_specdesc_t *o UNUSED, const cvec_t * spec,
       rollsum += SQR (spec->norm[j]);
       j++;
     }
-    desc->data[0] = j;
+    desc->data[0] = MAX (1, j) - 1.0f;
   }
 }