shithub: aubio

Download patch

ref: d22cc429cd5621210d3e71a4361b6d5b53febf43
parent: 18c6b2020965ecbc48929cdb56451968fd6c4750
author: Paul Brossier <piem@piem.org>
date: Mon Jul 16 09:36:50 EDT 2012

src/io/source_sndfile.c: refuse to run when when resampled hop_size does not match the requested one

--- a/src/io/source_sndfile.c
+++ b/src/io/source_sndfile.c
@@ -105,7 +105,12 @@
   if (s->ratio != 1) {
     s->input_data = new_fvec(s->input_hop_size);
     s->resampler = new_aubio_resampler(s->ratio, 0);
-    if (s-> ratio > 1) {
+    if (s->ratio > 1) {
+      // we would need to add a ring buffer for these
+      if ( (uint_t)(s->input_hop_size * s->ratio + .5)  != s->hop_size ) {
+        AUBIO_ERR("can not upsample from %d to %d\n", s->input_samplerate, s->samplerate);
+        goto beach;
+      }
       AUBIO_WRN("upsampling %s from %d to % d\n", s->path, s->input_samplerate, s->samplerate);
     }
   }
@@ -123,7 +128,7 @@
   return s;
 
 beach:
-  AUBIO_ERR("can not read %s at samplerate %dHz with hop_size of %d\n",
+  AUBIO_ERR("can not read %s at samplerate %dHz with a hop_size of %d\n",
       s->path, s->samplerate, s->hop_size);
   del_aubio_source_sndfile(s);
   return NULL;