From 65108666ab0c42175d4218c752c56612b3d8509c Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Mon, 8 Apr 2013 10:27:02 -0500 Subject: [PATCH] src/io/source_sndfile.c: mono to stereo, copying last channel of file to all remaining output matrix channels --- src/io/source_sndfile.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/io/source_sndfile.c b/src/io/source_sndfile.c index 489dfbb7..28b31d34 100644 --- a/src/io/source_sndfile.c +++ b/src/io/source_sndfile.c @@ -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) { -- 2.26.2