From 18a378eef755e01d6f5907dde97a4b272110b4f4 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Thu, 21 Mar 2013 20:50:06 -0500 Subject: [PATCH] src/io/source_sndfile.c: pad with 0 when end of file is reached --- src/io/source_sndfile.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/io/source_sndfile.c b/src/io/source_sndfile.c index 57a069ee..489dfbb7 100644 --- a/src/io/source_sndfile.c +++ b/src/io/source_sndfile.c @@ -171,6 +171,13 @@ void aubio_source_sndfile_do(aubio_source_sndfile_t * s, fvec_t * read_data, uin #endif /* HAVE_SAMPLERATE */ *read = (int)FLOOR(s->ratio * read_samples / input_channels + .5); + + if (*read < s->hop_size) { + for (j = *read; j < s->hop_size; j++) { + data[j] = 0; + } + } + } void aubio_source_sndfile_do_multi(aubio_source_sndfile_t * s, fmat_t * read_data, uint_t * read){ @@ -205,6 +212,15 @@ void aubio_source_sndfile_do_multi(aubio_source_sndfile_t * s, fmat_t * read_dat #endif /* HAVE_SAMPLERATE */ *read = (int)FLOOR(s->ratio * read_samples / input_channels + .5); + + if (*read < s->hop_size) { + for (i = 0; i < input_channels; i++) { + for (j = *read; j < s->hop_size; j++) { + data[i][j] = 0.; + } + } + } + } uint_t aubio_source_sndfile_get_samplerate(aubio_source_sndfile_t * s) { -- 2.26.2