shithub: aubio

Download patch

ref: 2a94ecaa7259f4ba7089347cf540f38250f25a64
parent: 2589ea9c604202f29436337103cc5b9db03f9608
author: Paul Brossier <piem@piem.org>
date: Thu Dec 20 14:03:45 EST 2018

[io] add helpers to pad source output

--- a/src/io/ioutils.c
+++ b/src/io/ioutils.c
@@ -19,6 +19,7 @@
 */
 
 #include "aubio_priv.h"
+#include "fmat.h"
 
 uint_t
 aubio_io_validate_samplerate(const char_t *kind, const char_t *path, uint_t samplerate)
@@ -89,6 +90,30 @@
     channels = source_channels;
   }
   return channels;
+}
+
+void
+aubio_source_pad_output (fvec_t *read_data, uint_t source_read)
+{
+  uint_t i = 0;
+  if (source_read < read_data->length) {
+    for (i = source_read; i < read_data->length; i++) {
+      read_data->data[i] = 0.;
+    }
+  }
+}
+
+void
+aubio_source_pad_multi_output (fmat_t *read_data,
+    uint_t source_channels, uint_t source_read) {
+  uint_t i, j;
+  if (source_read < read_data->length) {
+    for (i = 0; i < read_data->height; i++) {
+      for (j = source_read; j < read_data->length; j++) {
+        read_data->data[i][j] = 0.;
+      }
+    }
+  }
 }
 
 uint_t
--- a/src/io/ioutils.h
+++ b/src/io/ioutils.h
@@ -79,6 +79,26 @@
 aubio_source_validate_input_channels(const char_t *kind, const char_t *path,
     uint_t source_channels, uint_t read_data_height);
 
+/** pad end of source output vector with zeroes
+
+  \param read_data   output vector to pad
+  \param source_read number of frames read
+
+*/
+void
+aubio_source_pad_output (fvec_t *read_data, uint_t source_read);
+
+/** pad end of source output matrix with zeroes
+
+  \param read_data   output matrix to pad
+  \param source_channels number of channels in the source
+  \param source_read number of frames read
+
+*/
+void
+aubio_source_pad_multi_output (fmat_t *read_data, uint_t source_channels,
+        uint_t source_read);
+
 /** validate length of sink input
 
   \param kind       the object kind to report on