src/io/source_sndfile.c: mono to stereo, copying last channel of file to all remainin...
authorPaul Brossier <piem@piem.org>
Mon, 8 Apr 2013 15:27:02 +0000 (10:27 -0500)
committerPaul Brossier <piem@piem.org>
Mon, 8 Apr 2013 15:27:02 +0000 (10:27 -0500)
src/io/source_sndfile.c

index 489dfbb72f01da9fcb4bd80de7d2892c2d88fc8a..28b31d348574046bbf7c9ae5b688ef1c1fb98291 100644 (file)
@@ -204,6 +204,15 @@ void aubio_source_sndfile_do_multi(aubio_source_sndfile_t * s, fmat_t * read_dat
       data[i][j] = (smpl_t)s->scratch_data[input_channels*j+i];
     }
   }
+  // if read_data has more channels than the file
+  if (read_data->height > input_channels) {
+    // copy last channel to all additional channels
+    for (j = 0; j < read_samples / input_channels; j++) {
+      for (i = input_channels; i < read_to->height; i++) {
+        data[i][v] = s->scratch_data[ j * input_channels + (input_channels - 1)];
+      }
+    }
+  }
 
 #ifdef HAVE_SAMPLERATE
   if (s->resampler) {