src/io/source_sndfile.c: automagically set samplerate to input file if 0 is requested
authorPaul Brossier <piem@piem.org>
Sun, 10 Feb 2013 05:30:31 +0000 (00:30 -0500)
committerPaul Brossier <piem@piem.org>
Sun, 10 Feb 2013 05:30:31 +0000 (00:30 -0500)
src/io/source_sndfile.c

index f0925c25c9c69d42f2974c3913972ed11cdea02a..027583e3cf61e49a60707179f21fa11cf170a858 100644 (file)
@@ -69,7 +69,6 @@ aubio_source_sndfile_t * new_aubio_source_sndfile(char_t * path, uint_t samplera
   }
 
   s->hop_size = hop_size;
-  s->samplerate = samplerate;
   s->channels = 1;
   s->path = path;
 
@@ -89,6 +88,11 @@ aubio_source_sndfile_t * new_aubio_source_sndfile(char_t * path, uint_t samplera
   s->input_channels   = sfinfo.channels;
   s->input_format     = sfinfo.format;
 
+  if (samplerate == 0) {
+    samplerate = s->input_samplerate;
+    AUBIO_WRN("sampling rate set to 0, automagically adjusting to %d", samplerate);
+  }
+  s->samplerate = samplerate;
   /* compute input block size required before resampling */
   s->ratio = s->samplerate/(float)s->input_samplerate;
   s->input_hop_size = (uint_t)FLOOR(s->hop_size / s->ratio + .5);