From b8389deb101c95e4b7f796b9f0052d4d6445abbf Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Fri, 22 Mar 2013 19:55:46 -0500 Subject: [PATCH] src/io/source_apple_audio.c: copy data to missing channels --- src/io/source_apple_audio.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/io/source_apple_audio.c b/src/io/source_apple_audio.c index e2241879..10dc8343 100644 --- a/src/io/source_apple_audio.c +++ b/src/io/source_apple_audio.c @@ -204,10 +204,19 @@ void aubio_source_apple_audio_do_multi(aubio_source_apple_audio_t *s, fmat_t * r buf[c][v] = SHORT_TO_FLOAT(data[ v * s->channels + c]); } } + // if read_data has more channels than the file + if (read_to->height > s->channels) { + // copy last channel to all additional channels + for (v = 0; v < loadedPackets; v++) { + for (c = s->channels; c < read_to->height; c++) { + buf[c][v] = SHORT_TO_FLOAT(data[ v * s->channels + (s->channels - 1)]); + } + } + } // short read, fill with zeros if (loadedPackets < s->block_size) { for (v = loadedPackets; v < s->block_size; v++) { - for (c = 0; c < s->channels; c++) { + for (c = 0; c < read_to->height; c++) { buf[c][v] = 0.; } } -- 2.26.2